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

Unified Diff: cc/output/gl_renderer.cc

Issue 2936343002: Add support to GLRenderer for different blending for solid color quads (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 5d5afdf1b2edbcc668e8818cb7ddcdfe0cd748c9..89c2c75edb69423dfe574728572c3f5dc99b2c5f 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -711,6 +711,8 @@ void GLRenderer::ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode) {
// Left no-op intentionally.
} else if (blend_mode == SkBlendMode::kDstIn) {
gl_->BlendFunc(GL_ZERO, GL_SRC_ALPHA);
+ } else if (blend_mode == SkBlendMode::kDstOut) {
+ gl_->BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
} else if (blend_mode == SkBlendMode::kScreen) {
gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
} else {
@@ -776,6 +778,7 @@ void GLRenderer::RestoreBlendFuncToDefault(SkBlendMode blend_mode) {
case SkBlendMode::kSrcOver:
break;
case SkBlendMode::kDstIn:
+ case SkBlendMode::kDstOut:
case SkBlendMode::kScreen:
gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break;
@@ -1734,7 +1737,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
// Early out if alpha is small enough that quad doesn't contribute to output.
if (alpha < std::numeric_limits<float>::epsilon() &&
- quad->ShouldDrawWithBlending())
+ quad->ShouldDrawWithBlending() &&
+ quad->shared_quad_state->blend_mode == SkBlendMode::kSrcOver)
return;
gfx::Transform device_transform =
@@ -1781,6 +1785,7 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
// Enable blending when the quad properties require it or if we decided
// to use antialiasing.
SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
+ ApplyBlendModeUsingBlendFunc(quad->shared_quad_state->blend_mode);
// Antialising requires a normalized quad, but this could lead to floating
// point precision errors, so only normalize when antialising is on.
@@ -1808,6 +1813,7 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
quad->shared_quad_state->quad_to_target_transform);
gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
}
+ RestoreBlendFuncToDefault(quad->shared_quad_state->blend_mode);
}
void GLRenderer::DrawTileQuad(const TileDrawQuad* quad,
« no previous file with comments | « no previous file | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698