aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-06-04 13:27:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-04 13:27:10 -0700
commita4e4b798a5d46a5acbcb44ef094f626b64d39467 (patch)
treef844bf9c7a029350d94cedc139cc5bd9544ba2da
parent85994fb62e0a0ad6191d30641a35a5e240ae1bd7 (diff)
Add the ability to handle premul and swizzle src bitmap data.
-rw-r--r--src/core/SkBitmapProcShader.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index a372b51990..f88729e305 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -205,7 +205,10 @@ private:
static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImageInfo& srcInfo) {
// If we get here, we can reasonably use either context, respect the caller's preference
//
- return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType;
+ bool needsPremul = srcInfo.alphaType() == kUnpremul_SkAlphaType;
+ bool needsSwizzle = srcInfo.bytesPerPixel() == 4 && srcInfo.colorType() != kN32_SkColorType;
+ return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType
+ || needsPremul || needsSwizzle;
}
size_t SkBitmapProcShader::ContextSize(const ContextRec& rec, const SkImageInfo& srcInfo) {