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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 2161233002: pre-land special methods on device (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698