Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Unified Diff: cc/output/software_renderer.cc

Issue 18432002: Blend TextureLayer background-color at draw time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: implemented software renderer Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/software_renderer.cc
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index e7273a8c12cd1bddee6756b6ade8434564aa8cd5..f4093016c27469b100d4f3ac14c9867ca2762a69 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -352,11 +352,31 @@ void SoftwareRenderer::DrawTextureQuad(const DrawingFrame* frame,
bitmap->width(),
bitmap->height());
SkRect sk_uv_rect = gfx::RectFToSkRect(uv_rect);
+ SkRect quad_rect = gfx::RectFToSkRect(QuadVertexRect());
+
if (quad->flipped)
current_canvas_->scale(1, -1);
- current_canvas_->drawBitmapRectToRect(*bitmap, &sk_uv_rect,
- gfx::RectFToSkRect(QuadVertexRect()),
+
+ bool blend_background = (SkColorGetA(quad->background_color) != 0) &&
+ !bitmap->isOpaque();
+ bool needs_layer = blend_background && (current_paint_.getAlpha() != 0xFF);
alokp 2013/07/09 00:08:06 reed@: Is there a paint mode in skia that will avo
+ if (needs_layer) {
+ current_canvas_->saveLayerAlpha(&quad_rect, current_paint_.getAlpha());
+ current_paint_.setAlpha(0xFF);
+ }
+ if (blend_background) {
+ SkPaint background_paint;
+ background_paint.setColor(quad->background_color);
+ current_canvas_->drawRect(quad_rect, background_paint);
+ }
+
+ current_canvas_->drawBitmapRectToRect(*bitmap,
+ &sk_uv_rect,
+ quad_rect,
&current_paint_);
+
+ if (needs_layer)
+ current_canvas_->restore();
}
void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame,
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698