2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "main/glheader.h"
27 #include "main/context.h"
28 #include "main/colormac.h"
29 #include "main/condrender.h"
30 #include "main/convolve.h"
31 #include "main/image.h"
32 #include "main/macros.h"
33 #include "main/imports.h"
35 #include "s_context.h"
38 #include "s_stencil.h"
44 * Determine if there's overlap in an image copy.
45 * This test also compensates for the fact that copies are done from
46 * bottom to top and overlaps can sometimes be handled correctly
47 * without making a temporary image copy.
48 * \return GL_TRUE if the regions overlap, GL_FALSE otherwise.
51 regions_overlap(GLint srcx
, GLint srcy
,
52 GLint dstx
, GLint dsty
,
53 GLint width
, GLint height
,
54 GLfloat zoomX
, GLfloat zoomY
)
56 if (zoomX
== 1.0 && zoomY
== 1.0) {
58 if (srcx
>= dstx
+ width
|| (srcx
+ width
<= dstx
)) {
61 else if (srcy
< dsty
) { /* this is OK */
64 else if (srcy
> dsty
+ height
) {
72 /* add one pixel of slop when zooming, just to be safe */
73 if (srcx
> (dstx
+ ((zoomX
> 0.0F
) ? (width
* zoomX
+ 1.0F
) : 0.0F
))) {
74 /* src is completely right of dest */
77 else if (srcx
+ width
+ 1.0F
< dstx
+ ((zoomX
> 0.0F
) ? 0.0F
: (width
* zoomX
))) {
78 /* src is completely left of dest */
81 else if ((srcy
< dsty
) && (srcy
+ height
< dsty
+ (height
* zoomY
))) {
82 /* src is completely below dest */
85 else if ((srcy
> dsty
) && (srcy
+ height
> dsty
+ (height
* zoomY
))) {
86 /* src is completely above dest */
97 * RGBA copypixels with convolution.
100 copy_conv_rgba_pixels(GLcontext
*ctx
, GLint srcx
, GLint srcy
,
101 GLint width
, GLint height
, GLint destx
, GLint desty
)
104 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
105 const GLbitfield transferOps
= ctx
->_ImageTransferState
;
106 const GLboolean sink
= (ctx
->Pixel
.MinMaxEnabled
&& ctx
->MinMax
.Sink
)
107 || (ctx
->Pixel
.HistogramEnabled
&& ctx
->Histogram
.Sink
);
108 GLfloat
*dest
, *tmpImage
, *convImage
;
111 INIT_SPAN(span
, GL_BITMAP
);
112 _swrast_span_default_attribs(ctx
, &span
);
113 span
.arrayMask
= SPAN_RGBA
;
114 span
.arrayAttribs
= FRAG_BIT_COL0
;
116 /* allocate space for GLfloat image */
117 tmpImage
= (GLfloat
*) malloc(width
* height
* 4 * sizeof(GLfloat
));
119 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels");
122 convImage
= (GLfloat
*) malloc(width
* height
* 4 * sizeof(GLfloat
));
125 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels");
129 /* read source image as float/RGBA */
131 for (row
= 0; row
< height
; row
++) {
132 _swrast_read_rgba_span(ctx
, ctx
->ReadBuffer
->_ColorReadBuffer
,
133 width
, srcx
, srcy
+ row
, GL_FLOAT
, dest
);
137 /* do the image transfer ops which preceed convolution */
138 for (row
= 0; row
< height
; row
++) {
139 GLfloat (*rgba
)[4] = (GLfloat (*)[4]) (tmpImage
+ row
* width
* 4);
140 _mesa_apply_rgba_transfer_ops(ctx
,
141 transferOps
& IMAGE_PRE_CONVOLUTION_BITS
,
146 if (ctx
->Pixel
.Convolution2DEnabled
) {
147 _mesa_convolve_2d_image(ctx
, &width
, &height
, tmpImage
, convImage
);
150 ASSERT(ctx
->Pixel
.Separable2DEnabled
);
151 _mesa_convolve_sep_image(ctx
, &width
, &height
, tmpImage
, convImage
);
155 /* do remaining post-convolution image transfer ops */
156 for (row
= 0; row
< height
; row
++) {
157 GLfloat (*rgba
)[4] = (GLfloat (*)[4]) (convImage
+ row
* width
* 4);
158 _mesa_apply_rgba_transfer_ops(ctx
,
159 transferOps
& IMAGE_POST_CONVOLUTION_BITS
,
164 /* write the new image */
165 for (row
= 0; row
< height
; row
++) {
166 const GLfloat
*src
= convImage
+ row
* width
* 4;
167 GLfloat
*rgba
= (GLfloat
*) span
.array
->attribs
[FRAG_ATTRIB_COL0
];
169 /* copy convolved colors into span array */
170 memcpy(rgba
, src
, width
* 4 * sizeof(GLfloat
));
174 span
.y
= desty
+ row
;
176 span
.array
->ChanType
= GL_FLOAT
;
178 _swrast_write_zoomed_rgba_span(ctx
, destx
, desty
, &span
, rgba
);
181 _swrast_write_rgba_span(ctx
, &span
);
185 span
.array
->ChanType
= CHAN_TYPE
;
196 copy_rgba_pixels(GLcontext
*ctx
, GLint srcx
, GLint srcy
,
197 GLint width
, GLint height
, GLint destx
, GLint desty
)
199 GLfloat
*tmpImage
, *p
;
200 GLint sy
, dy
, stepy
, row
;
201 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
203 GLuint transferOps
= ctx
->_ImageTransferState
;
206 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
207 /* no readbuffer - OK */
211 if (ctx
->Pixel
.Convolution2DEnabled
|| ctx
->Pixel
.Separable2DEnabled
) {
212 copy_conv_rgba_pixels(ctx
, srcx
, srcy
, width
, height
, destx
, desty
);
215 else if (ctx
->Pixel
.Convolution1DEnabled
) {
216 /* make sure we don't apply 1D convolution */
217 transferOps
&= ~(IMAGE_CONVOLUTION_BIT
|
218 IMAGE_POST_CONVOLUTION_SCALE_BIAS
);
221 if (ctx
->DrawBuffer
== ctx
->ReadBuffer
) {
222 overlapping
= regions_overlap(srcx
, srcy
, destx
, desty
, width
, height
,
223 ctx
->Pixel
.ZoomX
, ctx
->Pixel
.ZoomY
);
226 overlapping
= GL_FALSE
;
229 /* Determine if copy should be done bottom-to-top or top-to-bottom */
230 if (!overlapping
&& srcy
< desty
) {
231 /* top-down max-to-min */
232 sy
= srcy
+ height
- 1;
233 dy
= desty
+ height
- 1;
237 /* bottom-up min-to-max */
243 INIT_SPAN(span
, GL_BITMAP
);
244 _swrast_span_default_attribs(ctx
, &span
);
245 span
.arrayMask
= SPAN_RGBA
;
246 span
.arrayAttribs
= FRAG_BIT_COL0
; /* we'll fill in COL0 attrib values */
249 tmpImage
= (GLfloat
*) malloc(width
* height
* sizeof(GLfloat
) * 4);
251 _mesa_error( ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels" );
254 /* read the source image as RGBA/float */
256 for (row
= 0; row
< height
; row
++) {
257 _swrast_read_rgba_span( ctx
, ctx
->ReadBuffer
->_ColorReadBuffer
,
258 width
, srcx
, sy
+ row
, GL_FLOAT
, p
);
264 tmpImage
= NULL
; /* silence compiler warnings */
268 ASSERT(width
< MAX_WIDTH
);
270 for (row
= 0; row
< height
; row
++, sy
+= stepy
, dy
+= stepy
) {
271 GLvoid
*rgba
= span
.array
->attribs
[FRAG_ATTRIB_COL0
];
273 /* Get row/span of source pixels */
275 /* get from buffered image */
276 memcpy(rgba
, p
, width
* sizeof(GLfloat
) * 4);
280 /* get from framebuffer */
281 _swrast_read_rgba_span( ctx
, ctx
->ReadBuffer
->_ColorReadBuffer
,
282 width
, srcx
, sy
, GL_FLOAT
, rgba
);
286 _mesa_apply_rgba_transfer_ops(ctx
, transferOps
, width
,
287 (GLfloat (*)[4]) rgba
);
290 /* Write color span */
294 span
.array
->ChanType
= GL_FLOAT
;
296 _swrast_write_zoomed_rgba_span(ctx
, destx
, desty
, &span
, rgba
);
299 _swrast_write_rgba_span(ctx
, &span
);
303 span
.array
->ChanType
= CHAN_TYPE
; /* restore */
311 * Convert floating point Z values to integer Z values with pixel transfer's
315 scale_and_bias_z(GLcontext
*ctx
, GLuint width
,
316 const GLfloat depth
[], GLuint z
[])
318 const GLuint depthMax
= ctx
->DrawBuffer
->_DepthMax
;
321 if (depthMax
<= 0xffffff &&
322 ctx
->Pixel
.DepthScale
== 1.0 &&
323 ctx
->Pixel
.DepthBias
== 0.0) {
324 /* no scale or bias and no clamping and no worry of overflow */
325 const GLfloat depthMaxF
= ctx
->DrawBuffer
->_DepthMaxF
;
326 for (i
= 0; i
< width
; i
++) {
327 z
[i
] = (GLuint
) (depth
[i
] * depthMaxF
);
331 /* need to be careful with overflow */
332 const GLdouble depthMaxF
= ctx
->DrawBuffer
->_DepthMaxF
;
333 for (i
= 0; i
< width
; i
++) {
334 GLdouble d
= depth
[i
] * ctx
->Pixel
.DepthScale
+ ctx
->Pixel
.DepthBias
;
335 d
= CLAMP(d
, 0.0, 1.0) * depthMaxF
;
350 copy_depth_pixels( GLcontext
*ctx
, GLint srcx
, GLint srcy
,
351 GLint width
, GLint height
,
352 GLint destx
, GLint desty
)
354 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
355 struct gl_renderbuffer
*readRb
= fb
->_DepthBuffer
;
356 GLfloat
*p
, *tmpImage
;
359 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
364 /* no readbuffer - OK */
368 INIT_SPAN(span
, GL_BITMAP
);
369 _swrast_span_default_attribs(ctx
, &span
);
370 span
.arrayMask
= SPAN_Z
;
372 if (ctx
->DrawBuffer
== ctx
->ReadBuffer
) {
373 overlapping
= regions_overlap(srcx
, srcy
, destx
, desty
, width
, height
,
374 ctx
->Pixel
.ZoomX
, ctx
->Pixel
.ZoomY
);
377 overlapping
= GL_FALSE
;
380 /* Determine if copy should be bottom-to-top or top-to-bottom */
381 if (!overlapping
&& srcy
< desty
) {
382 /* top-down max-to-min */
383 sy
= srcy
+ height
- 1;
384 dy
= desty
+ height
- 1;
388 /* bottom-up min-to-max */
396 tmpImage
= (GLfloat
*) malloc(width
* height
* sizeof(GLfloat
));
398 _mesa_error( ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels" );
402 for (j
= 0; j
< height
; j
++, ssy
+= stepy
) {
403 _swrast_read_depth_span_float(ctx
, readRb
, width
, srcx
, ssy
, p
);
409 tmpImage
= NULL
; /* silence compiler warning */
413 for (j
= 0; j
< height
; j
++, sy
+= stepy
, dy
+= stepy
) {
414 GLfloat depth
[MAX_WIDTH
];
415 /* get depth values */
417 memcpy(depth
, p
, width
* sizeof(GLfloat
));
421 _swrast_read_depth_span_float(ctx
, readRb
, width
, srcx
, sy
, depth
);
424 /* apply scale and bias */
425 scale_and_bias_z(ctx
, width
, depth
, span
.array
->z
);
427 /* write depth values */
432 _swrast_write_zoomed_depth_span(ctx
, destx
, desty
, &span
);
434 _swrast_write_rgba_span(ctx
, &span
);
444 copy_stencil_pixels( GLcontext
*ctx
, GLint srcx
, GLint srcy
,
445 GLint width
, GLint height
,
446 GLint destx
, GLint desty
)
448 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
449 struct gl_renderbuffer
*rb
= fb
->_StencilBuffer
;
452 GLstencil
*p
, *tmpImage
;
453 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
457 /* no readbuffer - OK */
461 if (ctx
->DrawBuffer
== ctx
->ReadBuffer
) {
462 overlapping
= regions_overlap(srcx
, srcy
, destx
, desty
, width
, height
,
463 ctx
->Pixel
.ZoomX
, ctx
->Pixel
.ZoomY
);
466 overlapping
= GL_FALSE
;
469 /* Determine if copy should be bottom-to-top or top-to-bottom */
470 if (!overlapping
&& srcy
< desty
) {
471 /* top-down max-to-min */
472 sy
= srcy
+ height
- 1;
473 dy
= desty
+ height
- 1;
477 /* bottom-up min-to-max */
485 tmpImage
= (GLstencil
*) malloc(width
* height
* sizeof(GLstencil
));
487 _mesa_error( ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels" );
491 for (j
= 0; j
< height
; j
++, ssy
+= stepy
) {
492 _swrast_read_stencil_span( ctx
, rb
, width
, srcx
, ssy
, p
);
498 tmpImage
= NULL
; /* silence compiler warning */
502 for (j
= 0; j
< height
; j
++, sy
+= stepy
, dy
+= stepy
) {
503 GLstencil stencil
[MAX_WIDTH
];
505 /* Get stencil values */
507 memcpy(stencil
, p
, width
* sizeof(GLstencil
));
511 _swrast_read_stencil_span( ctx
, rb
, width
, srcx
, sy
, stencil
);
514 _mesa_apply_stencil_transfer_ops(ctx
, width
, stencil
);
516 /* Write stencil values */
518 _swrast_write_zoomed_stencil_span(ctx
, destx
, desty
, width
,
522 _swrast_write_stencil_span( ctx
, width
, destx
, dy
, stencil
);
532 * This isn't terribly efficient. If a driver really has combined
533 * depth/stencil buffers the driver should implement an optimized
534 * CopyPixels function.
537 copy_depth_stencil_pixels(GLcontext
*ctx
,
538 const GLint srcX
, const GLint srcY
,
539 const GLint width
, const GLint height
,
540 const GLint destX
, const GLint destY
)
542 struct gl_renderbuffer
*stencilReadRb
, *depthReadRb
, *depthDrawRb
;
545 GLstencil
*tempStencilImage
= NULL
, *stencilPtr
= NULL
;
546 GLfloat
*tempDepthImage
= NULL
, *depthPtr
= NULL
;
547 const GLfloat depthScale
= ctx
->DrawBuffer
->_DepthMaxF
;
548 const GLuint stencilMask
= ctx
->Stencil
.WriteMask
[0];
549 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
550 const GLboolean scaleOrBias
551 = ctx
->Pixel
.DepthScale
!= 1.0 || ctx
->Pixel
.DepthBias
!= 0.0;
554 depthDrawRb
= ctx
->DrawBuffer
->_DepthBuffer
;
555 depthReadRb
= ctx
->ReadBuffer
->_DepthBuffer
;
556 stencilReadRb
= ctx
->ReadBuffer
->_StencilBuffer
;
560 ASSERT(stencilReadRb
);
562 if (ctx
->DrawBuffer
== ctx
->ReadBuffer
) {
563 overlapping
= regions_overlap(srcX
, srcY
, destX
, destY
, width
, height
,
564 ctx
->Pixel
.ZoomX
, ctx
->Pixel
.ZoomY
);
567 overlapping
= GL_FALSE
;
570 /* Determine if copy should be bottom-to-top or top-to-bottom */
571 if (!overlapping
&& srcY
< destY
) {
572 /* top-down max-to-min */
573 sy
= srcY
+ height
- 1;
574 dy
= destY
+ height
- 1;
578 /* bottom-up min-to-max */
587 if (stencilMask
!= 0x0) {
589 = (GLstencil
*) malloc(width
* height
* sizeof(GLstencil
));
590 if (!tempStencilImage
) {
591 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels");
595 /* get copy of stencil pixels */
596 stencilPtr
= tempStencilImage
;
597 for (j
= 0; j
< height
; j
++, ssy
+= stepy
) {
598 _swrast_read_stencil_span(ctx
, stencilReadRb
,
599 width
, srcX
, ssy
, stencilPtr
);
602 stencilPtr
= tempStencilImage
;
605 if (ctx
->Depth
.Mask
) {
607 = (GLfloat
*) malloc(width
* height
* sizeof(GLfloat
));
608 if (!tempDepthImage
) {
609 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCopyPixels");
610 free(tempStencilImage
);
614 /* get copy of depth pixels */
615 depthPtr
= tempDepthImage
;
616 for (j
= 0; j
< height
; j
++, ssy
+= stepy
) {
617 _swrast_read_depth_span_float(ctx
, depthReadRb
,
618 width
, srcX
, ssy
, depthPtr
);
621 depthPtr
= tempDepthImage
;
625 for (j
= 0; j
< height
; j
++, sy
+= stepy
, dy
+= stepy
) {
626 if (stencilMask
!= 0x0) {
627 GLstencil stencil
[MAX_WIDTH
];
629 /* Get stencil values */
631 memcpy(stencil
, stencilPtr
, width
* sizeof(GLstencil
));
635 _swrast_read_stencil_span(ctx
, stencilReadRb
,
636 width
, srcX
, sy
, stencil
);
639 _mesa_apply_stencil_transfer_ops(ctx
, width
, stencil
);
643 _swrast_write_zoomed_stencil_span(ctx
, destX
, destY
, width
,
647 _swrast_write_stencil_span( ctx
, width
, destX
, dy
, stencil
);
651 if (ctx
->Depth
.Mask
) {
652 GLfloat depth
[MAX_WIDTH
];
653 GLuint zVals32
[MAX_WIDTH
];
654 GLushort zVals16
[MAX_WIDTH
];
658 /* get depth values */
660 memcpy(depth
, depthPtr
, width
* sizeof(GLfloat
));
664 _swrast_read_depth_span_float(ctx
, depthReadRb
,
665 width
, srcX
, sy
, depth
);
670 _mesa_scale_and_bias_depth(ctx
, width
, depth
);
672 /* convert to integer Z values */
673 if (depthDrawRb
->DataType
== GL_UNSIGNED_SHORT
) {
675 for (k
= 0; k
< width
; k
++)
676 zVals16
[k
] = (GLushort
) (depth
[k
] * depthScale
);
682 for (k
= 0; k
< width
; k
++)
683 zVals32
[k
] = (GLuint
) (depth
[k
] * depthScale
);
690 _swrast_write_zoomed_z_span(ctx
, destX
, destY
, width
,
694 _swrast_put_row(ctx
, depthDrawRb
, width
, destX
, dy
, zVals
, zBytes
);
699 if (tempStencilImage
)
700 free(tempStencilImage
);
703 free(tempDepthImage
);
709 * Try to do a fast copy pixels.
712 fast_copy_pixels(GLcontext
*ctx
,
713 GLint srcX
, GLint srcY
, GLsizei width
, GLsizei height
,
714 GLint dstX
, GLint dstY
, GLenum type
)
716 struct gl_framebuffer
*srcFb
= ctx
->ReadBuffer
;
717 struct gl_framebuffer
*dstFb
= ctx
->DrawBuffer
;
718 struct gl_renderbuffer
*srcRb
, *dstRb
;
721 if (SWRAST_CONTEXT(ctx
)->_RasterMask
!= 0x0 ||
722 ctx
->Pixel
.ZoomX
!= 1.0F
||
723 ctx
->Pixel
.ZoomY
!= 1.0F
||
724 ctx
->_ImageTransferState
) {
725 /* can't handle these */
729 if (type
== GL_COLOR
) {
730 if (dstFb
->_NumColorDrawBuffers
!= 1)
732 srcRb
= srcFb
->_ColorReadBuffer
;
733 dstRb
= dstFb
->_ColorDrawBuffers
[0];
735 else if (type
== GL_STENCIL
) {
736 srcRb
= srcFb
->_StencilBuffer
;
737 dstRb
= dstFb
->_StencilBuffer
;
739 else if (type
== GL_DEPTH
) {
740 srcRb
= srcFb
->_DepthBuffer
;
741 dstRb
= dstFb
->_DepthBuffer
;
744 ASSERT(type
== GL_DEPTH_STENCIL_EXT
);
746 srcRb
= srcFb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
747 dstRb
= dstFb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
750 /* src and dst renderbuffers must be same format and type */
751 if (!srcRb
|| !dstRb
||
752 srcRb
->DataType
!= dstRb
->DataType
||
753 srcRb
->_BaseFormat
!= dstRb
->_BaseFormat
) {
757 /* clipping not supported */
758 if (srcX
< 0 || srcX
+ width
> (GLint
) srcFb
->Width
||
759 srcY
< 0 || srcY
+ height
> (GLint
) srcFb
->Height
||
760 dstX
< dstFb
->_Xmin
|| dstX
+ width
> dstFb
->_Xmax
||
761 dstY
< dstFb
->_Ymin
|| dstY
+ height
> dstFb
->_Ymax
) {
765 /* overlapping src/dst doesn't matter, just determine Y direction */
767 /* top-down max-to-min */
768 srcY
= srcY
+ height
- 1;
769 dstY
= dstY
+ height
- 1;
773 /* bottom-up min-to-max */
777 for (row
= 0; row
< height
; row
++) {
778 GLuint temp
[MAX_WIDTH
][4];
779 srcRb
->GetRow(ctx
, srcRb
, width
, srcX
, srcY
, temp
);
780 dstRb
->PutRow(ctx
, dstRb
, width
, dstX
, dstY
, temp
, NULL
);
790 * Do software-based glCopyPixels.
791 * By time we get here, all parameters will have been error-checked.
794 _swrast_CopyPixels( GLcontext
*ctx
,
795 GLint srcx
, GLint srcy
, GLsizei width
, GLsizei height
,
796 GLint destx
, GLint desty
, GLenum type
)
798 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
799 swrast_render_start(ctx
);
801 if (!_mesa_check_conditional_render(ctx
))
802 return; /* don't copy */
804 if (swrast
->NewState
)
805 _swrast_validate_derived( ctx
);
807 if (!fast_copy_pixels(ctx
, srcx
, srcy
, width
, height
, destx
, desty
, type
)) {
810 copy_rgba_pixels( ctx
, srcx
, srcy
, width
, height
, destx
, desty
);
813 copy_depth_pixels( ctx
, srcx
, srcy
, width
, height
, destx
, desty
);
816 copy_stencil_pixels( ctx
, srcx
, srcy
, width
, height
, destx
, desty
);
818 case GL_DEPTH_STENCIL_EXT
:
819 copy_depth_stencil_pixels(ctx
, srcx
, srcy
, width
, height
, destx
, desty
);
822 _mesa_problem(ctx
, "unexpected type in _swrast_CopyPixels");
826 swrast_render_finish(ctx
);