Index: src/pdf/SkPDFDevice.cpp |
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp |
index 01e8c82526ed295ed554d2f0ff1b5444f3372b35..ff2806a6729c10d8811793ba2a305b7ee5939fa1 100644 |
--- a/src/pdf/SkPDFDevice.cpp |
+++ b/src/pdf/SkPDFDevice.cpp |
@@ -2216,3 +2216,52 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix, |
SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
&content.entry()->fContent); |
} |
+ |
+/////////////////////////////////////////////////////////////////////////////////////////////////// |
+ |
+#include "SkSpecialImage.h" |
+#include "SkImageFilter.h" |
+ |
+void SkPDFDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int x, int y, |
+ const SkPaint& paint) { |
+ SkASSERT(!srcImg->isTextureBacked()); |
+ |
+ SkBitmap resultBM; |
+ |
+ SkImageFilter* filter = paint.getImageFilter(); |
+ if (filter) { |
+ SkIPoint offset = SkIPoint::Make(0, 0); |
+ SkMatrix matrix = *draw.fMatrix; |
+ matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
+ const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); |
robertphillips
2016/07/19 21:08:04
Should be override getImageFilterCache for the SkP
reed1
2016/07/19 21:32:26
Good catch. I think its just a public/protected is
|
+// SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); |
+ SkImageFilter::Context ctx(matrix, clipBounds, nullptr /*cache.get()*/); |
+ |
+ sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset)); |
+ if (resultImg) { |
+ SkPaint tmpUnfiltered(paint); |
+ tmpUnfiltered.setImageFilter(nullptr); |
+ if (resultImg->getROPixels(&resultBM)) { |
+ this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered); |
+ } |
+ } |
+ } else { |
+ if (srcImg->getROPixels(&resultBM)) { |
+ this->drawSprite(draw, resultBM, x, y, paint); |
+ } |
+ } |
+} |
+ |
+sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkBitmap& bitmap) { |
+ return SkSpecialImage::MakeFromRaster(bitmap.bounds(), bitmap); |
+} |
+ |
+sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { |
+ return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->height()), |
+ image->makeNonTextureImage()); |
+} |
+ |
+sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
+ SkASSERT(false); |
+ return nullptr; |
+} |