Chromium Code Reviews| Index: src/pdf/SkPDFDevice.cpp |
| diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp |
| index 7c366cdae7a6159d3605e127720b0bc263f4e295..3f35d455c47963de3190bac568c1a6fc7358e32d 100644 |
| --- a/src/pdf/SkPDFDevice.cpp |
| +++ b/src/pdf/SkPDFDevice.cpp |
| @@ -542,10 +542,12 @@ static bool not_supported_for_layers(const SkPaint& layerPaint) { |
| return layerPaint.getImageFilter() != nullptr; |
| } |
|
robertphillips
2016/07/15 15:07:22
Move this to the top ?
reed1
2016/07/15 16:46:31
Done.
|
| +#include "SkBitmapDevice.h" |
| + |
| SkBaseDevice* SkPDFDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint* layerPaint) { |
| - if (cinfo.fForImageFilter || |
| - (layerPaint && not_supported_for_layers(*layerPaint))) { |
| - return nullptr; |
| + if (cinfo.fForImageFilter || (layerPaint && not_supported_for_layers(*layerPaint))) { |
| + // need to return a raster device, which we will detect in drawDevice() |
| + return SkBitmapDevice::Create(cinfo.fInfo, SkSurfaceProps(0, kUnknown_SkPixelGeometry)); |
| } |
| SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height()); |
| return SkPDFDevice::Create(size, fRasterDpi, fDocument); |
| @@ -1272,6 +1274,20 @@ void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode, |
| void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, |
| int x, int y, const SkPaint& paint) { |
| + // Check if the source device is really a bitmapdevice (because that's what we returned |
| + // from createDevice (likely due to an imagefilter) |
| + SkPixmap pmap; |
| + if (device->peekPixels(&pmap)) { |
| + SkBitmap bitmap; |
| + bitmap.installPixels(pmap); |
| + if (paint.getImageFilter()) { |
| + this->drawSpriteWithFilter(d, bitmap, x, y, paint); |
| + } else { |
| + this->drawSprite(d, bitmap, x, y, paint); |
| + } |
| + return; |
| + } |
| + |
| // our onCreateCompatibleDevice() always creates SkPDFDevice subclasses. |
| SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); |