radeon/r200/r300: attempt to move lock to common code
[mesa.git] / src / mesa / drivers / dri / r300 / radeon_state.c
index 14d489bf1aa0b81381ccabde5f9f120fca0efe2a..0ee5313043e757978d584f7c98c0cb913a72966e 100644 (file)
@@ -56,83 +56,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Scissoring
  */
 
-static GLboolean intersect_rect(drm_clip_rect_t * out,
-                               drm_clip_rect_t * a, drm_clip_rect_t * b)
-{
-       *out = *a;
-       if (b->x1 > out->x1)
-               out->x1 = b->x1;
-       if (b->y1 > out->y1)
-               out->y1 = b->y1;
-       if (b->x2 < out->x2)
-               out->x2 = b->x2;
-       if (b->y2 < out->y2)
-               out->y2 = b->y2;
-       if (out->x1 >= out->x2)
-               return GL_FALSE;
-       if (out->y1 >= out->y2)
-               return GL_FALSE;
-       return GL_TRUE;
-}
-
-void radeonRecalcScissorRects(radeonContextPtr radeon)
-{
-       drm_clip_rect_t *out;
-       int i;
-
-       /* Grow cliprect store?
-        */
-       if (radeon->state.scissor.numAllocedClipRects < radeon->numClipRects) {
-               while (radeon->state.scissor.numAllocedClipRects <
-                      radeon->numClipRects) {
-                       radeon->state.scissor.numAllocedClipRects += 1; /* zero case */
-                       radeon->state.scissor.numAllocedClipRects *= 2;
-               }
-
-               if (radeon->state.scissor.pClipRects)
-                       FREE(radeon->state.scissor.pClipRects);
-
-               radeon->state.scissor.pClipRects =
-                   MALLOC(radeon->state.scissor.numAllocedClipRects *
-                          sizeof(drm_clip_rect_t));
-
-               if (radeon->state.scissor.pClipRects == NULL) {
-                       radeon->state.scissor.numAllocedClipRects = 0;
-                       return;
-               }
-       }
-
-       out = radeon->state.scissor.pClipRects;
-       radeon->state.scissor.numClipRects = 0;
-
-       for (i = 0; i < radeon->numClipRects; i++) {
-               if (intersect_rect(out,
-                                  &radeon->pClipRects[i],
-                                  &radeon->state.scissor.rect)) {
-                       radeon->state.scissor.numClipRects++;
-                       out++;
-               }
-       }
-}
-
-void radeonUpdateScissor(GLcontext* ctx)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
-       if (radeon->dri.drawable) {
-               __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
-               int x1 = dPriv->x + ctx->Scissor.X;
-               int y1 = dPriv->y + dPriv->h - (ctx->Scissor.Y + ctx->Scissor.Height);
-
-               radeon->state.scissor.rect.x1 = x1;
-               radeon->state.scissor.rect.y1 = y1;
-               radeon->state.scissor.rect.x2 = x1 + ctx->Scissor.Width;
-               radeon->state.scissor.rect.y2 = y1 + ctx->Scissor.Height;
-
-               radeonRecalcScissorRects(radeon);
-       }
-}
-
 static void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
        if (ctx->Scissor.Enabled) {
@@ -142,58 +65,6 @@ static void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h
        }
 }
 
-
-/**
- * Update cliprects and scissors.
- */
-void radeonSetCliprects(radeonContextPtr radeon)
-{
-       __DRIdrawablePrivate *const drawable = radeon->dri.drawable;
-       __DRIdrawablePrivate *const readable = radeon->dri.readable;
-       GLframebuffer *const draw_fb = (GLframebuffer*)drawable->driverPrivate;
-       GLframebuffer *const read_fb = (GLframebuffer*)readable->driverPrivate;
-
-    if (!radeon->radeonScreen->driScreen->dri2.enabled) {
-       if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
-               /* Can't ignore 2d windows if we are page flipping. */
-               if (drawable->numBackClipRects == 0 || radeon->doPageFlip ||
-                   radeon->sarea->pfCurrentPage == 1) {
-                       radeon->numClipRects = drawable->numClipRects;
-                       radeon->pClipRects = drawable->pClipRects;
-               } else {
-                       radeon->numClipRects = drawable->numBackClipRects;
-                       radeon->pClipRects = drawable->pBackClipRects;
-               }
-       } else {
-               /* front buffer (or none, or multiple buffers */
-               radeon->numClipRects = drawable->numClipRects;
-               radeon->pClipRects = drawable->pClipRects;
-       }
-    }
-
-       if ((draw_fb->Width != drawable->w) ||
-           (draw_fb->Height != drawable->h)) {
-               _mesa_resize_framebuffer(radeon->glCtx, draw_fb,
-                                        drawable->w, drawable->h);
-               draw_fb->Initialized = GL_TRUE;
-       }
-
-       if (drawable != readable) {
-               if ((read_fb->Width != readable->w) ||
-                   (read_fb->Height != readable->h)) {
-                       _mesa_resize_framebuffer(radeon->glCtx, read_fb,
-                                                readable->w, readable->h);
-                       read_fb->Initialized = GL_TRUE;
-               }
-       }
-
-       if (radeon->state.scissor.enabled)
-               radeonRecalcScissorRects(radeon);
-
-       radeon->lastStamp = drawable->lastStamp;
-}
-
-
 /**
  * Handle common enable bits.
  * Called as a fallback by r200Enable/r300Enable.