diff options
author | 2017-02-14 11:21:02 -0500 | |
---|---|---|
committer | 2017-02-14 17:50:52 +0000 | |
commit | 8572d853514e3c73077540341edbf62a3f486605 (patch) | |
tree | 66341d4ede6a9532d30142a68301e6c04c92cdab /src/core/SkImageInfoPriv.h | |
parent | 4bf560a056d7ba5b3051ebc87e687d4997928ff6 (diff) |
Make raster pipeline support all pixel conversions
BUG=skia:
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: Idc76999d0f5591a567b3976cb9db829c350e4be2
Reviewed-on: https://skia-review.googlesource.com/8304
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/core/SkImageInfoPriv.h')
-rw-r--r-- | src/core/SkImageInfoPriv.h | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/core/SkImageInfoPriv.h b/src/core/SkImageInfoPriv.h index 40209f8946..855e506bb2 100644 --- a/src/core/SkImageInfoPriv.h +++ b/src/core/SkImageInfoPriv.h @@ -19,6 +19,11 @@ static inline bool SkImageInfoIsValid(const SkImageInfo& info) { return false; } + const int kMaxDimension = SK_MaxS32 >> 2; + if (info.width() > kMaxDimension || info.height() > kMaxDimension) { + return false; + } + if (kUnknown_SkColorType == info.colorType() || kUnknown_SkAlphaType == info.alphaType()) { return false; } @@ -44,8 +49,8 @@ static inline bool SkImageInfoIsValid(const SkImageInfo& info) { /** * Returns true if Skia has defined a pixel conversion from the |src| to the |dst|. * Returns false otherwise. Some discussion of false cases: - * We will not convert to kIndex8 when the |src| is not kIndex8 in the same color space - * (color tables are immutable). + * We will not convert to kIndex8 unless it exactly matches the src, since color tables + * are immutable. * We do not convert to kGray8 when the |src| is not kGray8 in the same color space. * We may add this feature - it just requires some work to convert to luminance while * handling color spaces correctly. Currently no one is asking for this. @@ -64,16 +69,30 @@ static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkIm return false; } - if (kIndex_8_SkColorType == dst.colorType() && kIndex_8_SkColorType != src.colorType() && - dst.colorSpace() && !SkColorSpace::Equals(dst.colorSpace(), src.colorSpace())) - { - return false; + if (kIndex_8_SkColorType == dst.colorType()) { + if (kIndex_8_SkColorType != src.colorType()) { + return false; + } + + if ((kPremul_SkAlphaType == dst.alphaType() && kUnpremul_SkAlphaType == src.alphaType()) || + (kUnpremul_SkAlphaType == dst.alphaType() && kPremul_SkAlphaType == src.alphaType())) + { + return false; + } + + if (dst.colorSpace() && !SkColorSpace::Equals(dst.colorSpace(), src.colorSpace())) { + return false; + } } - if (kGray_8_SkColorType == dst.colorType() && kGray_8_SkColorType != src.colorType() && - dst.colorSpace() && !SkColorSpace::Equals(dst.colorSpace(), src.colorSpace())) - { - return false; + if (kGray_8_SkColorType == dst.colorType()) { + if (kGray_8_SkColorType != src.colorType()) { + return false; + } + + if (dst.colorSpace() && !SkColorSpace::Equals(dst.colorSpace(), src.colorSpace())) { + return false; + } } if (kAlpha_8_SkColorType != dst.colorType() && kAlpha_8_SkColorType == src.colorType()) { |