summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-15 17:13:37 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-15 17:58:48 +0900
commitd5ed158dc87669f62bb7d3fb65c23fb2a465442b (patch)
treef1f8b813c0f09ec1d7a013c0f4b63a7a477c4ee0
parent9a99b19949e407528b5b40309efd344672de8f6f (diff)
python: Get object ownership done correctly.
-rw-r--r--src/gallium/state_trackers/python/gallium.i44
-rw-r--r--src/gallium/state_trackers/python/st_device.c1
-rw-r--r--src/gallium/state_trackers/python/st_hardpipe_winsys.c2
3 files changed, 37 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 967840a063..2f1d8b22fb 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -66,6 +66,7 @@
%rename(Surface) pipe_surface;
%rename(Buffer) pipe_buffer;
+
%rename(BlendColor) pipe_blend_color;
%rename(Blend) pipe_blend_state;
%rename(Clip) pipe_clip_state;
@@ -82,15 +83,30 @@
%rename(VertexElement) pipe_vertex_element;
%rename(Viewport) pipe_viewport_state;
+%nodefaultctor st_device;
+%nodefaultctor st_context;
+%nodefaultctor pipe_texture;
+%nodefaultctor pipe_surface;
+%nodefaultctor pipe_buffer;
+
+%nodefaultdtor st_device;
+%nodefaultdtor st_context;
+%nodefaultdtor pipe_texture;
+%nodefaultdtor pipe_surface;
+%nodefaultdtor pipe_buffer;
+
+%ignore pipe_texture::screen;
+
+%ignore pipe_surface::winsys;
+%immutable pipe_surface::texture;
+%immutable pipe_surface::buffer;
+
%include "p_format.i";
%include "pipe/p_defines.h";
%include "pipe/p_state.h";
%include "pipe/p_shader_tokens.h";
-%nodefaultctor;
-%nodefaultdtor;
-
struct st_device {
};
@@ -98,6 +114,10 @@ struct st_context {
};
+%newobject st_device::texture_create;
+%newobject st_device::context_create;
+%newobject st_device::buffer_create;
+
%extend st_device {
st_device(int hardware = 1) {
@@ -157,6 +177,7 @@ struct st_context {
unsigned usage = 0
) {
struct pipe_texture templat;
+ struct pipe_texture *texture;
memset(&templat, 0, sizeof(templat));
templat.format = format;
pf_get_block(templat.format, &templat.block);
@@ -166,7 +187,9 @@ struct st_context {
templat.last_level = last_level;
templat.target = target;
templat.tex_usage = usage;
- return $self->screen->texture_create($self->screen, &templat);
+ texture = $self->screen->texture_create($self->screen, &templat);
+ fprintf(stderr, "creating texture %p\n", texture);
+ return texture;
}
struct pipe_buffer *
@@ -335,10 +358,6 @@ error1:
;
}
- void draw_quad(float x0, float y0, float x1, float y1, float z = 0.0f) {
- util_draw_texquad($self->pipe, x0, y0, x1, y1, z);
- }
-
void
flush(void) {
struct pipe_fence_handle *fence = NULL;
@@ -375,10 +394,13 @@ error1:
};
+%newobject pipe_texture::get_surface;
+
%extend pipe_texture {
~pipe_texture() {
struct pipe_texture *ptr = $self;
+ fprintf(stderr, "destroying texture %p\n", $self);
pipe_texture_reference(&ptr, NULL);
}
@@ -387,7 +409,10 @@ error1:
get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0, unsigned usage=0 )
{
struct pipe_screen *screen = $self->screen;
- return screen->get_tex_surface(screen, $self, face, level, zslice, usage);
+ struct pipe_surface *surface;
+ surface = screen->get_tex_surface(screen, $self, face, level, zslice, usage);
+ fprintf(stderr, "creating surface %p\n", surface);
+ return surface;
}
};
@@ -397,6 +422,7 @@ error1:
~pipe_surface() {
struct pipe_surface *ptr = $self;
+ fprintf(stderr, "destroying surface %p\n", $self);
pipe_surface_reference(&ptr, NULL);
}
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index d88d2de3c6..9e625ae2e0 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -70,6 +70,7 @@ st_device_create_from_st_winsys(const struct st_winsys *st_ws)
if(!st_dev)
return NULL;
+ st_dev->refcount = 1;
st_dev->st_ws = st_ws;
st_dev->screen = st_ws->screen_create();
diff --git a/src/gallium/state_trackers/python/st_hardpipe_winsys.c b/src/gallium/state_trackers/python/st_hardpipe_winsys.c
index 33b75637b3..1e04998232 100644
--- a/src/gallium/state_trackers/python/st_hardpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_hardpipe_winsys.c
@@ -37,8 +37,8 @@
#include "st_winsys.h"
+/* XXX: Force init_gallium symbol to be linked */
extern void init_gallium(void);
-
void (*force_init_gallium_linkage)(void) = &init_gallium;