Go to the source code of this file.
Functions | |
struct st_renderbuffer * | st_get_color_read_renderbuffer (GLcontext *ctx) |
Return renderbuffer to use for reading color pixels for glRead/CopyPixel commands. | |
void | st_read_stencil_pixels (GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, const struct gl_pixelstore_attrib *packing, GLvoid *pixels) |
glReadPixels interface to pipe | |
void | st_init_readpixels_functions (struct dd_function_table *functions) |
struct st_renderbuffer* st_get_color_read_renderbuffer | ( | GLcontext * | ctx | ) | [read] |
Return renderbuffer to use for reading color pixels for glRead/CopyPixel commands.
Special care is needed for the front buffer.
Definition at line 143 of file st_cb_readpixels.c.
References FRONT_STATUS_COPY_OF_BACK, and st_renderbuffer().
00144 { 00145 struct gl_framebuffer *fb = ctx->ReadBuffer; 00146 struct st_renderbuffer *strb = 00147 st_renderbuffer(fb->_ColorReadBuffer); 00148 struct st_renderbuffer *front = 00149 st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); 00150 00151 if (strb == front 00152 && ctx->st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { 00153 /* reading from front color buffer, which is a logical copy of the 00154 * back color buffer. 00155 */ 00156 struct st_renderbuffer *back = 00157 st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); 00158 strb = back; 00159 } 00160 00161 return strb; 00162 }
void st_init_readpixels_functions | ( | struct dd_function_table * | functions | ) |
Definition at line 461 of file st_cb_readpixels.c.
References st_readpixels().
00462 { 00463 functions->ReadPixels = st_readpixels; 00464 }
void st_read_stencil_pixels | ( | GLcontext * | ctx, | |
GLint | x, | |||
GLint | y, | |||
GLsizei | width, | |||
GLsizei | height, | |||
GLenum | type, | |||
const struct gl_pixelstore_attrib * | packing, | |||
GLvoid * | pixels | |||
) |
glReadPixels interface to pipe
Definition at line 58 of file st_cb_readpixels.c.
References assert, ASSERT, pipe_surface::format, pipe_screen::get_tex_surface, MAX_WIDTH, PIPE_BUFFER_USAGE_CPU_READ, PIPE_FORMAT_S8_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_Z24S8_UNORM, pipe_surface_reference(), st_fb_orientation(), st_renderbuffer(), pipe_surface::stride, pipe_screen::surface_map, pipe_screen::surface_unmap, st_renderbuffer::texture, and Y_0_TOP.
00062 { 00063 struct gl_framebuffer *fb = ctx->ReadBuffer; 00064 struct pipe_screen *screen = ctx->st->pipe->screen; 00065 struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer); 00066 struct pipe_surface *ps; 00067 ubyte *stmap; 00068 GLint j; 00069 00070 /* Create a CPU-READ surface/view into the renderbuffer's texture */ 00071 ps = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, 00072 PIPE_BUFFER_USAGE_CPU_READ); 00073 00074 /* map the stencil buffer */ 00075 stmap = screen->surface_map(screen, ps, PIPE_BUFFER_USAGE_CPU_READ); 00076 00077 /* width should never be > MAX_WIDTH since we did clipping earlier */ 00078 ASSERT(width <= MAX_WIDTH); 00079 00080 /* process image row by row */ 00081 for (j = 0; j < height; j++, y++) { 00082 GLvoid *dest; 00083 GLstencil values[MAX_WIDTH]; 00084 GLint srcY; 00085 00086 if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { 00087 srcY = ctx->DrawBuffer->Height - y - 1; 00088 } 00089 else { 00090 srcY = y; 00091 } 00092 00093 /* get stencil values */ 00094 switch (ps->format) { 00095 case PIPE_FORMAT_S8_UNORM: 00096 { 00097 const ubyte *src = stmap + srcY * ps->stride + x; 00098 memcpy(values, src, width); 00099 } 00100 break; 00101 case PIPE_FORMAT_S8Z24_UNORM: 00102 { 00103 const uint *src = (uint *) (stmap + srcY * ps->stride + x*4); 00104 GLint k; 00105 for (k = 0; k < width; k++) { 00106 values[k] = src[k] >> 24; 00107 } 00108 } 00109 break; 00110 case PIPE_FORMAT_Z24S8_UNORM: 00111 { 00112 const uint *src = (uint *) (stmap + srcY * ps->stride + x*4); 00113 GLint k; 00114 for (k = 0; k < width; k++) { 00115 values[k] = src[k] & 0xff; 00116 } 00117 } 00118 break; 00119 default: 00120 assert(0); 00121 } 00122 00123 /* store */ 00124 dest = _mesa_image_address2d(packing, pixels, width, height, 00125 GL_STENCIL_INDEX, type, j, 0); 00126 00127 _mesa_pack_stencil_span(ctx, width, type, dest, values, packing); 00128 } 00129 00130 00131 /* unmap the stencil buffer */ 00132 screen->surface_unmap(screen, ps); 00133 pipe_surface_reference(&ps, NULL); 00134 }