Chromium Code Reviews| Index: src/core/SkSpecialImage.cpp |
| diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp |
| index 8875d2248ff6c1035c6ce940dfa3f5b2c1796583..0e23f5ee18df6caf0603f37ce8f006141a97b2b8 100644 |
| --- a/src/core/SkSpecialImage.cpp |
| +++ b/src/core/SkSpecialImage.cpp |
| @@ -18,6 +18,10 @@ |
| #include "SkSpecialSurface.h" |
| #include "SkSurfacePriv.h" |
|
robertphillips
2016/07/20 12:20:05
// The raster-specific image filters are written s
|
| +static bool valid_for_imagefilters(const SkImageInfo& info) { |
| + return info.colorType() == kN32_SkColorType; |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| class SkSpecialImage_Base : public SkSpecialImage { |
| public: |
| @@ -315,7 +319,11 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset, |
| const SkSurfaceProps* props) { |
| SkASSERT(rect_fits(subset, image->width(), image->height())); |
|
robertphillips
2016/07/20 12:20:05
GPU-backed SkImages should work fine
|
| - return sk_make_sp<SkSpecialImage_Image>(subset, image, props); |
| + if (valid_for_imagefilters(as_IB(image.get())->onImageInfo())) { |
| + return sk_make_sp<SkSpecialImage_Image>(subset, image, props); |
| + } else { |
| + return nullptr; |
| + } |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -412,7 +420,16 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset, |
| SkASSERT(nullptr == bm.getTexture()); |
| SkASSERT(rect_fits(subset, bm.width(), bm.height())); |
| - return sk_make_sp<SkSpecialImage_Raster>(subset, bm, props); |
| + const SkBitmap* srcBM = &bm; |
| + SkBitmap tmpStorage; |
|
robertphillips
2016/07/20 12:20:05
for -> force
reed1
2016/07/20 12:41:53
Done.
|
| + // ImageFilters only handle N32 at the moment, so for our src to be that |
| + if (!valid_for_imagefilters(bm.info())) { |
| + if (!bm.copyTo(&tmpStorage, kN32_SkColorType)) { |
| + return nullptr; |
| + } |
| + srcBM = &tmpStorage; |
| + } |
| + return sk_make_sp<SkSpecialImage_Raster>(subset, *srcBM, props); |
| } |
| #if SK_SUPPORT_GPU |