OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkNinePatchIter.h" | 8 #include "SkNinePatchIter.h" |
9 #include "SkPDFCanvas.h" | 9 #include "SkPDFCanvas.h" |
10 #include "SkPDFDevice.h" | 10 #include "SkPDFDevice.h" |
11 | 11 |
12 SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev) | 12 SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev) |
13 : SkCanvas(dev.get()) {} | 13 : SkCanvas(dev.get()) {} |
14 | 14 |
15 SkPDFCanvas::~SkPDFCanvas() {} | 15 SkPDFCanvas::~SkPDFCanvas() {} |
16 | 16 |
| 17 /* |
| 18 * PDF's impl sometimes wants to access the raster clip as a SkRegion. To keep
this valid, |
| 19 * we intercept all clip calls to ensure that the clip stays BW (i.e. never ant
ialiased), since |
| 20 * an antialiased clip won't build a SkRegion (it builds SkAAClip). |
| 21 */ |
| 22 void SkPDFCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle
edgeStyle) { |
| 23 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); |
| 24 } |
| 25 |
| 26 void SkPDFCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeSty
le edgeStyle) { |
| 27 this->INHERITED::onClipRRect(rrect, op, kHard_ClipEdgeStyle); |
| 28 } |
| 29 |
| 30 void SkPDFCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle
edgeStyle) { |
| 31 this->INHERITED::onClipPath(path, op, kHard_ClipEdgeStyle); |
| 32 } |
| 33 |
17 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, | 34 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
18 const SkIRect& center, | 35 const SkIRect& center, |
19 const SkRect& dst, | 36 const SkRect& dst, |
20 const SkPaint* paint) { | 37 const SkPaint* paint) { |
21 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); | 38 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); |
22 SkRect srcR, dstR; | 39 SkRect srcR, dstR; |
23 while (iter.next(&srcR, &dstR)) { | 40 while (iter.next(&srcR, &dstR)) { |
24 this->drawBitmapRect(bitmap, srcR, dstR, paint); | 41 this->drawBitmapRect(bitmap, srcR, dstR, paint); |
25 } | 42 } |
26 } | 43 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 SkRect bounds = SkRect::Make(bitmap.bounds()); | 77 SkRect bounds = SkRect::Make(bitmap.bounds()); |
61 SkRect src = srcPtr ? *srcPtr : bounds; | 78 SkRect src = srcPtr ? *srcPtr : bounds; |
62 SkAutoCanvasRestore autoCanvasRestore(this, true); | 79 SkAutoCanvasRestore autoCanvasRestore(this, true); |
63 if (src != bounds) { | 80 if (src != bounds) { |
64 this->clipRect(dst); | 81 this->clipRect(dst); |
65 } | 82 } |
66 this->concat(SkMatrix::MakeRectToRect(src, dst, | 83 this->concat(SkMatrix::MakeRectToRect(src, dst, |
67 SkMatrix::kFill_ScaleToFit)); | 84 SkMatrix::kFill_ScaleToFit)); |
68 this->drawBitmap(bitmap, 0, 0, paint); | 85 this->drawBitmap(bitmap, 0, 0, paint); |
69 } | 86 } |
OLD | NEW |