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
::face
;
46 %immutable st_surface
::level
;
47 %immutable st_surface
::zslice
;
49 %newobject pipe_resource
::get_surface
;
51 /* Avoid naming conflict with p_inlines.h's pipe_buffer_read
/write
*/
53 %rename
(write
) write_
;
55 %extend pipe_resource
{
58 struct pipe_resource
*ptr
= $self
;
59 pipe_resource_reference
(&ptr, NULL);
62 unsigned get_width
(unsigned level
=0) {
63 return u_minify
($self-
>width0
, level
);
66 unsigned get_height
(unsigned level
=0) {
67 return u_minify
($self-
>height0
, level
);
70 unsigned get_depth
(unsigned level
=0) {
71 return u_minify
($self-
>depth0
, level
);
74 /** Get a surface which is a
"view" into a texture
*/
76 get_surface
(unsigned face
=0, unsigned level
=0, unsigned zslice
=0)
78 struct st_surface
*surface
;
80 if
(face
>= ($self-
>target
== PIPE_TEXTURE_CUBE ?
6U : 1U))
81 SWIG_exception
(SWIG_ValueError
, "face out of bounds");
82 if
(level
> $self-
>last_level
)
83 SWIG_exception
(SWIG_ValueError
, "level out of bounds");
84 if
(zslice
>= u_minify
($self-
>depth0
, level
))
85 SWIG_exception
(SWIG_ValueError
, "zslice out of bounds");
87 surface
= CALLOC_STRUCT
(st_surface
);
91 pipe_resource_reference
(&surface->texture, $self);
93 surface-
>level
= level
;
94 surface-
>zslice
= zslice
;
102 unsigned __len__
(void
)
104 assert
($self-
>target
== PIPE_BUFFER
);
105 assert
(p_atomic_read
(&$self->reference.count) > 0);
106 return $self-
>width0
;
115 struct pipe_resource
*texture
;
131 pipe_resource_reference
(&$self->texture, NULL);
139 static enum pipe_format
140 st_surface_format_get
(struct st_surface
*surface
)
142 return surface-
>texture-
>format
;
146 st_surface_width_get
(struct st_surface
*surface
)
148 return u_minify
(surface-
>texture-
>width0
, surface-
>level
);
152 st_surface_height_get
(struct st_surface
*surface
)
154 return u_minify
(surface-
>texture-
>height0
, surface-
>level
);