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

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: address comments 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpecialImage.cpp
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 8875d2248ff6c1035c6ce940dfa3f5b2c1796583..e3a14e57abde5ff8016d98ebbeb41b08d2082f8a 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -18,6 +18,13 @@
#include "SkSpecialSurface.h"
#include "SkSurfacePriv.h"
+// Currently the raster imagefilters can only handle certain imageinfos. Call this to know if
+// a given info is supported.
+static bool valid_for_imagefilters(const SkImageInfo& info) {
+ // no support for other swizzles/depths yet
+ return info.colorType() == kN32_SkColorType;
+}
+
///////////////////////////////////////////////////////////////////////////////
class SkSpecialImage_Base : public SkSpecialImage {
public:
@@ -315,7 +322,11 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
- 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 +423,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;
+ // ImageFilters only handle N32 at the moment, so force 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698