Fix sprite blitter choice logic
While we're asking if there are any color space xform steps to do,
let's look at all 5 of them, including whether we need to unpremul or
premul. The sprite blitter paths this logic guards can't handle
any change in color space _or_ alpha type, so this is a perfect fit.
Without this fix, we'd happily draw premul into unpremul using memcpy().
(Unpremul -> premul was already guarded by the check with my new note.)
Change-Id: Ic8d9e69f6c7bd2902ff77393de1da9cd940ea826
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257657
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp
index 89b107b..6ae7893 100644
--- a/src/core/SkBlitter_Sprite.cpp
+++ b/src/core/SkBlitter_Sprite.cpp
@@ -57,7 +57,7 @@
public:
static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint& paint) {
// the caller has already inspected the colorspace on src and dst
- SkASSERT(!SkColorSpaceXformSteps::Required(src.colorSpace(), dst.colorSpace()));
+ SkASSERT(0 == SkColorSpaceXformSteps(src,dst).flags.mask());
if (dst.colorType() != src.colorType()) {
return false;
@@ -178,13 +178,14 @@
*/
SkASSERT(allocator != nullptr);
+ // TODO: in principle SkRasterPipelineSpriteBlitter could be made to handle this.
if (source.alphaType() == kUnpremul_SkAlphaType) {
return nullptr;
}
SkSpriteBlitter* blitter = nullptr;
- if (!SkColorSpaceXformSteps::Required(source.colorSpace(), dst.colorSpace())) {
+ if (0 == SkColorSpaceXformSteps(source,dst).flags.mask()) {
if (!blitter && SkSpriteBlitter_Memcpy::Supports(dst, source, paint)) {
blitter = allocator->make<SkSpriteBlitter_Memcpy>(source);
}