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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFCanvas.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCanvas.cpp
diff --git a/src/pdf/SkPDFCanvas.cpp b/src/pdf/SkPDFCanvas.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..de3dc93528cb8783653bcfc2e5564847d39da94c
--- /dev/null
+++ b/src/pdf/SkPDFCanvas.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkNinePatchIter.h"
+#include "SkPDFCanvas.h"
+#include "SkPDFDevice.h"
+
+SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev)
+ : SkCanvas(dev.get()) {}
+
+SkPDFCanvas::~SkPDFCanvas() {}
+
+void SkPDFCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
+ const SkIRect& center,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst);
+ SkRect srcR, dstR;
+ while (iter.next(&srcR, &dstR)) {
+ this->drawBitmapRect(bitmap, srcR, dstR, paint);
+ }
+}
+
+void SkPDFCanvas::onDrawImageNine(const SkImage* image,
+ const SkIRect& center,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ SkNinePatchIter iter(image->width(), image->height(), center, dst);
+ SkRect srcR, dstR;
+ while (iter.next(&srcR, &dstR)) {
+ this->drawImageRect(image, srcR, dstR, paint);
+ }
+}
+
+void SkPDFCanvas::onDrawImageRect(const SkImage* image,
+ const SkRect* srcPtr,
+ const SkRect& dst,
+ const SkPaint* paint,
+ SkCanvas::SrcRectConstraint constraint) {
+ SkRect bounds = SkRect::Make(image->bounds());
+ SkRect src = srcPtr ? *srcPtr : bounds;
+ SkAutoCanvasRestore autoCanvasRestore(this, true);
+ if (src != bounds) {
+ this->clipRect(dst);
+ }
+ this->concat(SkMatrix::MakeRectToRect(src, dst,
+ SkMatrix::kFill_ScaleToFit));
+ this->drawImage(image, 0, 0, paint);
+}
+
+void SkPDFCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
+ const SkRect* srcPtr,
+ const SkRect& dst,
+ const SkPaint* paint,
+ SkCanvas::SrcRectConstraint constraint) {
+ SkRect bounds = SkRect::Make(bitmap.bounds());
+ SkRect src = srcPtr ? *srcPtr : bounds;
+ SkAutoCanvasRestore autoCanvasRestore(this, true);
+ if (src != bounds) {
+ this->clipRect(dst);
+ }
+ this->concat(SkMatrix::MakeRectToRect(src, dst,
+ SkMatrix::kFill_ScaleToFit));
+ this->drawBitmap(bitmap, 0, 0, paint);
+}
« 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