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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/core/SkCanvasDrawable.h ('k') | no next file » | 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 2014 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 "SkCanvas.h"
9 #include "SkCanvasDrawable.h"
10 #include "SkThread.h"
11
12 static int32_t next_generation_id() {
13 static int32_t gCanvasDrawableGenerationID;
14
15 // do a loop in case our global wraps around, as we never want to
16 // return a 0
17 int32_t genID;
18 do {
19 genID = sk_atomic_inc(&gCanvasDrawableGenerationID) + 1;
20 } while (0 == genID);
21 return genID;
22 }
23
24 SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {}
25
26 void SkCanvasDrawable::draw(SkCanvas* canvas) {
27 SkAutoCanvasRestore acr(canvas, true);
28 this->onDraw(canvas);
29 }
30
31 uint32_t SkCanvasDrawable::getGenerationID() {
32 if (0 == fGenerationID) {
33 fGenerationID = next_generation_id();
34 }
35 return fGenerationID;
36 }
37
38 bool SkCanvasDrawable::getBounds(SkRect* boundsPtr) {
39 SkRect bounds;
40 if (!boundsPtr) {
41 boundsPtr = &bounds;
42 }
43 return this->onGetBounds(boundsPtr);
44 }
45
46 void SkCanvasDrawable::notifyDrawingChanged() {
47 fGenerationID = 0;
48 }
49
50
OLDNEW
« 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