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

Unified Diff: src/core/SkMultiPictureDraw.cpp

Issue 491313003: SkMultiPictureDraw API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix clang complaint Created 6 years, 4 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 | « include/core/SkMultiPictureDraw.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMultiPictureDraw.cpp
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..50af2b717e38a45fb06a3006681cb10a2819b403
--- /dev/null
+++ b/src/core/SkMultiPictureDraw.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCanvas.h"
+#include "SkMultiPictureDraw.h"
+#include "SkPicture.h"
+
+SkMultiPictureDraw::SkMultiPictureDraw(int reserve) {
+ if (reserve > 0) {
+ fDrawData.setReserve(reserve);
+ }
+}
+
+void SkMultiPictureDraw::reset() {
+ for (int i = 0; i < fDrawData.count(); ++i) {
+ fDrawData[i].picture->unref();
+ fDrawData[i].canvas->unref();
+ SkDELETE(fDrawData[i].paint);
+ }
+
+ fDrawData.rewind();
+}
+
+void SkMultiPictureDraw::add(SkCanvas* canvas,
+ const SkPicture* picture,
+ const SkMatrix* matrix,
+ const SkPaint* paint) {
+ if (NULL == canvas || NULL == picture) {
+ SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-NULL");
+ return;
+ }
+
+ DrawData* data = fDrawData.append();
+
+ data->picture = SkRef(picture);
+ data->canvas = SkRef(canvas);
+ if (NULL != matrix) {
+ data->matrix = *matrix;
+ } else {
+ data->matrix.setIdentity();
+ }
+ if (NULL != paint) {
+ data->paint = SkNEW_ARGS(SkPaint, (*paint));
+ } else {
+ data->paint = NULL;
+ }
+}
+
+void SkMultiPictureDraw::draw() {
+ for (int i = 0; i < fDrawData.count(); ++i) {
+ fDrawData[i].canvas->drawPicture(fDrawData[i].picture,
+ &fDrawData[i].matrix,
+ fDrawData[i].paint);
+ }
+
+ this->reset();
+}
+
« no previous file with comments | « include/core/SkMultiPictureDraw.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698