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

Unified Diff: src/core/SkCanvasDrawable.cpp

Issue 696063005: initial checkin for experimenting (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/core/SkCanvasDrawable.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvasDrawable.cpp
diff --git a/src/core/SkCanvasDrawable.cpp b/src/core/SkCanvasDrawable.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c01738dd60d74b0a4a8c41b544688a5b9614af6
--- /dev/null
+++ b/src/core/SkCanvasDrawable.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "SkCanvasDrawable.h"
+#include "SkThread.h"
+
+static int32_t next_generation_id() {
+ static int32_t gCanvasDrawableGenerationID;
+
+ // do a loop in case our global wraps around, as we never want to
+ // return a 0
+ int32_t genID;
+ do {
+ genID = sk_atomic_inc(&gCanvasDrawableGenerationID) + 1;
+ } while (0 == genID);
+ return genID;
+}
+
+SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {}
+
+void SkCanvasDrawable::draw(SkCanvas* canvas) {
+ SkAutoCanvasRestore acr(canvas, true);
+ this->onDraw(canvas);
+}
+
+uint32_t SkCanvasDrawable::getGenerationID() {
+ if (0 == fGenerationID) {
+ fGenerationID = next_generation_id();
+ }
+ return fGenerationID;
+}
+
+bool SkCanvasDrawable::getBounds(SkRect* boundsPtr) {
+ SkRect bounds;
+ if (!boundsPtr) {
+ boundsPtr = &bounds;
+ }
+ return this->onGetBounds(boundsPtr);
+}
+
+void SkCanvasDrawable::notifyDrawingChanged() {
+ fGenerationID = 0;
+}
+
+
« no previous file with comments | « src/core/SkCanvasDrawable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698