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

Unified Diff: src/core/SkPictureImageGenerator.cpp

Issue 1240093004: SkPictureImageGenerator (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: added GM Created 5 years, 5 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
« gm/pictureimagegenerator.cpp ('K') | « src/core/SkPictureImageGenerator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureImageGenerator.cpp
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1011af9bbc4bba4f6d064b66a47d240dcb5924a1
--- /dev/null
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPictureImageGenerator.h"
+
+#include "SkCanvas.h"
+#include "SkMatrix.h"
+#include "SkPaint.h"
+#include "SkPicture.h"
+
+SkImageGenerator* SkPictureImageGenerator::Create(const SkISize& size, const SkPicture* picture,
+ const SkMatrix* matrix, const SkPaint* paint) {
+ if (!picture || size.isEmpty()) {
+ return nullptr;
+ }
+
+ return SkNEW_ARGS(SkPictureImageGenerator, (size, picture, matrix, paint));
+}
+
+SkPictureImageGenerator::SkPictureImageGenerator(const SkISize& size, const SkPicture* picture,
+ const SkMatrix* matrix, const SkPaint* paint)
+ : INHERITED(SkImageInfo::MakeN32Premul(size))
+ , fPicture(SkRef(picture)) {
+
+ if (matrix) {
+ fMatrix = *matrix;
+ } else {
+ fMatrix.reset();
+ }
+
+ if (paint) {
+ fPaint.set(*paint);
+ }
+}
+
robertphillips 2015/07/20 17:32:43 So is there no way to have this work in GPU land?
f(malita) 2015/07/20 20:13:38 Not at this point :( It would be super nice to ha
+bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount) {
+ if (info != getInfo() || ctable || ctableCount) {
+ return false;
+ }
+
+ SkBitmap bitmap;
+ if (!bitmap.installPixels(info, pixels, rowBytes)) {
+ return false;
+ }
+
+ bitmap.eraseColor(SK_ColorTRANSPARENT);
+ SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
+ canvas.drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
+
+ return true;
+}
« gm/pictureimagegenerator.cpp ('K') | « src/core/SkPictureImageGenerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698