Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: src/core/SkSpecialImage.cpp

Issue 2155063002: use special-image for imagefilters and save/restore layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: can't assert in snapSpecial (for backdrops) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« src/core/SkCanvas.cpp ('K') | « src/core/SkCanvas.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698