Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/pdf/SkPDFCanvas.cpp

Issue 1992283002: Add drawBitmapLattice() API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rewrite picture impls Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFCanvas.h ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkLatticeIter.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 /* 17 /*
18 * PDF's impl sometimes wants to access the raster clip as a SkRegion. To keep this valid, 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 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). 20 * an antialiased clip won't build a SkRegion (it builds SkAAClip).
21 */ 21 */
22 void SkPDFCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 22 void SkPDFCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
23 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); 23 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
24 } 24 }
25 25
26 void SkPDFCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeSty le edgeStyle) { 26 void SkPDFCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeSty le edgeStyle) {
27 this->INHERITED::onClipRRect(rrect, op, kHard_ClipEdgeStyle); 27 this->INHERITED::onClipRRect(rrect, op, kHard_ClipEdgeStyle);
28 } 28 }
29 29
30 void SkPDFCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 30 void SkPDFCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
31 this->INHERITED::onClipPath(path, op, kHard_ClipEdgeStyle); 31 this->INHERITED::onClipPath(path, op, kHard_ClipEdgeStyle);
32 } 32 }
33 33
34 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap, 34 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
35 const SkIRect& center, 35 const SkIRect& center,
36 const SkRect& dst, 36 const SkRect& dst,
37 const SkPaint* paint) { 37 const SkPaint* paint) {
38 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst); 38 SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst);
39 SkRect srcR, dstR; 39 SkRect srcR, dstR;
40 while (iter.next(&srcR, &dstR)) { 40 while (iter.next(&srcR, &dstR)) {
41 this->drawBitmapRect(bitmap, srcR, dstR, paint); 41 this->drawBitmapRect(bitmap, srcR, dstR, paint);
42 } 42 }
43 } 43 }
44 44
45 void SkPDFCanvas::onDrawImageNine(const SkImage* image, 45 void SkPDFCanvas::onDrawImageNine(const SkImage* image,
46 const SkIRect& center, 46 const SkIRect& center,
47 const SkRect& dst, 47 const SkRect& dst,
48 const SkPaint* paint) { 48 const SkPaint* paint) {
49 SkNinePatchIter iter(image->width(), image->height(), center, dst); 49 SkLatticeIter iter(image->width(), image->height(), center, dst);
50 SkRect srcR, dstR; 50 SkRect srcR, dstR;
51 while (iter.next(&srcR, &dstR)) { 51 while (iter.next(&srcR, &dstR)) {
52 this->drawImageRect(image, srcR, dstR, paint); 52 this->drawImageRect(image, srcR, dstR, paint);
53 } 53 }
54 } 54 }
55 55
56 void SkPDFCanvas::onDrawImageRect(const SkImage* image, 56 void SkPDFCanvas::onDrawImageRect(const SkImage* image,
57 const SkRect* srcPtr, 57 const SkRect* srcPtr,
58 const SkRect& dst, 58 const SkRect& dst,
59 const SkPaint* paint, 59 const SkPaint* paint,
(...skipping 17 matching lines...) Expand all
77 SkRect bounds = SkRect::Make(bitmap.bounds()); 77 SkRect bounds = SkRect::Make(bitmap.bounds());
78 SkRect src = srcPtr ? *srcPtr : bounds; 78 SkRect src = srcPtr ? *srcPtr : bounds;
79 SkAutoCanvasRestore autoCanvasRestore(this, true); 79 SkAutoCanvasRestore autoCanvasRestore(this, true);
80 if (src != bounds) { 80 if (src != bounds) {
81 this->clipRect(dst); 81 this->clipRect(dst);
82 } 82 }
83 this->concat(SkMatrix::MakeRectToRect(src, dst, 83 this->concat(SkMatrix::MakeRectToRect(src, dst,
84 SkMatrix::kFill_ScaleToFit)); 84 SkMatrix::kFill_ScaleToFit));
85 this->drawBitmap(bitmap, 0, 0, paint); 85 this->drawBitmap(bitmap, 0, 0, paint);
86 } 86 }
87
88 void SkPDFCanvas::onDrawImageLattice(const SkImage* image,
89 const Lattice& lattice,
90 const SkRect& dst,
91 const SkPaint* paint) {
92 SkLatticeIter iter(image->width(), image->height(), lattice, dst);
93 SkRect srcR, dstR;
94 while (iter.next(&srcR, &dstR)) {
95 this->drawImageRect(image, srcR, dstR, paint);
96 }
97 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFCanvas.h ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698