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

Side by Side Diff: src/gpu/draws/GrDraw.h

Issue 1336413006: Just an experiment (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrRectBatchFactory.h ('k') | src/gpu/draws/GrDraw.cpp » ('j') | 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 2015 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 #ifndef GrDraw_DEFINED
9 #define GrDraw_DEFINED
10
11 #include "GrNonAtomicRef.h"
12
13 #include "GrRenderTarget.h"
14
15 class GrDrawTarget;
16
17 #define GRDRAW_ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fC ontext)
18
19 /*
20 * GrDraw is a virtual class which captures the scope of the entry point on SkGp uDevice where it
21 * originates. After creation, it lives on the GrPipeline where it used as a po tential fast path
22 * for batching.
23 *
24 * A GrDraw must be able to fully draw itself if fastpath batching is not possib le
25 */
26
27 class GrDraw {
28 public:
29 GrDraw() : fClassID(kIllegalDrawClassID) {}
30 virtual ~GrDraw() {}
31
32 virtual void execute(GrDrawTarget*) const=0;
33 uint32_t classID() const { SkASSERT(!fClassID == kIllegalDrawClassID); retur n fClassID; }
34 template <typename PROC_SUBCLASS> static uint32_t ClassID() {
35 static uint32_t kClassID = GenID(&gCurrDrawClassID);
36 return kClassID;
37 }
38
39 protected:
40 static uint32_t GenID(int32_t* idCounter) {
41 // The atomic inc returns the old value not the incremented value. So we add
42 // 1 to the returned value.
43 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
44 if (!id) {
45 SkFAIL("This should never wrap as it should only be called once for each GrDraw "
46 "subclass.");
47 }
48 return id;
49 }
50
51 enum {
52 kIllegalDrawClassID = 0
53 };
54
55 static int32_t gCurrDrawClassID;
56 uint32_t fClassID;
57
58 friend class GrDrawSnap; // for class ID stuff
59 };
60
61 class GrDrawSnap : public GrNonAtomicRef {
62 public:
63 GrDrawSnap() : fClassID(GrDraw::kIllegalDrawClassID) {}
64 uint32_t classID() const {
65 SkASSERT(!fClassID == GrDraw::kIllegalDrawClassID);
66 return fClassID;
67 }
68
69 protected:
70 uint32_t fClassID;
71 typedef GrNonAtomicRef INHERITED;
72 };
73
74 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrRectBatchFactory.h ('k') | src/gpu/draws/GrDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698