no sprite blitters support gamut conversion

This fixes the None/Low bitmap filtering in gamut GM.

BUG=skia:6679

Change-Id: Ic6e0efa6a23b537aea69b4beb24f3c8b8c6ca347
Reviewed-on: https://skia-review.googlesource.com/17923
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Klein 2017-05-25 09:27:18 -04:00 committed by Skia Commit-Bot
parent d1f08302aa
commit 5addedd59d

View File

@ -6,6 +6,7 @@
*/
#include "SkArenaAlloc.h"
#include "SkColorSpace_Base.h"
#include "SkOpts.h"
#include "SkSpriteBlitter.h"
@ -137,6 +138,15 @@ private:
bool fUseMemcpy {true};
};
// Returns the hash of the color space gamut if we can, or sRGB's gamut hash if we can't.
static uint32_t safe_gamut_hash(SkColorSpace* cs) {
if (!cs) {
static const uint32_t srgb_hash = as_CSB(SkColorSpace::MakeSRGB())->toXYZD50Hash();
return srgb_hash;
}
return as_CSB(cs)->toXYZD50Hash();
}
// returning null means the caller will call SkBlitter::Choose() and
// have wrapped the source bitmap inside a shader
SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
@ -152,6 +162,11 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
*/
SkASSERT(allocator != nullptr);
// No sprite blitters support gamut conversion.
if (safe_gamut_hash(source.colorSpace()) != safe_gamut_hash(dst.colorSpace())) {
return nullptr;
}
// Defer to the general code if the pixels are unpremultipled. This case is not common,
// and this simplifies the code.
if (source.alphaType() == kUnpremul_SkAlphaType) {