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

Unified Diff: cc/output/gl_renderer.cc

Issue 614953002: Accelerate the lighten blendmode if GL_EXT_blend_minmax is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add IsDefaultBlendMode Created 6 years, 2 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/gl_renderer.h ('k') | content/common/gpu/gpu_messages.h » ('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 0a897f39432a1cb94c3c4bc02805ac02de71d010..67c8d518cbf4d13f5b8210789fb789c1724eb83f 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -338,6 +338,7 @@ GLRenderer::GLRenderer(RendererClient* client,
capabilities_.allow_rasterize_on_demand = true;
use_sync_query_ = context_caps.gpu.sync_query;
+ use_blend_minmax = context_caps.gpu.blend_minmax;
InitializeSharedObjects();
}
@@ -701,21 +702,32 @@ static skia::RefPtr<SkImage> ApplyImageFilter(
return image;
}
-bool GLRenderer::ShouldApplyBlendModeUsingBlendFunc(const DrawQuad* quad) {
- SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
- return blend_mode == SkXfermode::kScreen_Mode ||
+bool GLRenderer::CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) {
+ return (use_blend_minmax && blend_mode == SkXfermode::kLighten_Mode) ||
+ blend_mode == SkXfermode::kScreen_Mode ||
blend_mode == SkXfermode::kSrcOver_Mode;
}
-void GLRenderer::ApplyBlendModeUsingBlendFunc(const DrawQuad* quad) {
- DCHECK(ShouldApplyBlendModeUsingBlendFunc(quad));
- if (quad->shared_quad_state->blend_mode == SkXfermode::kScreen_Mode) {
+void GLRenderer::ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) {
+ DCHECK(CanApplyBlendModeUsingBlendFunc(blend_mode));
+
+ // Any modes set here must be reset in RestoreBlendFuncToDefault
+ if (blend_mode == SkXfermode::kScreen_Mode) {
GLC(gl_, gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE));
+ } else if (blend_mode == SkXfermode::kLighten_Mode) {
+ GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE));
+ GLC(gl_, gl_->BlendEquation(GL_MAX_EXT));
}
}
-void GLRenderer::RestoreBlendFuncToDefault() {
+void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) {
+ if (blend_mode == SkXfermode::kSrcOver_Mode)
+ return;
+
GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
+
+ if (blend_mode == SkXfermode::kLighten_Mode)
+ GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
}
static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop(
@@ -991,8 +1003,10 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassDrawQuad* quad) {
+ SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
SetBlendEnabled(quad->ShouldDrawWithBlending() ||
- ShouldApplyBlendModeUsingBlendFunc(quad));
+ (!IsDefaultBlendMode(blend_mode) &&
+ CanApplyBlendModeUsingBlendFunc(blend_mode)));
ScopedResource* contents_texture =
render_pass_textures_.get(quad->render_pass_id);
@@ -1011,7 +1025,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
if (!contents_device_transform.GetInverse(&contents_device_transform_inverse))
return;
- bool need_background_texture = !ShouldApplyBlendModeUsingBlendFunc(quad) ||
+ bool need_background_texture = !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
!quad->background_filters.IsEmpty();
bool background_changed = false;
scoped_ptr<ScopedResource> background_texture;
@@ -1066,7 +1080,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
}
}
- if (background_texture && !ShouldApplyBlendModeUsingBlendFunc(quad)) {
+ if (background_texture && !CanApplyBlendModeUsingBlendFunc(blend_mode)) {
enne (OOO) 2014/10/07 17:51:17 I think this CanApplyBlendModeUsingBlendFunc check
Erik Dahlström (inactive) 2014/10/08 15:25:20 No, I don't think it's redundant, have a look at t
filter_bitmap =
ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame),
resource_provider_,
@@ -1134,8 +1148,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
contents_resource_lock->target());
}
- if (ShouldApplyBlendModeUsingBlendFunc(quad))
- ApplyBlendModeUsingBlendFunc(quad);
+ if (CanApplyBlendModeUsingBlendFunc(blend_mode))
+ ApplyBlendModeUsingBlendFunc(blend_mode);
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
gl_,
@@ -1384,8 +1398,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
if (filter_bitmap)
GLC(gl_, gl_->Flush());
- if (ShouldApplyBlendModeUsingBlendFunc(quad))
- RestoreBlendFuncToDefault();
+ if (CanApplyBlendModeUsingBlendFunc(blend_mode))
+ RestoreBlendFuncToDefault(blend_mode);
}
struct SolidColorProgramUniforms {
« no previous file with comments | « cc/output/gl_renderer.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698