OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkNinePatchIter.h" |
| 9 #include "SkPDFCanvas.h" |
| 10 #include "SkPDFDevice.h" |
| 11 |
| 12 SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev) |
| 13 : SkCanvas(dev.get()) {} |
| 14 |
| 15 SkPDFCanvas::~SkPDFCanvas() {} |
| 16 |
| 17 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
| 18 const SkIRect& center, |
| 19 const SkRect& dst, |
| 20 const SkPaint* paint) { |
| 21 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); |
| 22 SkRect srcR, dstR; |
| 23 while (iter.next(&srcR, &dstR)) { |
| 24 this->drawBitmapRect(bitmap, srcR, dstR, paint); |
| 25 } |
| 26 } |
| 27 |
| 28 void SkPDFCanvas::onDrawImageNine(const SkImage* image, |
| 29 const SkIRect& center, |
| 30 const SkRect& dst, |
| 31 const SkPaint* paint) { |
| 32 SkNinePatchIter iter(image->width(), image->height(), center, dst); |
| 33 SkRect srcR, dstR; |
| 34 while (iter.next(&srcR, &dstR)) { |
| 35 this->drawImageRect(image, srcR, dstR, paint); |
| 36 } |
| 37 } |
| 38 |
| 39 void SkPDFCanvas::onDrawImageRect(const SkImage* image, |
| 40 const SkRect* srcPtr, |
| 41 const SkRect& dst, |
| 42 const SkPaint* paint, |
| 43 SkCanvas::SrcRectConstraint constraint) { |
| 44 SkRect bounds = SkRect::Make(image->bounds()); |
| 45 SkRect src = srcPtr ? *srcPtr : bounds; |
| 46 SkAutoCanvasRestore autoCanvasRestore(this, true); |
| 47 if (src != bounds) { |
| 48 this->clipRect(dst); |
| 49 } |
| 50 this->concat(SkMatrix::MakeRectToRect(src, dst, |
| 51 SkMatrix::kFill_ScaleToFit)); |
| 52 this->drawImage(image, 0, 0, paint); |
| 53 } |
| 54 |
| 55 void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap, |
| 56 const SkRect* srcPtr, |
| 57 const SkRect& dst, |
| 58 const SkPaint* paint, |
| 59 SkCanvas::SrcRectConstraint constraint) { |
| 60 SkRect bounds = SkRect::Make(bitmap.bounds()); |
| 61 SkRect src = srcPtr ? *srcPtr : bounds; |
| 62 SkAutoCanvasRestore autoCanvasRestore(this, true); |
| 63 if (src != bounds) { |
| 64 this->clipRect(dst); |
| 65 } |
| 66 this->concat(SkMatrix::MakeRectToRect(src, dst, |
| 67 SkMatrix::kFill_ScaleToFit)); |
| 68 this->drawBitmap(bitmap, 0, 0, paint); |
| 69 } |
OLD | NEW |