1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * SWIG interface definion for Gallium types.
32 * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
36 %nodefaultctor pipe_resource;
37 %nodefaultctor st_surface;
39 %nodefaultdtor pipe_resource;
40 %nodefaultdtor st_surface;
42 %ignore pipe_resource::screen;
44 %immutable st_surface::texture;
45 %immutable st_surface::level;
46 %immutable st_surface::layer;
48 %newobject pipe_resource::get_surface;
50 /* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */
52 %rename(write) write_;
54 %extend pipe_resource {
57 struct pipe_resource *ptr = $self;
58 pipe_resource_reference(&ptr, NULL);
61 unsigned get_width(unsigned level=0) {
62 return u_minify($self->width0, level);
65 unsigned get_height(unsigned level=0) {
66 return u_minify($self->height0, level);
69 unsigned get_depth(unsigned level=0) {
70 return u_minify($self->depth0, level);
73 /** Get a surface which is a "view" into a texture */
75 get_surface(unsigned level=0, unsigned layer=0)
77 struct st_surface *surface;
79 if(level > $self->last_level)
80 SWIG_exception(SWIG_ValueError, "level out of bounds");
81 if(layer >= ($self->target == PIPE_TEXTURE_3D ?
82 u_minify($self->depth0, level) : $self->depth0))
83 SWIG_exception(SWIG_ValueError, "layer out of bounds");
85 surface = CALLOC_STRUCT(st_surface);
89 pipe_resource_reference(&surface->texture, $self);
90 surface->level = level;
91 surface->layer = layer;
99 unsigned __len__(void)
101 assert($self->target == PIPE_BUFFER);
102 assert(p_atomic_read(&$self->reference.count) > 0);
103 return $self->width0;
112 struct pipe_resource *texture;
127 pipe_resource_reference(&$self->texture, NULL);
135 static enum pipe_format
136 st_surface_format_get(struct st_surface *surface)
138 return surface->texture->format;
142 st_surface_width_get(struct st_surface *surface)
144 return u_minify(surface->texture->width0, surface->level);
148 st_surface_height_get(struct st_surface *surface)
150 return u_minify(surface->texture->height0, surface->level);