/**
 * This function copies into 'aut_dest' the sub-automaton of 'aut_src' that
 * starts at the state #start and that ends at:
 *
 * - the state #z pointed by transitions, if left_constraint_part=1;
 * - the state pointed by transitions tagged with the 'z' symbol otherwise.
 *
 * Note that these transitions are not copied. The function returns the number of
 * the ending state.
 *
 * 'aut_dest' is supposed to have been allocated and to be empty.
 */
int get_sub_automaton(SingleGraph src,SingleGraph dest,int start,
                      int left_constraint_part,int z) {
/* We create the initial state of the sub-automaton */
SingleGraphState state=add_state(dest);
set_initial_state(state);
/* We use this array to renumber states */
int* renumber=(int*)malloc(src->number_of_states*sizeof(int));
if (renumber==NULL) {
   fatal_alloc_error("in get_sub_automaton");
}
for (int e=0;e<src->number_of_states;e++) {
   renumber[e]=ELAG_UNDEFINED;
}
int end=ELAG_UNDEFINED;
renumber[start]=0;
if (left_constraint_part) {
   end=get_left_constraint_part(src,dest,start,z,renumber);
} else {
   end=get_sub_automaton(src,dest,start,(SymbolType)z,renumber);
}
free(renumber);
if (left_constraint_part) {
   if (!end) {
      /* This should never happen */
      fatal_error("Internal error in get_sub_automaton\n");
   }
} else if (end==ELAG_UNDEFINED) {
   /* If we have not found the delimitor */
   fatal_error("In grammar: middle or end delimitor missing\n");
}
return end;
}
예제 #2
0
/**
 * We create a copy of the given graph using the following rules if full_simplification is not null:
 * - <E> transitions and graph calls are kept
 * - all right contexts are ignored, replaced by an epsilon transition
 * - all tags that don't match anything in the text (like $* $< and $>) are kept,
 *   because they can be involved into a E loop. We also add a real E transition.
 * - all other transitions that matches something from the text are removed
 *
 * As a consequence, the resulting graph is only made of real E transitions,
 * pseudo-E transitions, and graph calls and we can use it as follows:
 * - if no final state is accessible, it means that the graph cannot match E
 * - if the initial state is final, it means that the graph match E
 * - otherwise, we don't know yet
 *
 *
 * If full_simplification is null, we have to create a condition graph suitable for
 * E loop and left recursion detection. For that purpose, we keep the graph as is,
 * with only one modification: adding an E transition to skip right contexts. But still,
 * we keep the context, because we also have to look at it for E loops and left recursions.
 *
 */
static SingleGraph create_condition_graph(Fst2* fst2,int graph,int full_simplification) {
SingleGraph g=new_SingleGraph(INT_TAGS);
int initial_state=fst2->initial_states[graph];
int n_states=fst2->number_of_states_per_graphs[graph];
for (int i=initial_state;i<initial_state+n_states;i++) {
	SingleGraphState dst=add_state(g);
	Fst2State src=fst2->states[i];
	if (is_initial_state(src)) {
		set_initial_state(dst);
	}
	if (is_final_state(src)) {
		set_final_state(dst);
	}
	Transition* t=src->transitions;
	while (t!=NULL) {
		if (full_simplification) {
			deal_with_transition_v1(fst2,t,dst,initial_state);
		} else {
			deal_with_transition_v2(fst2,t,dst,initial_state);
		}
		t=t->next;
	}
}
clean_condition_graph(g);
return g;
}
예제 #3
0
/**
 * Creates a SingleGraph copy of the given .fst2 subgraph, using
 * the same tag numeration.
 */
