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

Unified Diff: cc/output/gl_renderer.cc

Issue 643373003: Add support for all blendmodes if we have GL_KHR_blend_equation_advanced. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing test 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
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index ac449a46f5df84bc66ffe091b6470f8c6a394cb9..da8996a83d2d876bce38fe94ccb7670a75220d77 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -339,6 +339,7 @@ GLRenderer::GLRenderer(RendererClient* client,
use_sync_query_ = context_caps.gpu.sync_query;
use_blend_minmax_ = context_caps.gpu.blend_minmax;
+ use_blend_equation_advanced_ = context_caps.gpu.blend_equation_advanced;
InitializeSharedObjects();
}
@@ -700,20 +701,77 @@ static skia::RefPtr<SkImage> ApplyImageFilter(
}
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;
+ return use_blend_equation_advanced_ ||
+ (use_blend_minmax_ && blend_mode == SkXfermode::kLighten_Mode) ||
+ blend_mode == SkXfermode::kScreen_Mode ||
+ blend_mode == SkXfermode::kSrcOver_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));
+ if (use_blend_equation_advanced_) {
+ GLenum equation = GL_SRC_OVER_NV;
+
+ switch (blend_mode) {
+ case SkXfermode::kScreen_Mode:
piman 2014/10/16 20:13:28 nit: indent style (run git cl format?)
Erik Dahlström (inactive) 2014/10/17 15:33:17 Done.
+ equation = GL_SCREEN_NV;
+ break;
+ case SkXfermode::kOverlay_Mode:
+ equation = GL_OVERLAY_NV;
+ break;
+ case SkXfermode::kDarken_Mode:
+ equation = GL_DARKEN_NV;
+ break;
+ case SkXfermode::kLighten_Mode:
+ equation = GL_LIGHTEN_NV;
+ break;
+ case SkXfermode::kColorDodge_Mode:
+ equation = GL_COLORDODGE_NV;
+ break;
+ case SkXfermode::kColorBurn_Mode:
+ equation = GL_COLORBURN_NV;
+ break;
+ case SkXfermode::kHardLight_Mode:
+ equation = GL_HARDLIGHT_NV;
+ break;
+ case SkXfermode::kSoftLight_Mode:
+ equation = GL_SOFTLIGHT_NV;
+ break;
+ case SkXfermode::kDifference_Mode:
+ equation = GL_DIFFERENCE_NV;
+ break;
+ case SkXfermode::kExclusion_Mode:
+ equation = GL_EXCLUSION_NV;
+ break;
+ case SkXfermode::kMultiply_Mode:
+ equation = GL_MULTIPLY_NV;
+ break;
+ case SkXfermode::kHue_Mode:
+ equation = GL_HSL_HUE_NV;
+ break;
+ case SkXfermode::kSaturation_Mode:
+ equation = GL_HSL_SATURATION_NV;
+ break;
+ case SkXfermode::kColor_Mode:
+ equation = GL_HSL_COLOR_NV;
+ break;
+ case SkXfermode::kLuminosity_Mode:
+ equation = GL_HSL_LUMINOSITY_NV;
+ break;
+ default:
+ return;
+ }
+
+ GLC(gl_, gl_->BlendEquation(equation));
+ } else {
+ 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));
+ }
}
}
@@ -721,10 +779,14 @@ 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 (use_blend_equation_advanced_) {
+ GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
+ } else {
+ GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
- if (blend_mode == SkXfermode::kLighten_Mode)
- GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
+ if (blend_mode == SkXfermode::kLighten_Mode)
+ GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
+ }
}
static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop(
@@ -1194,8 +1256,12 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
contents_resource_lock->target());
}
- if (CanApplyBlendModeUsingBlendFunc(blend_mode))
- ApplyBlendModeUsingBlendFunc(blend_mode);
+ if (CanApplyBlendModeUsingBlendFunc(blend_mode)) {
+ if (use_blend_equation_advanced_)
+ GLC(gl_, gl_->BlendBarrierNV());
piman 2014/10/16 20:13:29 Is it worth skipping this if we have GL_*_blend_eq
Erik Dahlström (inactive) 2014/10/17 15:33:17 Perhaps, my current card/driver setup doesn't supp
+
+ ApplyBlendModeUsingBlendFunc(blend_mode);
+ }
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
gl_,

Powered by Google App Engine
This is Rietveld 408576698