[PATCH 3/5] glamor: Pass source offset to glamor_use_program_render

Keith Packard keithp at keithp.com
Tue May 26 13:47:53 PDT 2015


We need the source offset when setting up a source pixmap to position
it in the destination correctly.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 glamor/glamor_composite_glyphs.c | 17 +++++++++--------
 glamor/glamor_program.c          | 16 +++++++++-------
 glamor/glamor_program.h          |  6 ++++--
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index 39ed854..5950e2c 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -210,8 +210,9 @@ glamor_glyphs_fini_facet(ScreenPtr screen)
 
 static void
 glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
-                   glamor_program *prog,
-                   struct glamor_glyph_atlas *atlas, int nglyph)
+                    int src_off_x, int src_off_y,
+                    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);
@@ -230,7 +231,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
     glBindTexture(GL_TEXTURE_2D, atlas_fbo->tex);
 
     for (;;) {
-        if (!glamor_use_program_render(prog, op, src, dst))
+        if (!glamor_use_program_render(prog, op, src, dst, src_off_x, src_off_y))
             break;
 
         glUniform1i(prog->atlas_uniform, 1);
@@ -373,12 +374,12 @@ glamor_composite_glyphs(CARD8 op,
                                 (glyph_pix_priv != 0 && glyph_pix_priv->type != GLAMOR_MEMORY)))
                 {
                     if (glyphs_queued) {
-                        glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+                        glamor_glyphs_flush(op, src, dst, x_src, y_src, prog, glyph_atlas, glyphs_queued);
                         glyphs_queued = 0;
                     }
                 bail_one:
                     glamor_composite(op, src, glyph_pict, dst,
-                                     x_src + (x - glyph->info.x), (y - glyph->info.y),
+                                     x_src + (x - glyph->info.x), y_src + (y - glyph->info.y),
                                      0, 0,
                                      x - glyph->info.x, y - glyph->info.y,
                                      glyph_draw->width, glyph_draw->height);
@@ -390,7 +391,7 @@ glamor_composite_glyphs(CARD8 op,
                      */
                     if (_X_UNLIKELY(next_atlas != glyph_atlas)) {
                         if (glyphs_queued) {
-                            glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+                            glamor_glyphs_flush(op, src, dst, x_src, y_src, prog, glyph_atlas, glyphs_queued);
                             glyphs_queued = 0;
                         }
                         glyph_atlas = next_atlas;
@@ -401,7 +402,7 @@ glamor_composite_glyphs(CARD8 op,
                     if (_X_UNLIKELY(glyph_priv->serial != glyph_atlas->serial)) {
                         if (!glamor_glyph_can_add(glyph_atlas, glyph_atlas_dim, glyph_draw)) {
                             if (glyphs_queued) {
-                                glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+                                glamor_glyphs_flush(op, src, dst, x_src, y_src, prog, glyph_atlas, glyphs_queued);
                                 glyphs_queued = 0;
                             }
                             if (glyph_atlas->atlas) {
@@ -478,7 +479,7 @@ glamor_composite_glyphs(CARD8 op,
     }
 
     if (glyphs_queued)
-        glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+        glamor_glyphs_flush(op, src, dst, x_src, y_src, prog, glyph_atlas, glyphs_queued);
 
     return;
 }
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index 8145cc1..d7df01d 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -488,7 +488,7 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
 }
 
 static Bool
-use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, int off_x, int off_y, glamor_program *prog)
 {
 
     glamor_set_blend(op, prog->alpha, dst);
@@ -507,12 +507,12 @@ const glamor_facet glamor_source_solid = {
 };
 
 static Bool
-use_source_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+use_source_picture(CARD8 op, PicturePtr src, PicturePtr dst, int off_x, int off_y, glamor_program *prog)
 {
     glamor_set_blend(op, prog->alpha, dst);
 
     return glamor_set_texture((PixmapPtr) src->pDrawable,
-                              0, 0,
+                              off_x, off_y,
                               prog->fill_offset_uniform,
                               prog->fill_size_inv_uniform);
 }
@@ -526,7 +526,7 @@ const glamor_facet glamor_source_picture = {
 };
 
 static Bool
-use_source_1x1_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+use_source_1x1_picture(CARD8 op, PicturePtr src, PicturePtr dst, int off_x, int off_y, glamor_program *prog)
 {
     glamor_set_blend(op, prog->alpha, dst);
 
@@ -647,14 +647,16 @@ Bool
 glamor_use_program_render(glamor_program        *prog,
                           CARD8                 op,
                           PicturePtr            src,
-                          PicturePtr            dst)
+                          PicturePtr            dst,
+                          int                   off_x,
+                          int                   off_y)
 {
     glUseProgram(prog->prog);
 
-    if (prog->prim_use_render && !prog->prim_use_render(op, src, dst, prog))
+    if (prog->prim_use_render && !prog->prim_use_render(op, src, dst, off_x, off_y, prog))
         return FALSE;
 
-    if (prog->fill_use_render && !prog->fill_use_render(op, src, dst, prog))
+    if (prog->fill_use_render && !prog->fill_use_render(op, src, dst, off_x, off_y, prog))
         return FALSE;
     return TRUE;
 }
diff --git a/glamor/glamor_program.h b/glamor/glamor_program.h
index 9e561cd..3c670d9 100644
--- a/glamor/glamor_program.h
+++ b/glamor/glamor_program.h
@@ -50,7 +50,7 @@ typedef struct _glamor_program glamor_program;
 
 typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
 
-typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
+typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, int off_x, int off_y, glamor_program *prog);
 
 typedef struct {
     const char                          *name;
@@ -148,6 +148,8 @@ Bool
 glamor_use_program_render(glamor_program        *prog,
                           CARD8                 op,
                           PicturePtr            src,
-                          PicturePtr            dst);
+                          PicturePtr            dst,
+                          int                   off_x,
+                          int                   off_y);
 
 #endif /* _GLAMOR_PROGRAM_H_ */
-- 
2.1.4



More information about the xorg-devel mailing list