SingleGraph create_copy_of_fst2_subgraph(Fst2* fst2,int n) {
int n_states=fst2->number_of_states_per_graphs[n];
SingleGraph g=new_SingleGraph(n_states,INT_TAGS);
int shift=fst2->initial_states[n];
for (int i=0;i<n_states;i++) {
   SingleGraphState dest=add_state(g);
   Fst2State src=fst2->states[i+shift];
   if (is_initial_state(src)) {
      set_initial_state(dest);
   }
   if (is_final_state(src)) {
      set_final_state(dest);
   }
   Transition* t=src->transitions;
   while (t!=NULL) {
      add_outgoing_transition(dest,t->tag_number,t->state_number);
      t=t->next;
   }
}
return g;
}
예제 #4
0
/**
 * 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 );
}
예제 #5
0
GLboolean
i830TryTextureDrawPixels( GLcontext *ctx,
			  GLint x, GLint y, GLsizei width, GLsizei height,
			  GLenum format, GLenum type,
			  const struct gl_pixelstore_attrib *unpack,
			  const GLvoid *pixels )
{
   intelContextPtr intel = INTEL_CONTEXT(ctx);
   i830ContextPtr i830 = I830_CONTEXT(ctx);
   GLint pitch = unpack->RowLength ? unpack->RowLength : width;
   __DRIdrawablePrivate *dPriv = intel->driDrawable;
   int textureFormat;
   GLenum glTextureFormat;
   int dst_offset = i830->meta.Buffer[I830_DESTREG_CBUFADDR2];
   int src_offset = intelAgpOffsetFromVirtual( intel, pixels );

   if (INTEL_DEBUG & DEBUG_PIXEL)
      fprintf(stderr, "%s\n", __FUNCTION__);

   /* Todo -- upload images that aren't in agp space, then texture
    * from them.  
    */

   if ( !intelIsAgpMemory( intel, pixels, pitch*height ) ) {
      fprintf(stderr, "%s: intelIsAgpMemory failed\n", __FUNCTION__);
      return GL_FALSE;
   }

   /* Todo -- don't want to clobber all the drawing state like we do
    * for readpixels -- most of this state can be handled just fine.
    */
   if (	ctx->_ImageTransferState ||
	unpack->SwapBytes ||
	unpack->LsbFirst ||
	ctx->Color.AlphaEnabled || 
	ctx->Depth.Test ||
	ctx->Fog.Enabled ||
	ctx->Scissor.Enabled ||
	ctx->Stencil.Enabled ||
	!ctx->Color.ColorMask[0] ||
	!ctx->Color.ColorMask[1] ||
	!ctx->Color.ColorMask[2] ||
	!ctx->Color.ColorMask[3] ||
	ctx->Color.ColorLogicOpEnabled ||
	ctx->Texture._EnabledUnits ||
	ctx->Depth.OcclusionTest) {
      fprintf(stderr, "%s: other tests failed\n", __FUNCTION__);
      return GL_FALSE;
   }

   /* Todo -- remove these restrictions:
    */
   if (ctx->Pixel.ZoomX != 1.0F ||
       ctx->Pixel.ZoomY != -1.0F)
      return GL_FALSE;



   switch (type) {
   case GL_UNSIGNED_SHORT_1_5_5_5_REV:
      if (format != GL_BGRA) return GL_FALSE;
      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
      glTextureFormat = GL_RGBA;
      break;
   case GL_UNSIGNED_SHORT_5_6_5: 
      if (format != GL_RGB) return GL_FALSE;
      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
      glTextureFormat = GL_RGB;
      break;
   case GL_UNSIGNED_SHORT_8_8_MESA: 
      if (format != GL_YCBCR_MESA) return GL_FALSE;
      textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY 
/*  		       | TM0S1_COLORSPACE_CONVERSION */
	 );
      glTextureFormat = GL_YCBCR_MESA;
      break;
   case GL_UNSIGNED_SHORT_8_8_REV_MESA: 
      if (format != GL_YCBCR_MESA) return GL_FALSE;
      textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL 
/* 		       | TM0S1_COLORSPACE_CONVERSION */
	 );
      glTextureFormat = GL_YCBCR_MESA;
      break;
   case GL_UNSIGNED_INT_8_8_8_8_REV: 
      if (format != GL_BGRA) return GL_FALSE;
      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
      glTextureFormat = GL_RGBA;
      break;
   default:
      fprintf(stderr, "%s: destFormat failed\n", __FUNCTION__);
      return GL_FALSE;
   }

   intelFlush( ctx );

   SET_STATE( i830, meta );

   LOCK_HARDWARE( intel );
   {
      intelWaitForIdle( intel ); /* required by GL */

      y -= height;			/* cope with pixel zoom */

      if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
	 UNLOCK_HARDWARE( intel );
	 SET_STATE(i830, state);
	 fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
	 return GL_TRUE;
      }


      y = dPriv->h - y - height;

      set_initial_state( i830 );

      /* Set the pixel image up as a rectangular texture.
       */
      set_tex_rect_source( i830, 
			   src_offset, 
			   width, 
			   height, 
			   pitch, /* XXXX!!!! -- /2 sometimes */
			   textureFormat ); 
   
   
      enable_texture_blend_replace( i830 ); 

   
      /* Draw to the current draw buffer:
       */
      set_draw_offset( i830, dst_offset );

      /* Draw a quad, use regular cliprects
       */
