⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i915_metaops.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 2 页
字号:
{   i915->meta.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */					DSTORG_VERT_BIAS(0x8) | /* .5 */					format |					LOD_PRECLAMP_OGL |					TEX_DEFAULT_COLOR_OGL |					depth_format);   i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;/*    fprintf(stderr, "%s: DV1: %x\n",  *//* 	   __FUNCTION__, i915->meta.Buffer[I915_DESTREG_DV1]); */}#endifstatic void set_vertex_format( i915ContextPtr i915 ){   i915->meta.Ctx[I915_CTXREG_LIS2] =       (S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) |       S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) |        S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) |       S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) |       S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) |       S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) |        S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) |       S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT));   i915->meta.Ctx[I915_CTXREG_LIS4] &= ~S4_VFMT_MASK;   i915->meta.Ctx[I915_CTXREG_LIS4] |=       (S4_VFMT_COLOR |       S4_VFMT_SPEC_FOG |       S4_VFMT_XYZW);   i915->meta.emitted &= ~I915_UPLOAD_CTX;}static void draw_quad(i915ContextPtr i915, 		      GLfloat x0, GLfloat x1,		      GLfloat y0, GLfloat y1, 		      GLubyte red, GLubyte green,		      GLubyte blue, GLubyte alpha,		      GLfloat s0, GLfloat s1,		      GLfloat t0, GLfloat t1 ){   GLuint vertex_size = 8;   GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel, 						PRIM3D_TRIFAN, 						4 * vertex_size,						vertex_size );   intelVertex tmp;   int i;   if (0)      fprintf(stderr, "%s: %f,%f-%f,%f 0x%x%x%x%x %f,%f-%f,%f\n",	      __FUNCTION__,	      x0,y0,x1,y1,red,green,blue,alpha,s0,t0,s1,t1);   /* initial vertex, left bottom */   tmp.v.x = x0;   tmp.v.y = y0;   tmp.v.z = 1.0;   tmp.v.w = 1.0;    tmp.v.color.red = red;   tmp.v.color.green = green;   tmp.v.color.blue = blue;   tmp.v.color.alpha = alpha;   tmp.v.specular.red = 0;   tmp.v.specular.green = 0;   tmp.v.specular.blue = 0;   tmp.v.specular.alpha = 0;   tmp.v.u0 = s0;   tmp.v.v0 = t0;   for (i = 0 ; i < vertex_size ; i++)      vb[i] = tmp.ui[i];   /* right bottom */   vb += vertex_size;   tmp.v.x = x1;   tmp.v.u0 = s1;   for (i = 0 ; i < vertex_size ; i++)      vb[i] = tmp.ui[i];   /* right top */   vb += vertex_size;   tmp.v.y = y1;   tmp.v.v0 = t1;   for (i = 0 ; i < vertex_size ; i++)      vb[i] = tmp.ui[i];   /* left top */   vb += vertex_size;   tmp.v.x = x0;   tmp.v.u0 = s0;   for (i = 0 ; i < vertex_size ; i++)      vb[i] = tmp.ui[i];}static void draw_poly(i915ContextPtr i915, 		      GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha,                      GLuint numVerts,                      /*const*/ GLfloat verts[][2],                      /*const*/ GLfloat texcoords[][2]){   GLuint vertex_size = 8;   GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel, 						PRIM3D_TRIFAN, 						numVerts * vertex_size,						vertex_size );   intelVertex tmp;   int i, k;   /* initial constant vertex fields */   tmp.v.z = 1.0;   tmp.v.w = 1.0;    tmp.v.color.red = red;   tmp.v.color.green = green;   tmp.v.color.blue = blue;   tmp.v.color.alpha = alpha;   tmp.v.specular.red = 0;   tmp.v.specular.green = 0;   tmp.v.specular.blue = 0;   tmp.v.specular.alpha = 0;   for (k = 0; k < numVerts; k++) {      tmp.v.x = verts[k][0];      tmp.v.y = verts[k][1];      tmp.v.u0 = texcoords[k][0];      tmp.v.v0 = texcoords[k][1];      for (i = 0 ; i < vertex_size ; i++)         vb[i] = tmp.ui[i];      vb += vertex_size;   }}void i915ClearWithTris(intelContextPtr intel, GLbitfield mask,		  GLboolean all,		  GLint cx, GLint cy, GLint cw, GLint ch){   i915ContextPtr i915 = I915_CONTEXT( intel );   __DRIdrawablePrivate *dPriv = intel->driDrawable;   intelScreenPrivate *screen = intel->intelScreen;   int x0, y0, x1, y1;   SET_STATE( i915, meta );    set_initial_state( i915 );    set_no_texture( i915 );    set_vertex_format( i915 );    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( 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 (mask & 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 (mask & 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 );}/** * 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. */voidi915RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,                 GLuint srcBuf){   i915ContextPtr i915 = I915_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( i915, meta );    set_initial_state( i915 );    set_no_texture( i915 );    set_vertex_format( i915 );    set_no_depth_stencil_write( i915 );   set_color_mask( i915, GL_TRUE );   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( i915, &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(i915,                       srcOffset,                       screen->width,		       screen->height,                       srcPitch,                       textureFormat);   enable_texture_blend_replace(i915);   /*    * 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(i915, 255, 255, 255, 255, 4, verts, tex);   } /* cliprect loop */   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( i915, state );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -