Line data Source code
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 "SkLatticeIter.h"
9 : #include "SkPDFCanvas.h"
10 : #include "SkPDFDevice.h"
11 :
12 0 : SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev)
13 0 : : SkCanvas(dev.get()) {}
14 :
15 0 : SkPDFCanvas::~SkPDFCanvas() {}
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 antialiased), since
20 : * an antialiased clip won't build a SkRegion (it builds SkAAClip).
21 : */
22 0 : void SkPDFCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
23 0 : this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
24 0 : }
25 :
26 0 : void SkPDFCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
27 0 : this->INHERITED::onClipRRect(rrect, op, kHard_ClipEdgeStyle);
28 0 : }
29 :
30 0 : void SkPDFCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
31 0 : this->INHERITED::onClipPath(path, op, kHard_ClipEdgeStyle);
32 0 : }
33 :
34 0 : void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
35 : const SkIRect& center,
36 : const SkRect& dst,
37 : const SkPaint* paint) {
38 0 : SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst);
39 : SkRect srcR, dstR;
40 0 : while (iter.next(&srcR, &dstR)) {
41 0 : this->drawBitmapRect(bitmap, srcR, dstR, paint);
42 : }
43 0 : }
44 :
45 0 : void SkPDFCanvas::onDrawImageNine(const SkImage* image,
46 : const SkIRect& center,
47 : const SkRect& dst,
48 : const SkPaint* paint) {
49 0 : SkLatticeIter iter(image->width(), image->height(), center, dst);
50 : SkRect srcR, dstR;
51 0 : while (iter.next(&srcR, &dstR)) {
52 0 : this->drawImageRect(image, srcR, dstR, paint);
53 : }
54 0 : }
55 :
56 0 : void SkPDFCanvas::onDrawImageRect(const SkImage* image,
57 : const SkRect* src,
58 : const SkRect& dst,
59 : const SkPaint* paint,
60 : SkCanvas::SrcRectConstraint constraint) {
61 0 : SkAutoCanvasRestore autoCanvasRestore(this, true);
62 0 : this->clipRect(dst);
63 0 : this->SkCanvas::onDrawImageRect(image, src, dst, paint, constraint);
64 0 : }
65 :
66 0 : void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
67 : const SkRect* src,
68 : const SkRect& dst,
69 : const SkPaint* paint,
70 : SkCanvas::SrcRectConstraint constraint) {
71 0 : SkAutoCanvasRestore autoCanvasRestore(this, true);
72 0 : this->clipRect(dst);
73 0 : this->SkCanvas::onDrawBitmapRect(bitmap, src, dst, paint, constraint);
74 0 : }
75 :
76 0 : void SkPDFCanvas::onDrawImageLattice(const SkImage* image,
77 : const Lattice& lattice,
78 : const SkRect& dst,
79 : const SkPaint* paint) {
80 0 : SkLatticeIter iter(lattice, dst);
81 : SkRect srcR, dstR;
82 0 : while (iter.next(&srcR, &dstR)) {
83 0 : this->drawImageRect(image, srcR, dstR, paint);
84 : }
85 0 : }
86 :
87 0 : void SkPDFCanvas::onDrawBitmapLattice(const SkBitmap& bitmap,
88 : const Lattice& lattice,
89 : const SkRect& dst,
90 : const SkPaint* paint) {
91 0 : SkLatticeIter iter(lattice, dst);
92 : SkRect srcR, dstR;
93 0 : while (iter.next(&srcR, &dstR)) {
94 0 : this->drawBitmapRect(bitmap, srcR, dstR, paint);
95 : }
96 0 : }
97 :
|