Chromium Code Reviews| 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(SkPDFDevice* dev) : SkCanvas(dev) {} | |
| 13 | |
| 14 SkPDFCanvas::~SkPDFCanvas() {} | |
| 15 | |
| 16 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, | |
| 17 const SkIRect& center, | |
| 18 const SkRect& dst, | |
| 19 const SkPaint* paint) { | |
| 20 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); | |
| 21 SkRect srcR, dstR; | |
| 22 while (iter.next(&srcR, &dstR)) { | |
| 23 this->drawBitmapRect(bitmap, srcR, dstR, paint); | |
|
reed1
2016/03/21 17:21:46
it might be clearer if we scope these explicitly t
| |
| 24 } | |
| 25 } | |
| 26 | |
| 27 void SkPDFCanvas::onDrawImageNine(const SkImage* image, | |
| 28 const SkIRect& center, | |
| 29 const SkRect& dst, | |
| 30 const SkPaint* paint) { | |
| 31 SkNinePatchIter iter(image->width(), image->height(), center, dst); | |
| 32 SkRect srcR, dstR; | |
| 33 while (iter.next(&srcR, &dstR)) { | |
| 34 this->drawImageRect(image, srcR, dstR, paint); | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 void SkPDFCanvas::onDrawImageRect(const SkImage* image, | |
| 39 const SkRect* srcPtr, | |
| 40 const SkRect& dst, | |
| 41 const SkPaint* paint, | |
| 42 SkCanvas::SrcRectConstraint constraint) { | |
| 43 SkRect bounds = SkRect::Make(image->bounds()); | |
| 44 SkRect src = srcPtr ? *srcPtr : bounds; | |
| 45 SkAutoCanvasRestore autoCanvasRestore(this, true); | |
| 46 if (src != bounds) { | |
| 47 this->clipRect(dst); | |
| 48 } | |
| 49 this->concat(SkMatrix::MakeRectToRect(src, dst, | |
| 50 SkMatrix::kFill_ScaleToFit)); | |
| 51 this->drawImage(image, 0, 0, paint); | |
| 52 } | |
| 53 | |
| 54 void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap, | |
| 55 const SkRect* srcPtr, | |
| 56 const SkRect& dst, | |
| 57 const SkPaint* paint, | |
| 58 SkCanvas::SrcRectConstraint constraint) { | |
| 59 SkRect bounds = SkRect::Make(bitmap.bounds()); | |
| 60 SkRect src = srcPtr ? *srcPtr : bounds; | |
| 61 SkAutoCanvasRestore autoCanvasRestore(this, true); | |
| 62 if (src != bounds) { | |
| 63 this->clipRect(dst); | |
| 64 } | |
| 65 this->concat(SkMatrix::MakeRectToRect(src, dst, | |
| 66 SkMatrix::kFill_ScaleToFit)); | |
| 67 this->drawBitmap(bitmap, 0, 0, paint); | |
| 68 } | |
| OLD | NEW |