cc: optimize color matrix application for more complex filter DAGs.
We previously optimized the case where a filter DAG consisted of a
single SkColorFilterImageFilter containing an SkColorMatrixFilter.
Here we extend it to support any DAG with such a filter at its root,
call skia to process the rest of the DAG, and apply the matrix in cc's
RenderSurface draw pass.
BUG=609897
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review-Url: https://codereview.chromium.org/1961553002
Cr-Commit-Position: refs/heads/master@{#392134}
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 5b14633..bc35463d 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -1008,11 +1008,14 @@
filter->asColorFilter(&colorfilter_rawptr);
sk_sp<SkColorFilter> cf(colorfilter_rawptr);
- if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
- // We have a single color matrix as a filter; apply it locally
- // in the compositor.
+ if (cf && cf->asColorMatrix(color_matrix)) {
+ // We have a color matrix at the root of the filter DAG; apply it
+ // locally in the compositor and process the rest of the DAG (if any)
+ // in Skia.
use_color_matrix = true;
- } else {
+ filter = sk_ref_sp(filter->getInput(0));
+ }
+ if (filter) {
gfx::Vector2dF scale = quad->filters_scale;
SkMatrix scale_matrix;
scale_matrix.setScale(scale.x(), scale.y());