SkPDF/Device/ImageFilter: Fix ImageFilter fallback code
authorhalcanary <halcanary@google.com>
Wed, 15 Apr 2015 20:05:18 +0000 (13:05 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 15 Apr 2015 20:05:18 +0000 (13:05 -0700)
Broken in https://chromium.googlesource.com/skia/+/76033be

I have confirmed that this fixes 470083.

BUG=470083

Review URL: https://codereview.chromium.org/1080923004

include/core/SkDevice.h
src/core/SkDeviceImageFilterProxy.h
src/pdf/SkPDFDevice.cpp

index 99c29ee2e3549bfa6701d5d0304f213a833356f2..ec5771175436906f47071fdd51e1e0e97c6bd477 100644 (file)
@@ -330,15 +330,19 @@ protected:
         static SkPixelGeometry AdjustGeometry(const SkImageInfo&, TileUsage, SkPixelGeometry);
 
         // The constructor may change the pixel geometry based on other parameters.
-        CreateInfo(const SkImageInfo& info, TileUsage tileUsage, SkPixelGeometry geo)
+        CreateInfo(const SkImageInfo& info,
+                   TileUsage tileUsage,
+                   SkPixelGeometry geo,
+                   bool forImageFilter = false)
             : fInfo(info)
             , fTileUsage(tileUsage)
             , fPixelGeometry(AdjustGeometry(info, tileUsage, geo))
-        {}
+            , fForImageFilter(forImageFilter) {}
 
         const SkImageInfo       fInfo;
         const TileUsage         fTileUsage;
         const SkPixelGeometry   fPixelGeometry;
+        const bool              fForImageFilter;
     };
 
     /**
index 06df759bc3cf062c1833211438a4f33b31642158..dcf12f7c4016d1564f92a9cd707c6ca68b3cabbe 100644 (file)
@@ -22,7 +22,8 @@ public:
     SkBaseDevice* createDevice(int w, int h) override {
         SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h),
                                        SkBaseDevice::kNever_TileUsage,
-                                       kUnknown_SkPixelGeometry);
+                                       kUnknown_SkPixelGeometry,
+                                       true /*forImageFilter*/);
         return fDevice->onCreateDevice(cinfo, NULL);
     }
     bool canHandleImageFilter(const SkImageFilter* filter) override {
index 5167474f106295cc15808104801308d7d256e1eb..1b16397512a834ff89d65f97fe0644e9888c6ef8 100644 (file)
@@ -577,7 +577,8 @@ static bool not_supported_for_layers(const SkPaint& layerPaint) {
 }
 
 SkBaseDevice* SkPDFDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint* layerPaint) {
-    if (layerPaint && not_supported_for_layers(*layerPaint)) {
+    if (cinfo.fForImageFilter ||
+        (layerPaint && not_supported_for_layers(*layerPaint))) {
         return SkBitmapDevice::Create(cinfo.fInfo);
     }
     SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height());