FreeBSD/sys/dev/drm/mach64_state.c
/* This function returns 0 on success, 1 for no intersection, and
 * negative for an error
 */
This function returns 0 on success, 1 for no intersection, and
negative for an error
This function returns 0 on success 1 for no intersection and negative for an error
static int mach64_emit_cliprect(struct drm_file *file_priv,
				drm_mach64_private_t * dev_priv,
				struct drm_clip_rect * box)
{
	u32 sc_left_right, sc_top_bottom;
	struct drm_clip_rect scissor;
	drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
	drm_mach64_context_regs_t *regs = &sarea_priv->context_state;
	DMALOCALS;
	DRM_DEBUG("box=%p\n", box);
	scissor.x1 = regs->sc_left_right & 0xffff;
	scissor.x2 = (regs->sc_left_right & 0xffff0000) >> 16;
	scissor.y1 = regs->sc_top_bottom & 0xffff;
	scissor.y2 = (regs->sc_top_bottom & 0xffff0000) >> 16;
	if (box->x1 > scissor.x1)
		scissor.x1 = box->x1;
	if (box->y1 > scissor.y1)
		scissor.y1 = box->y1;
	if (box->x2 < scissor.x2)
		scissor.x2 = box->x2;
	if (box->y2 < scissor.y2)
		scissor.y2 = box->y2;
	if (scissor.x1 >= scissor.x2)
		return 1;
	if (scissor.y1 >= scissor.y2)
		return 1;
	DMAGETPTR(file_priv, dev_priv, 2);	
	sc_left_right = ((scissor.x1 << 0) | (scissor.x2 << 16));
	sc_top_bottom = ((scissor.y1 << 0) | (scissor.y2 << 16));
	DMAOUTREG(MACH64_SC_LEFT_RIGHT, sc_left_right);
	DMAOUTREG(MACH64_SC_TOP_BOTTOM, sc_top_bottom);
	DMAADVANCE(dev_priv, 1);
	return 0;
}
static int mach64_emit_cliprect ( struct drm_file * file_priv , drm_mach64_private_t * dev_priv , struct drm_clip_rect * box ) { u32 sc_left_right , sc_top_bottom ; struct drm_clip_rect scissor ; drm_mach64_sarea_t * sarea_priv = dev_priv -> sarea_priv ; drm_mach64_context_regs_t * regs = & sarea_priv -> context_state ; DMALOCALS ; DRM_DEBUG ( " \n " , box ) ; scissor . x1 = regs -> sc_left_right & 0xffff ; scissor . x2 = ( regs -> sc_left_right & 0xffff0000 ) >> 16 ; scissor . y1 = regs -> sc_top_bottom & 0xffff ; scissor . y2 = ( regs -> sc_top_bottom & 0xffff0000 ) >> 16 ; if ( box -> x1 > scissor . x1 ) scissor . x1 = box -> x1 ; if ( box -> y1 > scissor . y1 ) scissor . y1 = box -> y1 ; if ( box -> x2 < scissor . x2 ) scissor . x2 = box -> x2 ; if ( box -> y2 < scissor . y2 ) scissor . y2 = box -> y2 ; if ( scissor . x1 >= scissor . x2 ) return 1 ; if ( scissor . y1 >= scissor . y2 ) return 1 ; DMAGETPTR ( file_priv , dev_priv , 2 ) ; sc_left_right = ( ( scissor . x1 << 0 ) | ( scissor . x2 << 16 ) ) ; sc_top_bottom = ( ( scissor . y1 << 0 ) | ( scissor . y2 << 16 ) ) ; DMAOUTREG ( MACH64_SC_LEFT_RIGHT , sc_left_right ) ; DMAOUTREG ( MACH64_SC_TOP_BOTTOM , sc_top_bottom ) ; DMAADVANCE ( dev_priv , 1 ) ; return 0 ; }
This function returns 0 on success, 1 for no intersection, and
 negative for an error
This function returns 0 on success 1 for no intersection and negative for an error
/* Get GL scissor */ /* FIXME: store scissor in SAREA as a cliprect instead of in
	 * hardware format, or do intersection client-side
	 */ /* Intersect GL scissor with cliprect */ /* positive return means skip */ /* returns on failure to get buffer */