/*       fprintf(stderr, "x: %d y: %d width %d height %d\n", x, y, width, height); */

      draw_quad( i830, 
		 x, x+width, y, y+height,
		 0, 255, 0, 0, 
		 0, width, 0, height );

      intelWindowMoved( intel );
   }
   UNLOCK_HARDWARE( intel );
   intelFinish( ctx ); /* required by GL */
   
   SET_STATE(i830, state);

   return GL_TRUE;
}
예제 #6
0
GLboolean
i830TryTextureReadPixels( GLcontext *ctx,
			  GLint x, GLint y, GLsizei width, GLsizei height,
			  GLenum format, GLenum type,
			  const struct gl_pixelstore_attrib *pack,
			  GLvoid *pixels )
{
   i830ContextPtr i830 = I830_CONTEXT(ctx);
   intelContextPtr intel = INTEL_CONTEXT(ctx);
   intelScreenPrivate *screen = i830->intel.intelScreen;
   GLint pitch = pack->RowLength ? pack->RowLength : width;
   __DRIdrawablePrivate *dPriv = i830->intel.driDrawable;
   int textureFormat;
   GLenum glTextureFormat;
   int src_offset = i830->meta.Buffer[I830_DESTREG_CBUFADDR2];
   int destOffset = intelAgpOffsetFromVirtual( &i830->intel, pixels);
   int destFormat, depthFormat, destPitch;
   drm_clip_rect_t tmp;

   if (INTEL_DEBUG & DEBUG_PIXEL)
      fprintf(stderr, "%s\n", __FUNCTION__);


   if (	ctx->_ImageTransferState ||
	pack->SwapBytes ||
	pack->LsbFirst ||
	!pack->Invert) {
      fprintf(stderr, "%s: check_color failed\n", __FUNCTION__);
      return GL_FALSE;
   }

   switch (screen->fbFormat) {
   case DV_PF_565:
      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
      glTextureFormat = GL_RGB;
      break;
   case DV_PF_555:
      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
      glTextureFormat = GL_RGBA;
      break;
   case DV_PF_8888:
      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
      glTextureFormat = GL_RGBA;
      break;
   default:
      fprintf(stderr, "%s: textureFormat failed %x\n", __FUNCTION__,
	      screen->fbFormat);
      return GL_FALSE;
   }


   switch (type) {
   case GL_UNSIGNED_SHORT_5_6_5: 
      if (format != GL_RGB) return GL_FALSE;
      destFormat = COLR_BUF_RGB565; 
      depthFormat = DEPTH_FRMT_16_FIXED;
      destPitch = pitch * 2;
      break;
   case GL_UNSIGNED_INT_8_8_8_8_REV: 
      if (format != GL_BGRA) return GL_FALSE;
      destFormat = COLR_BUF_ARGB8888; 
      depthFormat = DEPTH_FRMT_24_FIXED_8_OTHER;
      destPitch = pitch * 4;
      break;
   default:
      fprintf(stderr, "%s: destFormat failed %s\n", __FUNCTION__,
	      _mesa_lookup_enum_by_nr(type));
      return GL_FALSE;
   }

   destFormat |= (0x02<<24);

/*    fprintf(stderr, "type: %s destFormat: %x\n", */
/* 	   _mesa_lookup_enum_by_nr(type), */
/* 	   destFormat); */

   intelFlush( ctx );

   SET_STATE( i830, meta );
   set_initial_state( i830 );
   set_no_depth_stencil_write( i830 );

   LOCK_HARDWARE( intel );
   {
      intelWaitForIdle( intel ); /* required by GL */

      if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
	 UNLOCK_HARDWARE( intel );
	 SET_STATE(i830, state);
	 fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
	 return GL_TRUE;
      }

#if 0
      /* FIXME -- Just emit the correct state
       */
      if (i830SetParam(i830->driFd, I830_SETPARAM_CBUFFER_PITCH, 
		      destPitch) != 0) {
	 UNLOCK_HARDWARE( intel );
	 SET_STATE(i830, state);
	 fprintf(stderr, "%s: setparam failed\n", __FUNCTION__);
	 return GL_FALSE;
      }
#endif


      y = dPriv->h - y - height;
      x += dPriv->x;
      y += dPriv->y;


      /* Set the frontbuffer up as a large rectangular texture.
       */
      set_tex_rect_source( i830, 
			   src_offset, 
			   screen->width, 
			   screen->height, 
			   screen->front.pitch, 
			   textureFormat ); 
   
   
      enable_texture_blend_replace( i830 ); 


      /* Set the 3d engine to draw into the agp memory
       */

      set_draw_region( i830, destOffset ); 
      set_draw_format( i830, destFormat, depthFormat );  


      /* Draw a single quad, no cliprects:
       */
      i830->intel.numClipRects = 1;
      i830->intel.pClipRects = &tmp;
      i830->intel.pClipRects[0].x1 = 0;
      i830->intel.pClipRects[0].y1 = 0;
      i830->intel.pClipRects[0].x2 = width;
      i830->intel.pClipRects[0].y2 = height;

      draw_quad( i830, 
		 0, width, 0, height, 
		 0, 255, 0, 0, 
		 x, x+width, y, y+height );

      intelWindowMoved( intel );
   }
   UNLOCK_HARDWARE( intel );
   intelFinish( ctx ); /* required by GL */

   SET_STATE( i830, state );
   return GL_TRUE;
}
예제 #7
0
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 );
}
예제 #8
0
/**
 * Loads and returns an automaton from the given .fst2.
 * Returns NULL if there is no more automaton to load.
 */
