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

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: 2016-03-21 (Monday) 15:44:28 EDT 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(const sk_sp<SkPDFDevice>& dev)
13 : SkCanvas(dev.get()) {}
14
15 SkPDFCanvas::~SkPDFCanvas() {}
16
17 void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
18 const SkIRect& center,
19 const SkRect& dst,
20 const SkPaint* paint) {
21 SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst);
22 SkRect srcR, dstR;
23 while (iter.next(&srcR, &dstR)) {
24 this->drawBitmapRect(bitmap, srcR, dstR, paint);
25 }
26 }
27
28 void SkPDFCanvas::onDrawImageNine(const SkImage* image,
29 const SkIRect& center,
30 const SkRect& dst,
31 const SkPaint* paint) {
32 SkNinePatchIter iter(image->width(), image->height(), center, dst);
33 SkRect srcR, dstR;
34 while (iter.next(&srcR, &dstR)) {
35 this->drawImageRect(image, srcR, dstR, paint);
36 }
37 }
38
39 void SkPDFCanvas::onDrawImageRect(const SkImage* image,
40 const SkRect* srcPtr,
41 const SkRect& dst,
42 const SkPaint* paint,
43 SkCanvas::SrcRectConstraint constraint) {
44 SkRect bounds = SkRect::Make(image->bounds());
45 SkRect src = srcPtr ? *srcPtr : bounds;
46 SkAutoCanvasRestore autoCanvasRestore(this, true);
47 if (src != bounds) {
48 this->clipRect(dst);
49 }
50 this->concat(SkMatrix::MakeRectToRect(src, dst,
51 SkMatrix::kFill_ScaleToFit));
52 this->drawImage(image, 0, 0, paint);
53 }
54
55 void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
56 const SkRect* srcPtr,
57 const SkRect& dst,
58 const SkPaint* paint,
59 SkCanvas::SrcRectConstraint constraint) {
60 SkRect bounds = SkRect::Make(bitmap.bounds());
61 SkRect src = srcPtr ? *srcPtr : bounds;
62 SkAutoCanvasRestore autoCanvasRestore(this, true);
63 if (src != bounds) {
64 this->clipRect(dst);
65 }
66 this->concat(SkMatrix::MakeRectToRect(src, dst,
67 SkMatrix::kFill_ScaleToFit));
68 this->drawBitmap(bitmap, 0, 0, paint);
69 }
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