SkColorSpaceXformer: Preserve local matrix on shaders
authorMatt Sarett <msarett@google.com>
Wed, 12 Apr 2017 13:19:15 +0000 (09:19 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 12 Apr 2017 13:52:10 +0000 (13:52 +0000)
Also, do not drop unknown shaders.

Fixes cts tests.

b/37161109
b/37237678

Bug: skia:
Change-Id: I0fd817a4d6461ede0ccdcb8f3cccb255b646b864
Reviewed-on: https://skia-review.googlesource.com/13246
Commit-Queue: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
src/core/SkColorSpaceXformer.cpp

index 38e717d..fe66e74 100644 (file)
@@ -71,7 +71,8 @@ SkColor SkColorSpaceXformer::apply(SkColor srgb) {
 sk_sp<SkShader> SkColorSpaceXformer::apply(const SkShader* shader) {
     SkColor color;
     if (shader->isConstant() && shader->asLuminanceColor(&color)) {
-        return SkShader::MakeColorShader(this->apply(color));
+        return SkShader::MakeColorShader(this->apply(color))
+                ->makeWithLocalMatrix(shader->getLocalMatrix());
     }
 
     SkShader::TileMode xy[2];
@@ -85,7 +86,8 @@ sk_sp<SkShader> SkColorSpaceXformer::apply(const SkShader* shader) {
         auto A = this->apply(compose.fShaderA),
              B = this->apply(compose.fShaderB);
         if (A && B) {
-            return SkShader::MakeComposeShader(std::move(A), std::move(B), compose.fBlendMode);
+            return SkShader::MakeComposeShader(std::move(A), std::move(B), compose.fBlendMode)
+                    ->makeWithLocalMatrix(shader->getLocalMatrix());
         }
     }
 
@@ -147,7 +149,7 @@ sk_sp<SkShader> SkColorSpaceXformer::apply(const SkShader* shader) {
         }
     }
 
-    return nullptr;
+    return sk_ref_sp(const_cast<SkShader*>(shader));
 }
 
 const SkPaint& SkColorSpaceXformer::apply(const SkPaint& src) {