OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 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 GrResourceHandle_DEFINED | |
9 #define GrResourcehandle_DEFINED | |
10 | |
11 #include "SkTypes.h" | |
12 | |
13 // Opaque handle to a resource | |
14 class GrResourceHandle { | |
15 public: | |
16 GrResourceHandle(int value) : fValue(value) { | |
17 SkASSERT(this->isValid()); | |
18 } | |
19 | |
20 GrResourceHandle() : fValue(kInvalid_ResourceHandle) {} | |
21 protected: | |
22 bool operator==(const GrResourceHandle& other) const { return other.fValue = = fValue; } | |
23 bool isValid() const { return kInvalid_ResourceHandle != fValue; } | |
24 int toIndex() const { SkASSERT(this->isValid()); return fValue; } | |
25 | |
26 private: | |
27 static const int kInvalid_ResourceHandle = -1; | |
28 int fValue; | |
29 }; | |
30 | |
31 // Creates a resource handle class with the name, name, which exposes the protec ted functions of the | |
32 // handle class to be used on the sub class | |
33 #define GR_CREATE_RESOURCE_HANDLE_CLASS(name) \ | |
bsalomon
2016/05/06 17:37:54
What do you think about simplifying this by making
| |
34 class name : public GrResourceHandle { \ | |
35 private: \ | |
36 typedef GrResourceHandle INHERITED; \ | |
37 public: \ | |
38 using INHERITED::INHERITED; \ | |
39 using INHERITED::operator==; \ | |
40 using INHERITED::isValid; \ | |
41 using INHERITED::toIndex; \ | |
42 } | |
43 | |
44 | |
45 | |
46 #endif | |
OLD | NEW |