summaryrefslogtreecommitdiff
path: root/src/sna
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-07-11 16:40:51 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-07-11 22:23:29 +0100
commitc604d1426cc11f9799044710acf1ef7d226d2604 (patch)
tree09c1aa25ae0fb460a5cf12156cf9d372f0a37086 /src/sna
parent07926bfe507071a3d46a2ec13bb86a36bc225761 (diff)
sna: Remove the duplicated open-coding of SetScreenPixmap
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r--src/sna/sna.h2
-rw-r--r--src/sna/sna_accel.c73
-rw-r--r--src/sna/sna_display.c59
-rw-r--r--src/sna/sna_display_fake.c59
-rw-r--r--src/sna/sna_driver.c2
5 files changed, 75 insertions, 120 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 17cae7e2..249d57cb 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -149,7 +149,7 @@ struct sna_glyph {
uint16_t size, pos;
};
-static inline WindowPtr root(ScreenPtr screen)
+static inline WindowPtr get_root_window(ScreenPtr screen)
{
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,10,0,0,0)
return screen->root;
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 50aa48e1..2eb16992 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -15062,6 +15062,77 @@ sna_set_window_pixmap(WindowPtr window, PixmapPtr pixmap)
*(PixmapPtr *)__get_private(window, sna_window_key) = pixmap;
}
+struct sna_visit_set_pixmap_window {
+ PixmapPtr old, new;
+};
+
+static int
+sna_visit_set_window_pixmap(WindowPtr window, pointer data)
+{
+ struct sna_visit_set_pixmap_window *visit = data;
+
+ if (fbGetWindowPixmap(window) == visit->old) {
+ window->drawable.pScreen->SetWindowPixmap(window, visit->new);
+ return WT_WALKCHILDREN;
+ }
+
+ return WT_DONTWALKCHILDREN;
+}
+
+static void
+migrate_dirty_tracking(PixmapPtr old_front, PixmapPtr new_front)
+{
+#if HAS_PIXMAP_SHARING
+ ScreenPtr screen = old_front->drawable.pScreen;
+ PixmapDirtyUpdatePtr dirty, safe;
+
+ xorg_list_for_each_entry_safe(dirty, safe, &screen->pixmap_dirty_list, ent) {
+ assert(dirty->src == old_front);
+ if (dirty->src != old_front)
+ continue;
+
+ DamageUnregister(&dirty->src->drawable, dirty->damage);
+ DamageDestroy(dirty->damage);
+
+ dirty->damage = DamageCreate(NULL, NULL,
+ DamageReportNone,
+ TRUE, screen, screen);
+ if (!dirty->damage) {
+ xorg_list_del(&dirty->ent);
+ free(dirty);
+ continue;
+ }
+
+ DamageRegister(&new_front->drawable, dirty->damage);
+ dirty->src = new_front;
+ }
+#endif
+}
+
+static void
+sna_set_screen_pixmap(PixmapPtr pixmap)
+{
+ PixmapPtr old_front = pixmap->drawable.pScreen->devPrivate;
+ WindowPtr root;
+
+ assert(pixmap == to_sna_from_pixmap(pixmap)->front);
+
+ if (old_front)
+ migrate_dirty_tracking(old_front, pixmap);
+
+ root = get_root_window(pixmap->drawable.pScreen);
+ if (root) {
+ struct sna_visit_set_pixmap_window visit;
+
+ visit.old = old_front;
+ visit.new = pixmap;
+ TraverseTree(root, sna_visit_set_window_pixmap, &visit);
+ assert(fbGetWindowPixmap(root) == pixmap);
+ }
+
+ pixmap->drawable.pScreen->devPrivate = pixmap;
+}
+
static Bool
sna_create_window(WindowPtr win)
{
@@ -15236,6 +15307,8 @@ bool sna_accel_init(ScreenPtr screen, struct sna *sna)
assert(screen->SetWindowPixmap == NULL);
screen->SetWindowPixmap = sna_set_window_pixmap;
+ screen->SetScreenPixmap = sna_set_screen_pixmap;
+
if (sna->kgem.has_userptr)
ShmRegisterFuncs(screen, &shm_funcs);
else
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index e1fc6fc9..1427cd6e 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -2610,24 +2610,6 @@ sna_mode_compute_possible_clones(ScrnInfoPtr scrn)
}
}
-struct sna_visit_set_pixmap_window {
- PixmapPtr old, new;
-};
-
-static int
-sna_visit_set_window_pixmap(WindowPtr window, pointer data)
-{
- struct sna_visit_set_pixmap_window *visit = data;
- ScreenPtr screen = window->drawable.pScreen;
-
- if (screen->GetWindowPixmap(window) == visit->old) {
- screen->SetWindowPixmap(window, visit->new);
- return WT_WALKCHILDREN;
- }
-
- return WT_DONTWALKCHILDREN;
-}
-
static void copy_front(struct sna *sna, PixmapPtr old, PixmapPtr new)
{
struct sna_pixmap *old_priv, *new_priv;
@@ -2695,36 +2677,6 @@ static void copy_front(struct sna *sna, PixmapPtr old, PixmapPtr new)
new->drawable.height);
}
-static void
-migrate_dirty_tracking(struct sna *sna, PixmapPtr old_front)
-{
-#if HAS_PIXMAP_SHARING
- ScreenPtr screen = sna->scrn->pScreen;
- PixmapDirtyUpdatePtr dirty, safe;
-
- xorg_list_for_each_entry_safe(dirty, safe, &screen->pixmap_dirty_list, ent) {
- assert(dirty->src == old_front);
- if (dirty->src != old_front)
- continue;
-
- DamageUnregister(&dirty->src->drawable, dirty->damage);
- DamageDestroy(dirty->damage);
-
- dirty->damage = DamageCreate(NULL, NULL,
- DamageReportNone,
- TRUE, screen, screen);
- if (!dirty->damage) {
- xorg_list_del(&dirty->ent);
- free(dirty);
- continue;
- }
-
- DamageRegister(&sna->front->drawable, dirty->damage);
- dirty->src = sna->front;
- }
-#endif
-}
-
static Bool
sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
{
@@ -2783,17 +2735,6 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
sna_crtc_disable(crtc);
}
- /* Open-coded screen->SetScreenPixmap */
- migrate_dirty_tracking(sna, old_front);
-
- if (root(screen)) {
- struct sna_visit_set_pixmap_window visit;
-
- visit.old = old_front;
- visit.new = sna->front;
- TraverseTree(root(screen), sna_visit_set_window_pixmap, &visit);
- assert(screen->GetWindowPixmap(root(screen)) == sna->front);
- }
screen->SetScreenPixmap(sna->front);
assert(screen->GetScreenPixmap(screen) == sna->front);
diff --git a/src/sna/sna_display_fake.c b/src/sna/sna_display_fake.c
index b4a5a943..113c44ac 100644
--- a/src/sna/sna_display_fake.c
+++ b/src/sna/sna_display_fake.c
@@ -199,54 +199,6 @@ sna_output_fake(struct sna *sna)
return true;
}
-struct sna_visit_set_pixmap_window {
- PixmapPtr old, new;
-};
-
-static int
-sna_visit_set_window_pixmap(WindowPtr window, pointer data)
-{
- struct sna_visit_set_pixmap_window *visit = data;
- ScreenPtr screen = window->drawable.pScreen;
-
- if (screen->GetWindowPixmap(window) == visit->old) {
- screen->SetWindowPixmap(window, visit->new);
- return WT_WALKCHILDREN;
- }
-
- return WT_DONTWALKCHILDREN;
-}
-
-static void
-migrate_dirty_tracking(struct sna *sna, PixmapPtr old_front)
-{
-#if HAS_PIXMAP_SHARING
- ScreenPtr screen = sna->scrn->pScreen;
- PixmapDirtyUpdatePtr dirty, safe;
-
- xorg_list_for_each_entry_safe(dirty, safe, &screen->pixmap_dirty_list, ent) {
- assert(dirty->src == old_front);
- if (dirty->src != old_front)
- continue;
-
- DamageUnregister(&dirty->src->drawable, dirty->damage);
- DamageDestroy(dirty->damage);
-
- dirty->damage = DamageCreate(NULL, NULL,
- DamageReportNone,
- TRUE, screen, screen);
- if (!dirty->damage) {
- xorg_list_del(&dirty->ent);
- free(dirty);
- continue;
- }
-
- DamageRegister(&sna->front->drawable, dirty->damage);
- dirty->src = sna->front;
- }
-#endif
-}
-
static Bool
sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
{
@@ -279,17 +231,6 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
scrn->virtualY = height;
scrn->displayWidth = width;
- /* Open-coded screen->SetScreenPixmap */
- migrate_dirty_tracking(sna, old_front);
-
- if (root(screen)) {
- struct sna_visit_set_pixmap_window visit;
-
- visit.old = old_front;
- visit.new = sna->front;
- TraverseTree(root(screen), sna_visit_set_window_pixmap, &visit);
- assert(screen->GetWindowPixmap(root(screen)) == sna->front);
- }
screen->SetScreenPixmap(sna->front);
assert(screen->GetScreenPixmap(screen) == sna->front);
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index aafa3651..eededf34 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -186,7 +186,7 @@ sna_set_fallback_mode(ScrnInfoPtr scrn)
xf86DisableUnusedFunctions(scrn);
#ifdef RANDR_12_INTERFACE
- if (root(scrn->pScreen))
+ if (get_root_window(scrn->pScreen))
xf86RandR12TellChanged(scrn->pScreen);
#endif
}