Chromium Code Reviews| Index: src/pdf/SkPDFCanvas.cpp |
| diff --git a/src/pdf/SkPDFCanvas.cpp b/src/pdf/SkPDFCanvas.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..efc29ab65471f4ccc7cfd641332c1f55ab0f81c2 |
| --- /dev/null |
| +++ b/src/pdf/SkPDFCanvas.cpp |
| @@ -0,0 +1,68 @@ |
| +/* |
| + * Copyright 2016 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "SkNinePatchIter.h" |
| +#include "SkPDFCanvas.h" |
| +#include "SkPDFDevice.h" |
| + |
| +SkPDFCanvas::SkPDFCanvas(SkPDFDevice* dev) : SkCanvas(dev) {} |
| + |
| +SkPDFCanvas::~SkPDFCanvas() {} |
| + |
| +void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
| + const SkIRect& center, |
| + const SkRect& dst, |
| + const SkPaint* paint) { |
| + SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); |
| + SkRect srcR, dstR; |
| + while (iter.next(&srcR, &dstR)) { |
| + this->drawBitmapRect(bitmap, srcR, dstR, paint); |
|
reed1
2016/03/21 17:21:46
it might be clearer if we scope these explicitly t
|
| + } |
| +} |
| + |
| +void SkPDFCanvas::onDrawImageNine(const SkImage* image, |
| + const SkIRect& center, |
| + const SkRect& dst, |
| + const SkPaint* paint) { |
| + SkNinePatchIter iter(image->width(), image->height(), center, dst); |
| + SkRect srcR, dstR; |
| + while (iter.next(&srcR, &dstR)) { |
| + this->drawImageRect(image, srcR, dstR, paint); |
| + } |
| +} |
| + |
| +void SkPDFCanvas::onDrawImageRect(const SkImage* image, |
| + const SkRect* srcPtr, |
| + const SkRect& dst, |
| + const SkPaint* paint, |
| + SkCanvas::SrcRectConstraint constraint) { |
| + SkRect bounds = SkRect::Make(image->bounds()); |
| + SkRect src = srcPtr ? *srcPtr : bounds; |
| + SkAutoCanvasRestore autoCanvasRestore(this, true); |
| + if (src != bounds) { |
| + this->clipRect(dst); |
| + } |
| + this->concat(SkMatrix::MakeRectToRect(src, dst, |
| + SkMatrix::kFill_ScaleToFit)); |
| + this->drawImage(image, 0, 0, paint); |
| +} |
| + |
| +void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap, |
| + const SkRect* srcPtr, |
| + const SkRect& dst, |
| + const SkPaint* paint, |
| + SkCanvas::SrcRectConstraint constraint) { |
| + SkRect bounds = SkRect::Make(bitmap.bounds()); |
| + SkRect src = srcPtr ? *srcPtr : bounds; |
| + SkAutoCanvasRestore autoCanvasRestore(this, true); |
| + if (src != bounds) { |
| + this->clipRect(dst); |
| + } |
| + this->concat(SkMatrix::MakeRectToRect(src, dst, |
| + SkMatrix::kFill_ScaleToFit)); |
| + this->drawBitmap(bitmap, 0, 0, paint); |
| +} |