/* Operations where the 3D engine is decoupled temporarily from the * current GL state and used for other purposes than simply rendering * incoming triangles. */ static void install_meta_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); memcpy(&i830->meta, &i830->initial, sizeof(i830->meta)); i830->meta.active = ACTIVE; i830->meta.emitted = 0; SET_STATE(i830, meta); set_vertex_format(intel); set_no_texture(intel); }
/** * Copy the window contents named by dPriv to the rotated (or reflected) * color buffer. * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source. */ void i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv, GLuint srcBuf) { i830ContextPtr i830 = I830_CONTEXT( intel ); intelScreenPrivate *screen = intel->intelScreen; const GLuint cpp = screen->cpp; drm_clip_rect_t fullRect; GLuint textureFormat, srcOffset, srcPitch; const drm_clip_rect_t *clipRects; int numClipRects; int i; int xOrig, yOrig; int origNumClipRects; drm_clip_rect_t *origRects; /* * set up hardware state */ intelFlush( &intel->ctx ); SET_STATE( i830, meta ); set_initial_state( i830 ); set_no_texture( i830 ); set_vertex_format( i830 ); set_no_depth_stencil_write( i830 ); set_color_mask( i830, GL_FALSE ); LOCK_HARDWARE(intel); /* save current drawing origin and cliprects (restored at end) */ xOrig = intel->drawX; yOrig = intel->drawY; origNumClipRects = intel->numClipRects; origRects = intel->pClipRects; if (!intel->numClipRects) goto done; /* * set drawing origin, cliprects for full-screen access to rotated screen */ fullRect.x1 = 0; fullRect.y1 = 0; fullRect.x2 = screen->rotatedWidth; fullRect.y2 = screen->rotatedHeight; intel->drawX = 0; intel->drawY = 0; intel->numClipRects = 1; intel->pClipRects = &fullRect; set_draw_region( i830, &screen->rotated ); if (cpp == 4) textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888; else textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565; if (srcBuf == BUFFER_BIT_FRONT_LEFT) { srcPitch = screen->front.pitch; /* in bytes */ srcOffset = screen->front.offset; /* bytes */ clipRects = dPriv->pClipRects; numClipRects = dPriv->numClipRects; } else { srcPitch = screen->back.pitch; /* in bytes */ srcOffset = screen->back.offset; /* bytes */ clipRects = dPriv->pBackClipRects; numClipRects = dPriv->numBackClipRects; } /* set the whole screen up as a texture to avoid alignment issues */ set_tex_rect_source(i830, srcOffset, screen->width, screen->height, srcPitch, textureFormat); enable_texture_blend_replace(i830); /* * loop over the source window's cliprects */ for (i = 0; i < numClipRects; i++) { int srcX0 = clipRects[i].x1; int srcY0 = clipRects[i].y1; int srcX1 = clipRects[i].x2; int srcY1 = clipRects[i].y2; GLfloat verts[4][2], tex[4][2]; int j; /* build vertices for four corners of clip rect */ verts[0][0] = srcX0; verts[0][1] = srcY0; verts[1][0] = srcX1; verts[1][1] = srcY0; verts[2][0] = srcX1; verts[2][1] = srcY1; verts[3][0] = srcX0; verts[3][1] = srcY1; /* .. and texcoords */ tex[0][0] = srcX0; tex[0][1] = srcY0; tex[1][0] = srcX1; tex[1][1] = srcY0; tex[2][0] = srcX1; tex[2][1] = srcY1; tex[3][0] = srcX0; tex[3][1] = srcY1; /* transform coords to rotated screen coords */ for (j = 0; j < 4; j++) { matrix23TransformCoordf(&screen->rotMatrix, &verts[j][0], &verts[j][1]); } /* draw polygon to map source image to dest region */ draw_poly(i830, 255, 255, 255, 255, 4, verts, tex); } /* cliprect loop */ assert(!intel->prim.flush); intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE ); done: /* restore original drawing origin and cliprects */ intel->drawX = xOrig; intel->drawY = yOrig; intel->numClipRects = origNumClipRects; intel->pClipRects = origRects; UNLOCK_HARDWARE(intel); SET_STATE( i830, state ); }
void i830ClearWithTris(intelContextPtr intel, GLbitfield mask, GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) { i830ContextPtr i830 = I830_CONTEXT( intel ); __DRIdrawablePrivate *dPriv = intel->driDrawable; intelScreenPrivate *screen = intel->intelScreen; int x0, y0, x1, y1; INTEL_FIREVERTICES(intel); SET_STATE( i830, meta ); set_initial_state( i830 ); /* set_no_texture( i830 ); */ set_vertex_format( i830 ); LOCK_HARDWARE(intel); if(!all) { x0 = cx; y0 = cy; x1 = x0 + cw; y1 = y0 + ch; } else { x0 = 0; y0 = 0; x1 = x0 + dPriv->w; y1 = y0 + dPriv->h; } /* Don't do any clipping to screen - these are window coordinates. * The active cliprects will be applied as for any other geometry. */ if(mask & BUFFER_BIT_FRONT_LEFT) { set_no_depth_stencil_write( i830 ); set_color_mask( i830, GL_TRUE ); set_draw_region( i830, &screen->front ); draw_quad(i830, x0, x1, y0, y1, intel->clear_red, intel->clear_green, intel->clear_blue, intel->clear_alpha, 0, 0, 0, 0); } if(mask & BUFFER_BIT_BACK_LEFT) { set_no_depth_stencil_write( i830 ); set_color_mask( i830, GL_TRUE ); set_draw_region( i830, &screen->back ); draw_quad(i830, x0, x1, y0, y1, intel->clear_red, intel->clear_green, intel->clear_blue, intel->clear_alpha, 0, 0, 0, 0); } if(mask & BUFFER_BIT_STENCIL) { set_stencil_replace( i830, intel->ctx.Stencil.WriteMask[0], intel->ctx.Stencil.Clear); set_color_mask( i830, GL_FALSE ); set_draw_region( i830, &screen->front ); draw_quad( i830, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 ); } UNLOCK_HARDWARE(intel); INTEL_FIREVERTICES(intel); SET_STATE( i830, state ); }
void i915ClearWithTris(intelContextPtr intel, GLbitfield buffers, GLboolean allFoo, GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo) { i915ContextPtr i915 = I915_CONTEXT( intel ); __DRIdrawablePrivate *dPriv = intel->driDrawable; intelScreenPrivate *screen = intel->intelScreen; int x0, y0, x1, y1; GLint cx, cy, cw, ch; GLboolean all; SET_STATE( i915, meta ); set_initial_state( i915 ); set_no_texture( i915 ); set_vertex_format( i915 ); LOCK_HARDWARE(intel); /* get clear bounds after locking */ cx = intel->ctx.DrawBuffer->_Xmin; cy = intel->ctx.DrawBuffer->_Ymin; cw = intel->ctx.DrawBuffer->_Xmax - cx; ch = intel->ctx.DrawBuffer->_Ymax - cy; all = (cw == intel->ctx.DrawBuffer->Width && ch == intel->ctx.DrawBuffer->Height); if (!all) { x0 = cx; y0 = cy; x1 = x0 + cw; y1 = y0 + ch; } else { x0 = 0; y0 = 0; x1 = x0 + dPriv->w; y1 = y0 + dPriv->h; } /* Don't do any clipping to screen - these are window coordinates. * The active cliprects will be applied as for any other geometry. */ if (buffers & BUFFER_BIT_FRONT_LEFT) { set_no_depth_stencil_write( i915 ); set_color_mask( i915, GL_TRUE ); set_draw_region( i915, &screen->front ); draw_quad(i915, x0, x1, y0, y1, intel->clear_red, intel->clear_green, intel->clear_blue, intel->clear_alpha, 0, 0, 0, 0); } if (buffers & BUFFER_BIT_BACK_LEFT) { set_no_depth_stencil_write( i915 ); set_color_mask( i915, GL_TRUE ); set_draw_region( i915, &screen->back ); draw_quad(i915, x0, x1, y0, y1, intel->clear_red, intel->clear_green, intel->clear_blue, intel->clear_alpha, 0, 0, 0, 0); } if (buffers & BUFFER_BIT_STENCIL) { set_stencil_replace( i915, intel->ctx.Stencil.WriteMask[0], intel->ctx.Stencil.Clear); set_color_mask( i915, GL_FALSE ); set_draw_region( i915, &screen->front ); /* could be either? */ draw_quad( i915, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 ); } UNLOCK_HARDWARE(intel); SET_STATE( i915, state ); }