void XAAOverWindowExposures(WindowPtr pWin, RegionPtr pReg, RegionPtr pOtherReg) { ScreenPtr pScreen = pWin->drawable.pScreen; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); if ((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) { if (RegionNumRects(pReg) && infoRec->FillSolidRects) { XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen); SWITCH_DEPTH(8); (*infoRec->FillSolidRects) (infoRec->pScrn, infoRec->pScrn->colorKey, GXcopy, ~0, RegionNumRects(pReg), RegionRects(pReg)); miWindowExposures(pWin, pReg, pOtherReg); return; } else if (infoRec->NeedToSync) { (*infoRec->Sync) (infoRec->pScrn); infoRec->NeedToSync = FALSE; } } XAA_SCREEN_PROLOGUE(pScreen, WindowExposures); (*pScreen->WindowExposures) (pWin, pReg, pOtherReg); XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures); }
void fbPushImage(DrawablePtr pDrawable, GCPtr pGC, FbStip * src, FbStride srcStride, int srcX, int x, int y, int width, int height) { RegionPtr pClip = fbGetCompositeClip(pGC); int nbox; BoxPtr pbox; int x1, y1, x2, y2; for (nbox = RegionNumRects(pClip), pbox = RegionRects(pClip); nbox--; pbox++) { x1 = x; y1 = y; x2 = x + width; y2 = y + height; if (x1 < pbox->x1) x1 = pbox->x1; if (y1 < pbox->y1) y1 = pbox->y1; if (x2 > pbox->x2) x2 = pbox->x2; if (y2 > pbox->y2) y2 = pbox->y2; if (x1 >= x2 || y1 >= y2) continue; fbPushFill(pDrawable, pGC, src + (y1 - y) * srcStride, srcStride, srcX + (x1 - x), x1, y1, x2 - x1, y2 - y1); } }
static void ephyrInternalDamageRedisplay(ScreenPtr pScreen) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = screen->driver; RegionPtr pRegion; if (!scrpriv || !scrpriv->pDamage) return; pRegion = DamageRegion(scrpriv->pDamage); if (RegionNotEmpty(pRegion)) { int nbox; BoxPtr pbox; if (ephyr_glamor) { ephyr_glamor_damage_redisplay(scrpriv->glamor, pRegion); } else { nbox = RegionNumRects(pRegion); pbox = RegionRects(pRegion); while (nbox--) { hostx_paint_rect(screen, pbox->x1, pbox->y1, pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); pbox++; } } DamageEmpty(scrpriv->pDamage); } }
void fbPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg) { void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg); if (pGC->lineWidth == 0) { seg = fbZeroSegment; if (pGC->fillStyle == FillSolid && pGC->lineStyle == LineSolid && RegionNumRects(fbGetCompositeClip(pGC)) == 1) { switch (pDrawable->bitsPerPixel) { case 8: seg = fbPolySegment8; break; case 16: seg = fbPolySegment16; break; case 32: seg = fbPolySegment32; break; } } } else { seg = miPolySegment; } (*seg) (pDrawable, pGC, nseg, pseg); }
static void glamor_dash_loop(DrawablePtr drawable, GCPtr gc, glamor_program *prog, int n, GLenum mode) { PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); int box_index; int off_x, off_y; glEnable(GL_SCISSOR_TEST); glamor_pixmap_loop(pixmap_priv, box_index) { int nbox = RegionNumRects(gc->pCompositeClip); BoxPtr box = RegionRects(gc->pCompositeClip); glamor_set_destination_drawable(drawable, box_index, TRUE, TRUE, prog->matrix_uniform, &off_x, &off_y); while (nbox--) { glScissor(box->x1 + off_x, box->y1 + off_y, box->x2 - box->x1, box->y2 - box->y1); box++; glDrawArrays(mode, 0, n); } }
static void ShadowCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgn) { ScreenPtr pScreen = pWin->drawable.pScreen; ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen); int num = 0; RegionRec rgnDst; if (pPriv->vtSema) { RegionNull(&rgnDst); RegionCopy(&rgnDst, prgn); RegionTranslate(&rgnDst, pWin->drawable.x - ptOldOrg.x, pWin->drawable.y - ptOldOrg.y); RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst); if ((num = RegionNumRects(&rgnDst))) { if (pPriv->preRefresh) (*pPriv->preRefresh) (pPriv->pScrn, num, RegionRects(&rgnDst)); } else { RegionUninit(&rgnDst); } } pScreen->CopyWindow = pPriv->CopyWindow; (*pScreen->CopyWindow) (pWin, ptOldOrg, prgn); pScreen->CopyWindow = ShadowCopyWindow; if (num) { if (pPriv->postRefresh) (*pPriv->postRefresh) (pPriv->pScrn, num, RegionRects(&rgnDst)); RegionUninit(&rgnDst); } }
void miWindowExposures(WindowPtr pWin, RegionPtr prgn) { RegionPtr exposures = prgn; if (prgn && !RegionNil(prgn)) { RegionRec expRec; int clientInterested = (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask; if (clientInterested && (RegionNumRects(prgn) > RECTLIMIT)) { /* * If we have LOTS of rectangles, we decide to take the extents * and force an exposure on that. This should require much less * work overall, on both client and server. This is cheating, but * isn't prohibited by the protocol ("spontaneous combustion" :-). */ BoxRec box = *RegionExtents(prgn); exposures = &expRec; RegionInit(exposures, &box, 1); RegionReset(prgn, &box); /* miPaintWindow doesn't clip, so we have to */ RegionIntersect(prgn, prgn, &pWin->clipList); } pWin->drawable.pScreen->PaintWindow(pWin, prgn, PW_BACKGROUND); if (clientInterested) miSendExposures(pWin, exposures, pWin->drawable.x, pWin->drawable.y); if (exposures == &expRec) RegionUninit(exposures); RegionEmpty(prgn); } }
void miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy) { BoxPtr pBox; int numRects; xEvent *pEvent, *pe; int i; pBox = RegionRects(pRgn); numRects = RegionNumRects(pRgn); if (!(pEvent = calloc(1, numRects * sizeof(xEvent)))) return; for (i = numRects, pe = pEvent; --i >= 0; pe++, pBox++) { pe->u.u.type = Expose; pe->u.expose.window = pWin->drawable.id; pe->u.expose.x = pBox->x1 - dx; pe->u.expose.y = pBox->y1 - dy; pe->u.expose.width = pBox->x2 - pBox->x1; pe->u.expose.height = pBox->y2 - pBox->y1; pe->u.expose.count = i; } #ifdef PANORAMIX if (!noPanoramiXExtension) { int scrnum = pWin->drawable.pScreen->myNum; int x = 0, y = 0; XID realWin = 0; if (!pWin->parent) { x = screenInfo.screens[scrnum]->x; y = screenInfo.screens[scrnum]->y; pWin = screenInfo.screens[0]->root; realWin = pWin->drawable.id; } else if (scrnum) { PanoramiXRes *win; win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, scrnum); if (!win) { free(pEvent); return; } realWin = win->info[0].id; dixLookupWindow(&pWin, realWin, serverClient, DixSendAccess); } if (x || y || scrnum) for (i = 0; i < numRects; i++) { pEvent[i].u.expose.window = realWin; pEvent[i].u.expose.x += x; pEvent[i].u.expose.y += y; } } #endif DeliverEvents(pWin, pEvent, numRects, NullWindow); free(pEvent); }
void fbPolyLine(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt) { void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt); if (pGC->lineWidth == 0) { line = fbZeroLine; if (pGC->fillStyle == FillSolid && pGC->lineStyle == LineSolid && RegionNumRects(fbGetCompositeClip(pGC)) == 1) { switch (pDrawable->bitsPerPixel) { case 8: line = fbPolyline8; break; case 16: line = fbPolyline16; break; case 32: line = fbPolyline32; break; } } } else { if (pGC->lineStyle != LineSolid) line = miWideDash; else line = miWideLine; } (*line) (pDrawable, pGC, mode, npt, ppt); }
void shadowUpdateIplan2p4(ScreenPtr pScreen, shadowBufPtr pBuf) { RegionPtr damage = shadowDamage(pBuf); PixmapPtr pShadow = pBuf->pPixmap; int nbox = RegionNumRects(damage); BoxPtr pbox = RegionRects(damage); FbBits *shaBase; CARD16 *shaLine, *sha; FbStride shaStride; int scrLine; _X_UNUSED int shaBpp, shaXoff, shaYoff; int x, y, w, h; int i, n; CARD16 *win; _X_UNUSED CARD32 winSize; union { CARD8 bytes[8]; CARD32 words[2]; } d; fbGetDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); shaStride *= sizeof(FbBits) / sizeof(CARD16); while (nbox--) { x = pbox->x1; y = pbox->y1; w = pbox->x2 - pbox->x1; h = pbox->y2 - pbox->y1; scrLine = (x & -16) / 2; shaLine = (CARD16 *)shaBase + y * shaStride + scrLine / sizeof(CARD16); n = ((x & 15) + w + 15) / 16; /* number of c2p units in scanline */ while (h--) { sha = shaLine; win = (CARD16 *) (*pBuf->window) (pScreen, y, scrLine, SHADOW_WINDOW_WRITE, &winSize, pBuf->closure); if (!win) return; for (i = 0; i < n; i++) { memcpy(d.bytes, sha, sizeof(d.bytes)); c2p_16x4(d.words); store_iplan2p4(win, d.words); sha += sizeof(d.bytes) / sizeof(*sha); win += sizeof(d.bytes) / sizeof(*win); } shaLine += shaStride; y++; } pbox++; } }
void fbPutZImage (DrawablePtr pDrawable, RegionPtr pClip, int alu, FbBits pm, int x, int y, int width, int height, FbStip *src, FbStride srcStride) { FbStip *dst; FbStride dstStride; int dstBpp; int dstXoff, dstYoff; int nbox; BoxPtr pbox; int x1, y1, x2, y2; fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); for (nbox = RegionNumRects (pClip), pbox = RegionRects(pClip); nbox--; pbox++) { x1 = x; y1 = y; x2 = x + width; y2 = y + height; if (x1 < pbox->x1) x1 = pbox->x1; if (y1 < pbox->y1) y1 = pbox->y1; if (x2 > pbox->x2) x2 = pbox->x2; if (y2 > pbox->y2) y2 = pbox->y2; if (x1 >= x2 || y1 >= y2) continue; fbBltStip (src + (y1 - y) * srcStride, srcStride, (x1 - x) * dstBpp, dst + (y1 + dstYoff) * dstStride, dstStride, (x1 + dstXoff) * dstBpp, (x2 - x1) * dstBpp, (y2 - y1), alu, pm, dstBpp); } fbFinishAccess (pDrawable); }
void XAACopyWindow( WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc ) { DDXPointPtr pptSrc, ppt; RegionRec rgnDst; BoxPtr pbox; int dx, dy, nbox; WindowPtr pwinRoot; ScreenPtr pScreen = pWin->drawable.pScreen; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable)); if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { XAA_SCREEN_PROLOGUE (pScreen, CopyWindow); if(infoRec->pScrn->vtSema && infoRec->NeedToSync) { (*infoRec->Sync)(infoRec->pScrn); infoRec->NeedToSync = FALSE; } (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow); return; } pwinRoot = pScreen->root; RegionNull(&rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; RegionTranslate(prgnSrc, -dx, -dy); RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc); pbox = RegionRects(&rgnDst); nbox = RegionNumRects(&rgnDst); if(!nbox || !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) { RegionUninit(&rgnDst); return; } ppt = pptSrc; while(nbox--) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; ppt++; pbox++; } infoRec->ScratchGC.planemask = ~0L; infoRec->ScratchGC.alu = GXcopy; XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, &(infoRec->ScratchGC), &rgnDst, pptSrc); free(pptSrc); RegionUninit(&rgnDst); }
/* * Create and display a new frame. */ static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY, RegionPtr pShape) { WindowPtr pWin = pFrame->win; xp_window_changes wc; unsigned int mask = 0; xp_error err; wc.x = newX; wc.y = newY; wc.width = pFrame->width; wc.height = pFrame->height; wc.bit_gravity = XP_GRAVITY_NONE; mask |= XP_BOUNDS; if (pWin->drawable.depth == 8) { wc.depth = XP_DEPTH_INDEX8; wc.colormap = xprColormapCallback; wc.colormap_data = pScreen; mask |= XP_COLORMAP; } else if (pWin->drawable.depth == 15) wc.depth = XP_DEPTH_RGB555; else if (pWin->drawable.depth == 24) wc.depth = XP_DEPTH_ARGB8888; else wc.depth = XP_DEPTH_NIL; mask |= XP_DEPTH; if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); wc.shape_rects = RegionRects(pShape); wc.shape_tx = wc.shape_ty = 0; mask |= XP_SHAPE; } pFrame->level = !IsRoot(pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels; if (XQuartzIsRootless) wc.window_level = normal_window_levels[pFrame->level]; else if (XQuartzShieldingWindowLevel) wc.window_level = XQuartzShieldingWindowLevel + 1; else wc.window_level = rooted_window_levels[pFrame->level]; mask |= XP_WINDOW_LEVEL; err = xp_create_window(mask, &wc, (xp_window_id *)&pFrame->wid); if (err != Success) { return FALSE; } #ifdef HAVE_LIBDISPATCH dispatch_async(window_hash_serial_q, ^ { x_hash_table_insert(window_hash, pFrame->wid, pFrame); });
/* * Compute the visibility of a shaped window */ int miShapedWindowIn (RegionPtr universe, RegionPtr bounding, BoxPtr rect, int x, int y) { BoxRec box; BoxPtr boundBox; int nbox; Bool someIn, someOut; int t, x1, y1, x2, y2; nbox = RegionNumRects (bounding); boundBox = RegionRects (bounding); someIn = someOut = FALSE; x1 = rect->x1; y1 = rect->y1; x2 = rect->x2; y2 = rect->y2; while (nbox--) { if ((t = boundBox->x1 + x) < x1) t = x1; box.x1 = t; if ((t = boundBox->y1 + y) < y1) t = y1; box.y1 = t; if ((t = boundBox->x2 + x) > x2) t = x2; box.x2 = t; if ((t = boundBox->y2 + y) > y2) t = y2; box.y2 = t; if (box.x1 > box.x2) box.x2 = box.x1; if (box.y1 > box.y2) box.y2 = box.y1; switch (RegionContainsRect(universe, &box)) { case rgnIN: if (someOut) return rgnPART; someIn = TRUE; break; case rgnOUT: if (someIn) return rgnPART; someOut = TRUE; break; default: return rgnPART; } boundBox++; } if (someIn) return rgnIN; return rgnOUT; }
static void glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog, struct glamor_glyph_atlas *atlas, int nglyph) { DrawablePtr drawable = dst->pDrawable; glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen); PixmapPtr atlas_pixmap = atlas->atlas; glamor_pixmap_private *atlas_priv = glamor_get_pixmap_private(atlas_pixmap); glamor_pixmap_fbo *atlas_fbo = glamor_pixmap_fbo_at(atlas_priv, 0, 0); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); int box_x, box_y; int off_x, off_y; glamor_put_vbo_space(drawable->pScreen); glEnable(GL_SCISSOR_TEST); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, atlas_fbo->tex); for (;;) { if (!glamor_use_program_render(prog, op, src, dst)) break; glUniform1i(prog->atlas_uniform, 1); glamor_pixmap_loop(pixmap_priv, box_x, box_y) { BoxPtr box = RegionRects(dst->pCompositeClip); int nbox = RegionNumRects(dst->pCompositeClip); glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y); /* Run over the clip list, drawing the glyphs * in each box */ while (nbox--) { glScissor(box->x1 + off_x, box->y1 + off_y, box->x2 - box->x1, box->y2 - box->y1); box++; if (glamor_glyph_use_130(glamor_priv)) glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph); else glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph); } } if (prog->alpha != glamor_program_alpha_ca_first) break; prog++; }
int ProcXFixesFetchRegion (ClientPtr client) { RegionPtr pRegion; xXFixesFetchRegionReply *reply; xRectangle *pRect; BoxPtr pExtent; BoxPtr pBox; int i, nBox; REQUEST(xXFixesFetchRegionReq); REQUEST_SIZE_MATCH(xXFixesFetchRegionReq); VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess); pExtent = RegionExtents(pRegion); pBox = RegionRects (pRegion); nBox = RegionNumRects (pRegion); reply = malloc(sizeof (xXFixesFetchRegionReply) + nBox * sizeof (xRectangle)); if (!reply) return BadAlloc; reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = nBox << 1; reply->x = pExtent->x1; reply->y = pExtent->y1; reply->width = pExtent->x2 - pExtent->x1; reply->height = pExtent->y2 - pExtent->y1; pRect = (xRectangle *) (reply + 1); for (i = 0; i < nBox; i++) { pRect[i].x = pBox[i].x1; pRect[i].y = pBox[i].y1; pRect[i].width = pBox[i].x2 - pBox[i].x1; pRect[i].height = pBox[i].y2 - pBox[i].y1; } if (client->swapped) { int n; swaps (&reply->sequenceNumber, n); swapl (&reply->length, n); swaps (&reply->x, n); swaps (&reply->y, n); swaps (&reply->width, n); swaps (&reply->height, n); SwapShorts ((INT16 *) pRect, nBox * 4); } (void) WriteToClient(client, sizeof (xXFixesFetchRegionReply) + nBox * sizeof (xRectangle), (char *) reply); free(reply); return Success; }
void fbSolidBoxClipped(DrawablePtr pDrawable, RegionPtr pClip, int x1, int y1, int x2, int y2, FbBits and, FbBits xor) { FbBits *dst; FbStride dstStride; int dstBpp; int dstXoff, dstYoff; BoxPtr pbox; int nbox; int partX1, partX2, partY1, partY2; fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); for (nbox = RegionNumRects(pClip), pbox = RegionRects(pClip); nbox--; pbox++) { partX1 = pbox->x1; if (partX1 < x1) partX1 = x1; partX2 = pbox->x2; if (partX2 > x2) partX2 = x2; if (partX2 <= partX1) continue; partY1 = pbox->y1; if (partY1 < y1) partY1 = y1; partY2 = pbox->y2; if (partY2 > y2) partY2 = y2; if (partY2 <= partY1) continue; #ifndef FB_ACCESS_WRAPPER if (and || !pixman_fill((uint32_t *) dst, dstStride, dstBpp, partX1 + dstXoff, partY1 + dstYoff, (partX2 - partX1), (partY2 - partY1), xor)) #endif fbSolid(dst + (partY1 + dstYoff) * dstStride, dstStride, (partX1 + dstXoff) * dstBpp, dstBpp, (partX2 - partX1) * dstBpp, (partY2 - partY1), and, xor); } fbFinishAccess(pDrawable); }
RegionPtr XFixesRegionCopy(RegionPtr pRegion) { RegionPtr pNew = RegionCreate(RegionExtents(pRegion), RegionNumRects(pRegion)); if (!pNew) return 0; if (!RegionCopy(pNew, pRegion)) { RegionDestroy(pNew); return 0; } return pNew; }
Bool glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, unsigned long fg_pixel) { glamor_pixmap_private *pixmap_priv; GLfloat color[4]; pixmap_priv = glamor_get_pixmap_private(pixmap); if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) return FALSE; glamor_get_rgba_from_pixel(fg_pixel, &color[0], &color[1], &color[2], &color[3], format_for_pixmap(pixmap)); if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) { RegionRec region; int n_region; glamor_pixmap_clipped_regions *clipped_regions; int i; RegionInitBoxes(®ion, box, nbox); clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0); for (i = 0; i < n_region; i++) { BoxPtr inner_box; int inner_nbox; SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx); inner_box = RegionRects(clipped_regions[i].region); inner_nbox = RegionNumRects(clipped_regions[i].region); _glamor_solid_boxes(pixmap, inner_box, inner_nbox, color); RegionDestroy(clipped_regions[i].region); } free(clipped_regions); RegionUninit(®ion); } else _glamor_solid_boxes(pixmap, box, nbox, color); return TRUE; }
static void DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw) { xp_window_changes wc; unsigned int flags = 0; if (pDRIDrawablePriv->sid == 0) return; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888 : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL); if (wc.depth != XP_DEPTH_NIL) flags |= XP_DEPTH; #endif if (pDraw->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDraw; WindowPtr pTopWin = TopLevelParent(pWin); wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth); wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth); wc.width = pWin->drawable.width + 2 * pWin->borderWidth; wc.height = pWin->drawable.height + 2 * pWin->borderWidth; wc.bit_gravity = XP_GRAVITY_NONE; wc.shape_nrects = RegionNumRects(&pWin->clipList); wc.shape_rects = RegionRects(&pWin->clipList); wc.shape_tx = -(pTopWin->drawable.x - pTopWin->borderWidth); wc.shape_ty = -(pTopWin->drawable.y - pTopWin->borderWidth); flags |= XP_BOUNDS | XP_SHAPE; } else if (pDraw->type == DRAWABLE_PIXMAP) { wc.x = 0; wc.y = 0; wc.width = pDraw->width; wc.height = pDraw->height; wc.bit_gravity = XP_GRAVITY_NONE; flags |= XP_BOUNDS; } xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc); }
void fbFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, FbBits and, FbBits xor) { FbBits *dst; FbStride dstStride; int dstBpp; int dstXoff, dstYoff; int n = RegionNumRects(pRegion); BoxPtr pbox = RegionRects(pRegion); #ifndef FB_ACCESS_WRAPPER int try_mmx = 0; if (!and) try_mmx = 1; #endif fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); while (n--) { #ifndef FB_ACCESS_WRAPPER if (!try_mmx || !pixman_fill((uint32_t *) dst, dstStride, dstBpp, pbox->x1 + dstXoff, pbox->y1 + dstYoff, (pbox->x2 - pbox->x1), (pbox->y2 - pbox->y1), xor)) { #endif fbSolid(dst + (pbox->y1 + dstYoff) * dstStride, dstStride, (pbox->x1 + dstXoff) * dstBpp, dstBpp, (pbox->x2 - pbox->x1) * dstBpp, pbox->y2 - pbox->y1, and, xor); #ifndef FB_ACCESS_WRAPPER } #endif fbValidateDrawable(pDrawable); pbox++; } fbFinishAccess(pDrawable); }
static void DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure) { DamageExtPtr pDamageExt = closure; switch (pDamageExt->level) { case DamageReportRawRegion: case DamageReportDeltaRegion: DamageExtNotify (pDamageExt, RegionRects(pRegion), RegionNumRects(pRegion)); break; case DamageReportBoundingBox: DamageExtNotify (pDamageExt, RegionExtents(pRegion), 1); break; case DamageReportNonEmpty: DamageExtNotify (pDamageExt, NullBox, 0); break; case DamageReportNone: break; } }
/** Change the clip rects for a GC. */ void dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects) { ScreenPtr pScreen = pGC->pScreen; DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); XRectangle *pRects; BoxPtr pBox; int i, nRects; DMX_GC_FUNC_PROLOGUE(pGC); pGC->funcs->ChangeClip(pGC, type, pvalue, nrects); /* Set the client clip on the back-end server */ if (!pGC->clientClip) { if (dmxScreen->beDisplay) XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None); } else { if (dmxScreen->beDisplay) { nRects = RegionNumRects((RegionPtr) pGC->clientClip); pRects = malloc(nRects * sizeof(*pRects)); pBox = RegionRects((RegionPtr) pGC->clientClip); for (i = 0; i < nRects; i++) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; pRects[i].width = pBox[i].x2 - pBox[i].x1; pRects[i].height = pBox[i].y2 - pBox[i].y1; } XSetClipRectangles(dmxScreen->beDisplay, pGCPriv->gc, pGC->clipOrg.x, pGC->clipOrg.y, pRects, nRects, Unsorted); free(pRects); } } DMX_GC_FUNC_EPILOGUE(pGC); }
int ProcXFixesExpandRegion (ClientPtr client) { RegionPtr pSource, pDestination; REQUEST (xXFixesExpandRegionReq); BoxPtr pTmp; BoxPtr pSrc; int nBoxes; int i; REQUEST_SIZE_MATCH (xXFixesExpandRegionReq); VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); nBoxes = RegionNumRects(pSource); pSrc = RegionRects(pSource); if (nBoxes) { pTmp = malloc(nBoxes * sizeof (BoxRec)); if (!pTmp) return BadAlloc; for (i = 0; i < nBoxes; i++) { pTmp[i].x1 = pSrc[i].x1 - stuff->left; pTmp[i].x2 = pSrc[i].x2 + stuff->right; pTmp[i].y1 = pSrc[i].y1 - stuff->top; pTmp[i].y2 = pSrc[i].y2 + stuff->bottom; } RegionEmpty(pDestination); for (i = 0; i < nBoxes; i++) { RegionRec r; RegionInit(&r, &pTmp[i], 0); RegionUnion(pDestination, pDestination, &r); } free(pTmp); } return Success; }
/* * Change the frame's shape. */ static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) { xp_window_changes wc; TA_SERVER(); if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); wc.shape_rects = RegionRects(pShape); } else { wc.shape_nrects = -1; wc.shape_rects = NULL; } wc.shape_tx = wc.shape_ty = 0; xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc); }
static int ephyrReputImage(KdScreenInfo * a_info, DrawablePtr a_drawable, short a_drw_x, short a_drw_y, RegionPtr a_clipping_region, pointer a_port_priv) { EphyrPortPriv *port_priv = a_port_priv; int result = BadImplementation; EPHYR_RETURN_VAL_IF_FAIL(a_info->pScreen, FALSE); EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue); EPHYR_LOG("enter\n"); if (!port_priv->image_buf_size || !port_priv->image_buf) { EPHYR_LOG_ERROR("has null image buf in cache\n"); goto out; } if (!ephyrHostXVPutImage(a_info->pScreen->myNum, port_priv->port_number, port_priv->image_id, a_drw_x, a_drw_y, port_priv->drw_w, port_priv->drw_h, port_priv->src_x, port_priv->src_y, port_priv->src_w, port_priv->src_h, port_priv->image_width, port_priv->image_height, port_priv->image_buf, (EphyrHostBox *) RegionRects(a_clipping_region), RegionNumRects(a_clipping_region))) { EPHYR_LOG_ERROR("ephyrHostXVPutImage() failed\n"); goto out; } result = Success; out: EPHYR_LOG("leave\n"); return result; }
static void xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, RegionPtr region) { ScrnInfoPtr scrn = crtc->scrn; ScreenPtr screen = scrn->pScreen; WindowPtr root = screen->root; PixmapPtr dst_pixmap = crtc->rotatedPixmap; PictFormatPtr format = PictureWindowFormat(screen->root); int error; PicturePtr src, dst; int n = RegionNumRects(region); BoxPtr b = RegionRects(region); XID include_inferiors = IncludeInferiors; if (crtc->driverIsPerformingTransform) return; src = CreatePicture(None, &root->drawable, format, CPSubwindowMode, &include_inferiors, serverClient, &error); if (!src) return; dst = CreatePicture(None, &dst_pixmap->drawable, format, 0L, NULL, serverClient, &error); if (!dst) return; error = SetPictureTransform(src, &crtc->crtc_to_framebuffer); if (error) return; if (crtc->transform_in_use && crtc->filter) SetPicturePictFilter(src, crtc->filter, crtc->params, crtc->nparams); if (crtc->shadowClear) { CompositePicture(PictOpSrc, src, NULL, dst, 0, 0, 0, 0, 0, 0, crtc->mode.HDisplay, crtc->mode.VDisplay); crtc->shadowClear = FALSE; } else { while (n--) { BoxRec dst_box; dst_box = *b; dst_box.x1 -= crtc->filter_width >> 1; dst_box.x2 += crtc->filter_width >> 1; dst_box.y1 -= crtc->filter_height >> 1; dst_box.y2 += crtc->filter_height >> 1; pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, &dst_box); CompositePicture(PictOpSrc, src, NULL, dst, dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1, dst_box.x2 - dst_box.x1, dst_box.y2 - dst_box.y1); b++; } } FreePicture(src, None); FreePicture(dst, None); }
static Bool exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel, CARD32 planemask, CARD32 alu, Bool hasClientClip) { ExaScreenPriv(pDrawable->pScreen); PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable); ExaPixmapPriv(pPixmap); int xoff, yoff; Bool ret = FALSE; exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff); RegionTranslate(pRegion, xoff, yoff); if (pExaScr->fallback_counter || pExaPixmap->accel_blocked) goto out; if (pExaScr->do_migration) { ExaMigrationRec pixmaps[1]; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; pixmaps[0].pPix = pPixmap; pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillSolid, alu, hasClientClip) ? NULL : pRegion; exaDoMigration(pixmaps, 1, TRUE); } if (exaPixmapHasGpuCopy(pPixmap) && (*pExaScr->info->PrepareSolid) (pPixmap, alu, planemask, pixel)) { int nbox; BoxPtr pBox; nbox = RegionNumRects(pRegion); pBox = RegionRects(pRegion); while (nbox--) { (*pExaScr->info->Solid) (pPixmap, pBox->x1, pBox->y1, pBox->x2, pBox->y2); pBox++; } (*pExaScr->info->DoneSolid) (pPixmap); exaMarkSync(pDrawable->pScreen); if (pExaPixmap->pDamage && pExaPixmap->sys_ptr && pDrawable->type == DRAWABLE_PIXMAP && pDrawable->width == 1 && pDrawable->height == 1 && pDrawable->bitsPerPixel != 24) { RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage); switch (pDrawable->bitsPerPixel) { case 32: *(CARD32 *) pExaPixmap->sys_ptr = pixel; break; case 16: *(CARD16 *) pExaPixmap->sys_ptr = pixel; break; case 8: case 4: case 1: *(CARD8 *) pExaPixmap->sys_ptr = pixel; } RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys, pRegion); RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB, pRegion); RegionSubtract(pending_damage, pending_damage, pRegion); } ret = TRUE; } out: RegionTranslate(pRegion, -xoff, -yoff); return ret; }
static void exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect) { ExaScreenPriv(pDrawable->pScreen); RegionPtr pClip = fbGetCompositeClip(pGC); PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable); ExaPixmapPriv(pPixmap); register BoxPtr pbox; BoxPtr pextent; int extentX1, extentX2, extentY1, extentY2; int fullX1, fullX2, fullY1, fullY2; int partX1, partX2, partY1, partY2; int xoff, yoff; int xorg, yorg; int n; RegionPtr pReg = RegionFromRects(nrect, prect, CT_UNSORTED); /* Compute intersection of rects and clip region */ RegionTranslate(pReg, pDrawable->x, pDrawable->y); RegionIntersect(pReg, pClip, pReg); if (!RegionNumRects(pReg)) { goto out; } exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff); if (pExaScr->fallback_counter || pExaScr->swappedOut || pExaPixmap->accel_blocked) { goto fallback; } /* For ROPs where overlaps don't matter, convert rectangles to region and * call exaFillRegion{Solid,Tiled}. */ if ((pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) && (nrect == 1 || pGC->alu == GXcopy || pGC->alu == GXclear || pGC->alu == GXnoop || pGC->alu == GXcopyInverted || pGC->alu == GXset)) { if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) && exaFillRegionSolid(pDrawable, pReg, pGC->fillStyle == FillSolid ? pGC->fgPixel : pGC->tile.pixel, pGC->planemask, pGC->alu, pGC->clientClip != NULL)) || (pGC->fillStyle == FillTiled && !pGC->tileIsPixel && exaFillRegionTiled(pDrawable, pReg, pGC->tile.pixmap, &pGC->patOrg, pGC->planemask, pGC->alu, pGC->clientClip != NULL))) { goto out; } } if (pGC->fillStyle != FillSolid && !(pGC->tileIsPixel && pGC->fillStyle == FillTiled)) { goto fallback; } if (pExaScr->do_migration) { ExaMigrationRec pixmaps[1]; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; pixmaps[0].pPix = pPixmap; pixmaps[0].pReg = NULL; exaDoMigration(pixmaps, 1, TRUE); } if (!exaPixmapHasGpuCopy(pPixmap) || !(*pExaScr->info->PrepareSolid) (pPixmap, pGC->alu, pGC->planemask, pGC->fgPixel)) { fallback: ExaCheckPolyFillRect(pDrawable, pGC, nrect, prect); goto out; } xorg = pDrawable->x; yorg = pDrawable->y; pextent = RegionExtents(pClip); extentX1 = pextent->x1; extentY1 = pextent->y1; extentX2 = pextent->x2; extentY2 = pextent->y2; while (nrect--) { fullX1 = prect->x + xorg; fullY1 = prect->y + yorg; fullX2 = fullX1 + (int) prect->width; fullY2 = fullY1 + (int) prect->height; prect++; if (fullX1 < extentX1) fullX1 = extentX1; if (fullY1 < extentY1) fullY1 = extentY1; if (fullX2 > extentX2) fullX2 = extentX2; if (fullY2 > extentY2) fullY2 = extentY2; if ((fullX1 >= fullX2) || (fullY1 >= fullY2)) continue; n = RegionNumRects(pClip); if (n == 1) { (*pExaScr->info->Solid) (pPixmap, fullX1 + xoff, fullY1 + yoff, fullX2 + xoff, fullY2 + yoff); } else { pbox = RegionRects(pClip); /* * clip the rectangle to each box in the clip region * this is logically equivalent to calling Intersect(), * but rectangles may overlap each other here. */ while (n--) { partX1 = pbox->x1; if (partX1 < fullX1) partX1 = fullX1; partY1 = pbox->y1; if (partY1 < fullY1) partY1 = fullY1; partX2 = pbox->x2; if (partX2 > fullX2) partX2 = fullX2; partY2 = pbox->y2; if (partY2 > fullY2) partY2 = fullY2; pbox++; if (partX1 < partX2 && partY1 < partY2) { (*pExaScr->info->Solid) (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff, partY2 + yoff); } } } } (*pExaScr->info->DoneSolid) (pPixmap); exaMarkSync(pDrawable->pScreen); out: RegionUninit(pReg); RegionDestroy(pReg); }
static void exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, DDXPointPtr ppt, int *pwidth, int fSorted) { ScreenPtr pScreen = pDrawable->pScreen; ExaScreenPriv(pScreen); RegionPtr pClip = fbGetCompositeClip(pGC); PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable); ExaPixmapPriv(pPixmap); BoxPtr pextent, pbox; int nbox; int extentX1, extentX2, extentY1, extentY2; int fullX1, fullX2, fullY1; int partX1, partX2; int off_x, off_y; if (pExaScr->fallback_counter || pExaScr->swappedOut || pGC->fillStyle != FillSolid || pExaPixmap->accel_blocked) { ExaCheckFillSpans(pDrawable, pGC, n, ppt, pwidth, fSorted); return; } if (pExaScr->do_migration) { ExaMigrationRec pixmaps[1]; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; pixmaps[0].pPix = pPixmap; pixmaps[0].pReg = NULL; exaDoMigration(pixmaps, 1, TRUE); } if (!(pPixmap = exaGetOffscreenPixmap(pDrawable, &off_x, &off_y)) || !(*pExaScr->info->PrepareSolid) (pPixmap, pGC->alu, pGC->planemask, pGC->fgPixel)) { ExaCheckFillSpans(pDrawable, pGC, n, ppt, pwidth, fSorted); return; } pextent = RegionExtents(pClip); extentX1 = pextent->x1; extentY1 = pextent->y1; extentX2 = pextent->x2; extentY2 = pextent->y2; while (n--) { fullX1 = ppt->x; fullY1 = ppt->y; fullX2 = fullX1 + (int) *pwidth; ppt++; pwidth++; if (fullY1 < extentY1 || extentY2 <= fullY1) continue; if (fullX1 < extentX1) fullX1 = extentX1; if (fullX2 > extentX2) fullX2 = extentX2; if (fullX1 >= fullX2) continue; nbox = RegionNumRects(pClip); if (nbox == 1) { (*pExaScr->info->Solid) (pPixmap, fullX1 + off_x, fullY1 + off_y, fullX2 + off_x, fullY1 + 1 + off_y); } else { pbox = RegionRects(pClip); while (nbox--) { if (pbox->y1 <= fullY1 && fullY1 < pbox->y2) { partX1 = pbox->x1; if (partX1 < fullX1) partX1 = fullX1; partX2 = pbox->x2; if (partX2 > fullX2) partX2 = fullX2; if (partX2 > partX1) { (*pExaScr->info->Solid) (pPixmap, partX1 + off_x, fullY1 + off_y, partX2 + off_x, fullY1 + 1 + off_y); } } pbox++; } } } (*pExaScr->info->DoneSolid) (pPixmap); exaMarkSync(pScreen); }