diff options
author | Eric Anholt <eric@anholt.net> | 2016-02-01 13:58:04 -0800 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-03-10 11:12:42 -0500 |
commit | a96c6d4658e3f386002f96eede660af3b01e5209 (patch) | |
tree | f761f530c16743c9fba4f3cec965030054e0fa50 | |
parent | 25ce263fd88684be9370025f93ba3a2bfc72ff1a (diff) |
glamor: Simplify temporary picture uploading call stack.
glamor_upload_sub_pixmap_to_texture() only had the one caller, so we
can merge it in, fix its silly return value, and propagate a bunch of
constants.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | glamor/glamor_picture.c | 68 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 18 | ||||
-rw-r--r-- | glamor/glamor_render.c | 27 |
3 files changed, 37 insertions, 76 deletions
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c index b069ce56b..e91461cc9 100644 --- a/glamor/glamor_picture.c +++ b/glamor/glamor_picture.c @@ -797,11 +797,15 @@ glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits, } } -static Bool -glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, - int h, int stride, void *bits, int pbo, - PictFormatShort pict_format) +/* Upload picture to texture. We may need to flip the y axis or + * wire alpha to 1. So we may conditional create fbo for the picture. + * */ +Bool +glamor_upload_picture_to_texture(PicturePtr picture) { + PixmapPtr pixmap = glamor_get_drawable_pixmap(picture->pDrawable); + void *bits = pixmap->devPrivate.ptr; + int stride = pixmap->devKind; ScreenPtr screen = pixmap->drawable.pScreen; glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); GLenum format, type; @@ -810,7 +814,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, Bool force_clip; if (glamor_get_tex_format_type_from_pixmap(pixmap, - pict_format, + picture->format, &format, &type, &no_alpha, @@ -822,8 +826,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, return FALSE; pixmap_priv = glamor_get_pixmap_private(pixmap); - force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP - && !glamor_check_fbo_size(glamor_priv, w, h); + force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP; if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) { RegionRec region; @@ -833,13 +836,13 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, void *sub_bits; int i, j; - sub_bits = xallocarray(h, stride); + sub_bits = xallocarray(pixmap->drawable.height, stride); if (sub_bits == NULL) return FALSE; - box.x1 = x; - box.y1 = y; - box.x2 = x + w; - box.y2 = y + h; + box.x1 = 0; + box.y1 = 0; + box.x2 = pixmap->drawable.width; + box.y2 = pixmap->drawable.height; RegionInitBoxes(®ion, &box, 1); if (!force_clip) clipped_regions = @@ -860,8 +863,6 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int temp_stride; void *temp_bits; - assert(pbo == 0); - glamor_set_pixmap_fbo_current(pixmap_priv, clipped_regions[i].block_idx); boxes = RegionRects(clipped_regions[i].region); @@ -871,26 +872,26 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1, pixmap->drawable.depth); - if (boxes[j].x1 == x && temp_stride == stride) { - temp_bits = (char *) bits + (boxes[j].y1 - y) * stride; + if (boxes[j].x1 == 0 && temp_stride == stride) { + temp_bits = (char *) bits + boxes[j].y1 * stride; } else { temp_bits = sub_bits; glamor_put_bits(temp_bits, temp_stride, bits, stride, pixmap->drawable.bitsPerPixel, - boxes[j].x1 - x, boxes[j].y1 - y, + boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1, boxes[j].y2 - boxes[j].y1); } DEBUGF("upload x %d y %d w %d h %d temp stride %d \n", - boxes[j].x1 - x, boxes[j].y1 - y, + boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1, boxes[j].y2 - boxes[j].y1, temp_stride); if (_glamor_upload_bits_to_pixmap_texture (pixmap, format, type, no_alpha, revert, swap_rb, boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1, boxes[j].y2 - boxes[j].y1, temp_stride, temp_bits, - pbo) == FALSE) { + 0) == FALSE) { RegionUninit(®ion); free(sub_bits); assert(0); @@ -907,28 +908,9 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, else return _glamor_upload_bits_to_pixmap_texture(pixmap, format, type, no_alpha, revert, swap_rb, - x, y, w, h, stride, bits, - pbo); -} - -/* Upload picture to texture. We may need to flip the y axis or - * wire alpha to 1. So we may conditional create fbo for the picture. - * */ -enum glamor_pixmap_status -glamor_upload_picture_to_texture(PicturePtr picture) -{ - PixmapPtr pixmap; - - assert(picture->pDrawable); - pixmap = glamor_get_drawable_pixmap(picture->pDrawable); - - if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0, - pixmap->drawable.width, - pixmap->drawable.height, - pixmap->devKind, - pixmap->devPrivate.ptr, 0, - picture->format)) - return GLAMOR_UPLOAD_DONE; - else - return GLAMOR_UPLOAD_FAILED; + 0, 0, + pixmap->drawable.width, + pixmap->drawable.height, + stride, bits, + 0); } diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index a70f10eb4..422b0fdc8 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -514,22 +514,6 @@ glamor_pixmap_hcnt(glamor_pixmap_private *priv) for (box_index = 0; box_index < glamor_pixmap_hcnt(priv) * \ glamor_pixmap_wcnt(priv); box_index++) \ -/** - * Pixmap upload status, used by glamor_render.c's support for - * temporarily uploading pixmaps to GL textures to get a Composite - * operation done. - */ -typedef enum glamor_pixmap_status { - /** initial status, don't need to do anything. */ - GLAMOR_NONE, - /** marked as need to be uploaded to gl texture. */ - GLAMOR_UPLOAD_PENDING, - /** the pixmap has been uploaded successfully. */ - GLAMOR_UPLOAD_DONE, - /** fail to upload the pixmap. */ - GLAMOR_UPLOAD_FAILED -} glamor_pixmap_status_t; - /* GC private structure. Currently holds only any computed dash pixmap */ typedef struct { @@ -739,7 +723,7 @@ Bool glamor_composite_largepixmap_region(CARD8 op, * Upload a picture to gl texture. Similar to the * glamor_upload_pixmap_to_texture. Used in rendering. **/ -enum glamor_pixmap_status glamor_upload_picture_to_texture(PicturePtr picture); +Bool glamor_upload_picture_to_texture(PicturePtr picture); void glamor_add_traps(PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntrap, xTrap *traps); diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 73ac831ee..d47e7d729 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -788,8 +788,8 @@ glamor_composite_choose_shader(CARD8 op, { ScreenPtr screen = dest->pDrawable->pScreen; glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); - enum glamor_pixmap_status source_status = GLAMOR_NONE; - enum glamor_pixmap_status mask_status = GLAMOR_NONE; + Bool source_needs_upload = FALSE; + Bool mask_needs_upload = FALSE; PictFormatShort saved_source_format = 0; struct shader_key key; GLfloat source_solid_color[4]; @@ -900,7 +900,7 @@ glamor_composite_choose_shader(CARD8 op, } if (source_pixmap_priv->gl_fbo == GLAMOR_FBO_UNATTACHED) { #ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD - source_status = GLAMOR_UPLOAD_PENDING; + source_needs_upload = TRUE; #else glamor_fallback("no texture in source\n"); goto fail; @@ -916,7 +916,7 @@ glamor_composite_choose_shader(CARD8 op, } if (mask_pixmap_priv->gl_fbo == GLAMOR_FBO_UNATTACHED) { #ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD - mask_status = GLAMOR_UPLOAD_PENDING; + mask_needs_upload = TRUE; #else glamor_fallback("no texture in mask\n"); goto fail; @@ -925,8 +925,7 @@ glamor_composite_choose_shader(CARD8 op, } #ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD - if (source_status == GLAMOR_UPLOAD_PENDING - && mask_status == GLAMOR_UPLOAD_PENDING + if (source_needs_upload && mask_needs_upload && source_pixmap == mask_pixmap) { if (source->format != mask->format) { @@ -962,20 +961,17 @@ glamor_composite_choose_shader(CARD8 op, if (!PICT_FORMAT_A(mask->format) && PICT_FORMAT_A(saved_source_format)) key.mask = SHADER_MASK_TEXTURE; - - mask_status = GLAMOR_NONE; } - source_status = glamor_upload_picture_to_texture(source); - if (source_status != GLAMOR_UPLOAD_DONE) { + if (!glamor_upload_picture_to_texture(source)) { glamor_fallback("Failed to upload source texture.\n"); goto fail; } + mask_needs_upload = FALSE; } else { - if (source_status == GLAMOR_UPLOAD_PENDING) { - source_status = glamor_upload_picture_to_texture(source); - if (source_status != GLAMOR_UPLOAD_DONE) { + if (source_needs_upload) { + if (!glamor_upload_picture_to_texture(source)) { glamor_fallback("Failed to upload source texture.\n"); goto fail; } @@ -986,9 +982,8 @@ glamor_composite_choose_shader(CARD8 op, } } - if (mask_status == GLAMOR_UPLOAD_PENDING) { - mask_status = glamor_upload_picture_to_texture(mask); - if (mask_status != GLAMOR_UPLOAD_DONE) { + if (mask_needs_upload) { + if (!glamor_upload_picture_to_texture(mask)) { glamor_fallback("Failed to upload mask texture.\n"); goto fail; } |