OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #ifndef GrFakeRefObj_DEFINED | 8 #ifndef GrFakeRefObj_DEFINED |
10 #define GrFakeRefObj_DEFINED | 9 #define GrFakeRefObj_DEFINED |
11 | 10 |
| 11 #include "SkTypes.h" |
12 #include "gl/GrGLInterface.h" | 12 #include "gl/GrGLInterface.h" |
13 #include "GrNoncopyable.h" | |
14 | 13 |
15 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
16 // This object is used to track the OpenGL objects. We don't use real | 15 // This object is used to track the OpenGL objects. We don't use real |
17 // reference counting (i.e., we don't free the objects when their ref count | 16 // reference counting (i.e., we don't free the objects when their ref count |
18 // goes to 0) so that we can detect invalid memory accesses. The refs we | 17 // goes to 0) so that we can detect invalid memory accesses. The refs we |
19 // are tracking in this class are actually OpenGL's references to the objects | 18 // are tracking in this class are actually OpenGL's references to the objects |
20 // not "ours" | 19 // not "ours" |
21 // Each object also gets a unique globally identifying ID | 20 // Each object also gets a unique globally identifying ID |
22 class GrFakeRefObj : public GrNoncopyable { | 21 class GrFakeRefObj : public SkNoncopyable { |
23 public: | 22 public: |
24 GrFakeRefObj() | 23 GrFakeRefObj() |
25 : fRef(0) | 24 : fRef(0) |
26 , fHighRefCount(0) | 25 , fHighRefCount(0) |
27 , fMarkedForDeletion(false) | 26 , fMarkedForDeletion(false) |
28 , fDeleted(false) { | 27 , fDeleted(false) { |
29 | 28 |
30 // source for globally unique IDs - 0 is reserved! | 29 // source for globally unique IDs - 0 is reserved! |
31 static int fNextID = 0; | 30 static int fNextID = 0; |
32 | 31 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // factory creation entry point. This entry point is used by the GrGLDebug | 85 // factory creation entry point. This entry point is used by the GrGLDebug |
87 // object to instantiate the various objects | 86 // object to instantiate the various objects |
88 // all globally unique IDs | 87 // all globally unique IDs |
89 #define GR_DEFINE_CREATOR(className) \ | 88 #define GR_DEFINE_CREATOR(className) \ |
90 public: \ | 89 public: \ |
91 static GrFakeRefObj *create ## className() { \ | 90 static GrFakeRefObj *create ## className() { \ |
92 return SkNEW(className); \ | 91 return SkNEW(className); \ |
93 } | 92 } |
94 | 93 |
95 #endif // GrFakeRefObj_DEFINED | 94 #endif // GrFakeRefObj_DEFINED |
OLD | NEW |