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

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

Issue 1355353002: Create GrDraw and start fast pathing src over rects (Closed) Base URL: https://skia.googlesource.com/skia.git@strokerect2
Patch Set: rebase 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
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.
bsalomon 2015/09/23 13:49:38 "fast path" needs some explanation. something abou
joshualitt 2015/09/25 18:17:12 Acknowledged.
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;
robertphillips 2015/09/25 12:48:49 Some comments about how these class IDs work and w
joshualitt 2015/09/25 18:17:12 Acknowledged.
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;
robertphillips 2015/09/25 12:48:49 Do we need/even use 'fClassID'. Don't we just call
joshualitt 2015/09/25 18:17:12 Acknowledged.
56 uint32_t fClassID;
57
58 friend class GrDrawSnap; // for class ID stuff
59 };
60
robertphillips 2015/09/25 12:48:48 I second the motion for a comment
joshualitt 2015/09/25 18:17:12 Acknowledged.
61 class GrDrawSnap : public GrNonAtomicRef {
bsalomon 2015/09/23 13:49:38 /** ... */
joshualitt 2015/09/25 18:17:12 Acknowledged.
62 public:
63 GrDrawSnap() : fClassID(GrDraw::kIllegalDrawClassID) {}
64 uint32_t classID() const {
robertphillips 2015/09/25 12:48:49 use != ?
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

Powered by Google App Engine
This is Rietveld 408576698