static Bool TegraCreateScreenResources(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); TegraPtr tegra = TegraPTR(pScrn); PixmapPtr rootPixmap; Bool ret; void *pixels; pScreen->CreateScreenResources = tegra->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = TegraCreateScreenResources; if (!drmmode_set_desired_modes(pScrn, &tegra->drmmode)) return FALSE; drmmode_uevent_init(pScrn, &tegra->drmmode); if (!tegra->drmmode.want_sw_cursor) drmmode_map_cursor_bos(pScrn, &tegra->drmmode); pixels = drmmode_map_front_bo(&tegra->drmmode); if (!pixels) return FALSE; rootPixmap = pScreen->GetScreenPixmap(pScreen); if (tegra->drmmode.shadow_enable) pixels = tegra->drmmode.shadow_fb; if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels)) FatalError("Couldn't adjust screen pixmap\n"); if (tegra->drmmode.shadow_enable) { if (!shadowAdd(pScreen, rootPixmap, shadowUpdatePackedWeak(), TegraShadowWindow, 0, 0)) return FALSE; } tegra->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, pScreen, rootPixmap); if (tegra->damage) { DamageRegister(&rootPixmap->drawable, tegra->damage); tegra->dirty_enabled = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n"); } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to create screen damage record\n"); return FALSE; } return ret; }
static Bool NestedCreateScreenResources(ScreenPtr pScreen) { xf86DrvMsg(pScreen->myNum, X_INFO, "NestedCreateScreenResources\n"); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; NestedPrivatePtr pNested = PNESTED(pScrn); Bool ret; pScreen->CreateScreenResources = pNested->CreateScreenResources; ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = NestedCreateScreenResources; shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), pNested->update, /*pNested->window*/ 0, 0, 0); }
static Bool winCreateScreenResources(ScreenPtr pScreen) { winScreenPriv(pScreen); Bool result; result = pScreenPriv->pwinCreateScreenResources(pScreen); /* Now the screen bitmap has been wrapped in a pixmap, add that to the Shadow framebuffer */ if (!shadowAdd(pScreen, pScreen->devPrivate, pScreenPriv->pwinShadowUpdate, NULL, 0, 0)) { ErrorF("winCreateScreenResources - shadowAdd () failed\n"); return FALSE; } return result; }
Bool shadowInit(ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window) { PixmapPtr pPixmap; pPixmap = pScreen->CreatePixmap(pScreen, pScreen->width, pScreen->height, pScreen->rootDepth); if (!pPixmap) return FALSE; if (!shadowSetup(pScreen)) { pScreen->DestroyPixmap(pPixmap); return FALSE; } shadowAdd(pScreen, pPixmap, update, window, NULL, SHADOW_ROTATE_0, 0); return TRUE; }
Bool LayerCreatePixmap (ScreenPtr pScreen, LayerPtr pLayer) { LayerKindPtr pKind = pLayer->pKind; LayerUnwrap (pScreen, pKind, CreatePixmap); /* XXX create full-screen sized layers all around */ pLayer->pPixmap = (*pScreen->CreatePixmap) (pScreen, pScreen->width, pScreen->height, pLayer->depth); LayerWrap (pScreen, pKind, CreatePixmap, layerCreatePixmap); if (!pLayer->pPixmap) return FALSE; if (pLayer->pKind->kind == LAYER_SHADOW) { if (!shadowAdd (pScreen, pLayer->pPixmap, pLayer->update, pLayer->window, pLayer->randr, pLayer->closure)) return FALSE; } return TRUE; }
static Bool CreateScreenResources(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); modesettingPtr ms = modesettingPTR(pScrn); PixmapPtr rootPixmap; Bool ret; void *pixels = NULL; int err; pScreen->CreateScreenResources = ms->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = CreateScreenResources; if (!drmmode_set_desired_modes(pScrn, &ms->drmmode)) return FALSE; if (!drmmode_glamor_handle_new_screen_pixmap(&ms->drmmode)) return FALSE; drmmode_uevent_init(pScrn, &ms->drmmode); if (!ms->drmmode.sw_cursor) drmmode_map_cursor_bos(pScrn, &ms->drmmode); if (!ms->drmmode.gbm) { pixels = drmmode_map_front_bo(&ms->drmmode); if (!pixels) return FALSE; } rootPixmap = pScreen->GetScreenPixmap(pScreen); if (ms->drmmode.shadow_enable) pixels = ms->drmmode.shadow_fb; if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels)) FatalError("Couldn't adjust screen pixmap\n"); if (ms->drmmode.shadow_enable) { if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked, msShadowWindow, 0, 0)) return FALSE; } err = drmModeDirtyFB(ms->fd, ms->drmmode.fb_id, NULL, 0); if (err != -EINVAL && err != -ENOSYS) { ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, pScreen, rootPixmap); if (ms->damage) { DamageRegister(&rootPixmap->drawable, ms->damage); ms->dirty_enabled = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n"); } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to create screen damage record\n"); return FALSE; } } return ret; }
Bool GXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode) { GeodeRec *pGeode = GEODEPTR(pScrni); Rotation curr = pGeode->rotation; unsigned int curdw = pScrni->displayWidth; PixmapPtr pPixmap; BOOL ret; pPixmap = pScrni->pScreen->GetScreenPixmap(pScrni->pScreen); pGeode->rotation = GXGetRotation(pScrni->pScreen); /* Leave if we have nothing to do */ if (pGeode->rotation == curr && pGeode->curMode == mode) { return TRUE; } shadowRemove(pScrni->pScreen, NULL); switch (pGeode->rotation) { case RR_Rotate_0: ErrorF("Rotate to 0 degrees\n"); pScrni->displayWidth = pGeode->displayWidth; pGeode->Pitch = pGeode->displayPitch; break; case RR_Rotate_90: ErrorF("Rotate to 90 degrees\n"); pScrni->displayWidth = pScrni->pScreen->width; break; case RR_Rotate_180: ErrorF("Rotate to 180 degrees\n"); pScrni->displayWidth = pGeode->displayWidth; break; case RR_Rotate_270: ErrorF("Rotate to 270 degrees\n"); pScrni->displayWidth = pScrni->pScreen->width; break; } if (pGeode->rotation != RR_Rotate_0) { ret = shadowAdd(pScrni->pScreen, pPixmap, GXUpdate, GXWindowLinear, pGeode->rotation, NULL); if (!ret) { ErrorF("shadowAdd failed\n"); goto error; } } if (pGeode->rotation == RR_Rotate_0) pScrni->fbOffset = pGeode->displayOffset; else pScrni->fbOffset = pGeode->shadowOffset; pScrni->pScreen->ModifyPixmapHeader(pPixmap, pScrni->pScreen->width, pScrni->pScreen->height, pScrni->pScreen->rootDepth, pScrni->bitsPerPixel, PixmapBytePad(pScrni->displayWidth, pScrni-> pScreen->rootDepth), (pointer) (pGeode->FBBase + pScrni->fbOffset)); /* Don't use XAA pixmap cache or offscreen pixmaps when rotated */ #if XF86XAA if (pGeode->AccelInfoRec) { if (pGeode->rotation == RR_Rotate_0) { pGeode->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; pGeode->AccelInfoRec->UsingPixmapCache = TRUE; pGeode->AccelInfoRec->maxOffPixWidth = 0; pGeode->AccelInfoRec->maxOffPixHeight = 0; } else { pGeode->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER; pGeode->AccelInfoRec->UsingPixmapCache = FALSE; pGeode->AccelInfoRec->maxOffPixWidth = 1; pGeode->AccelInfoRec->maxOffPixHeight = 1; } } #endif return TRUE; error: /* Restore the old rotation */ pScrni->displayWidth = curdw; if (curr & (RR_Rotate_0 | RR_Rotate_180)) { pScrni->pScreen->width = pScrni->virtualX; pScrni->pScreen->height = pScrni->virtualY; } else { pScrni->pScreen->width = pScrni->virtualY; pScrni->pScreen->height = pScrni->virtualX; } pGeode->rotation = curr; return FALSE; }