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

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

Issue 1812063002: SkPDF: Add SkPDFCanvas to intercept some draw calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFCanvas.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698