diff options
author | Hal Canary <halcanary@google.com> | 2017-06-07 15:00:44 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-07 20:21:16 +0000 |
commit | db6365a9e267192c02d2745a654b07888f76b32e (patch) | |
tree | 572cf75ed44877987c6200026f35afb031a97a68 /src/pdf | |
parent | 2c075e749d1f33dea06ad2710e15c9a1d60ebced (diff) |
SkPDF: Do draw{Image,Bitmap} with maskfilter.
https://fiddle.skia.org/c/@skbug_237_drawImage_with_blur
BUG=skia:237
Change-Id: I50f65d428f254e3965a448a110edd39c0f7a937f
Reviewed-on: https://skia-review.googlesource.com/19027
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkPDFCanvas.cpp | 29 | ||||
-rw-r--r-- | src/pdf/SkPDFCanvas.h | 3 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/pdf/SkPDFCanvas.cpp b/src/pdf/SkPDFCanvas.cpp index a0ab8f16f7..720161ecf5 100644 --- a/src/pdf/SkPDFCanvas.cpp +++ b/src/pdf/SkPDFCanvas.cpp @@ -54,6 +54,35 @@ void SkPDFCanvas::onDrawImageNine(const SkImage* image, } } +void SkPDFCanvas::onDrawImage(const SkImage* image, + SkScalar x, + SkScalar y, + const SkPaint* paint) { + SkASSERT(image); + if (paint && paint->getMaskFilter()) { + SkPaint paintCopy(*paint); + SkMatrix m = SkMatrix::MakeTrans(x, y); + paintCopy.setShader(image->makeShader(&m)); + this->drawRect(SkRect::MakeXYWH(x, y, image->width(), image->height()), paintCopy); + return; + } + this->SkCanvas::onDrawImage(image, x, y, paint); +} + +void SkPDFCanvas::onDrawBitmap(const SkBitmap& bitmap, + SkScalar x, + SkScalar y, + const SkPaint* paint) { + if (paint && paint->getMaskFilter()) { + if (sk_sp<SkImage> img = SkImage::MakeFromBitmap(bitmap)) { + this->onDrawImage(img.get(), x, y, paint); + } + return; + } + this->SkCanvas::onDrawBitmap(bitmap, x, y, paint); +} + + static bool is_integer(SkScalar x) { return x == SkScalarTruncToScalar(x); } diff --git a/src/pdf/SkPDFCanvas.h b/src/pdf/SkPDFCanvas.h index 93c055a26a..117056664a 100644 --- a/src/pdf/SkPDFCanvas.h +++ b/src/pdf/SkPDFCanvas.h @@ -21,6 +21,9 @@ protected: void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override; void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override; + void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override; + void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override; + void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*) override; |