Fst2Automaton* load_automaton(Elag_fst_file_in* fstf) {
if (fstf->pos>=fstf->nb_automata) {
   return NULL;
}
Ustring* ustr=new_Ustring();
readline(ustr,fstf->f);
const unichar* p=ustr->str;
if (p[0]!='-') {
   fatal_error("load_automaton: %s: bad file format\n",fstf->name);
}
p++;
int i=u_parse_int(p,&p);
if (i!=fstf->pos+1) {
   /* We make sure that the automaton number is what it should be */
   fatal_error("load_automaton: %s: parsing error with line '%S' ('-%d ...' expected)\n",fstf->name,ustr->str,fstf->pos+1);
}
/* Now p points on the automaton name */
p++;
Fst2Automaton* A=new_Fst2Automaton(p);
while (readline(ustr,fstf->f) && ustr->str[0]!='f') {
   /* If there is a state to read */
   p=ustr->str;
   SingleGraphState state=add_state(A->automaton);
   if (*p=='t') {
      /* If necessary, we set the state final */
      set_final_state(state);
   }
   /* We puts p on the first digit */
   while (*p!='\0' && !u_is_digit(*p)) {
      p++;
   }
   while (*p!='\0') {
      /* If there is a transition to read */
      int tag_number=u_parse_int(p,&p);
      if (fstf->renumber!=NULL) {
         tag_number=fstf->renumber[tag_number];
      }
      while (*p==' ') {
         p++;
      }
      if (!u_is_digit(*p)) {
         fatal_error("load_automaton: %s: bad file format (line='%S')\n",fstf->name,ustr->str);
      }
      int state_number=u_parse_int(p,&p);
      symbol_t* tmp=(symbol_t*)fstf->symbols->value[tag_number];
      if (tmp!=NULL) {
         /* If it is a good symbol (successfully loaded), we add transition(s) */
         if (fstf->type!=FST_TEXT) {
            add_all_outgoing_transitions(state,tmp,state_number);
         } else {
            /* In a text automaton, we add one transition per element of
             * the symbol list. For instance, if we have:
             *
             * tmp = "{domestique,.N:fs}" => "{domestique,.N:ms}" => NULL
             *
             * then we add two transitions. */
            add_all_outgoing_transitions(state,tmp,state_number);
         }
      }
      while (*p==' ') {
         p++;
      }
   }
}
if (*ustr->str=='\0') {
   fatal_error("load_automaton: unexpected end of file\n");
}
if (A->automaton->number_of_states==0) {
   error("load_automaton: automaton with no state\n");
} else {
   set_initial_state(A->automaton->states[0]);
}
fstf->pos++;
free_Ustring(ustr);
return A;
}
예제 #9
0
void DynamicalSystem::integrateStart(const VectorXd& x_init, Ref<VectorXd> x, Ref<VectorXd> xd)
{
  set_initial_state(x_init);
  integrateStart(x,xd);
}
예제 #10
0
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 );
}