• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
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 skgpu_graphite_UniquePaintParamsID_DEFINED
9 #define skgpu_graphite_UniquePaintParamsID_DEFINED
10 
11 #include "include/core/SkTypes.h"
12 
13 namespace skgpu::graphite {
14 
15 // This class boils down to a unique uint that can be used instead of a variable length
16 // key derived from a PaintParams.
17 class UniquePaintParamsID {
18 public:
UniquePaintParamsID(uint32_t id)19     explicit UniquePaintParamsID(uint32_t id) : fID(id) {
20         SkASSERT(id != SK_InvalidUniqueID);
21     }
22 
InvalidID()23     static UniquePaintParamsID InvalidID() { return UniquePaintParamsID(); }
24 
UniquePaintParamsID()25     UniquePaintParamsID() : fID(SK_InvalidUniqueID) {}
26 
27     bool operator==(const UniquePaintParamsID &that) const { return fID == that.fID; }
28     bool operator!=(const UniquePaintParamsID &that) const { return !(*this == that); }
29 
isValid()30     bool isValid() const { return fID != SK_InvalidUniqueID; }
asUInt()31     uint32_t asUInt() const { return fID; }
32 
33 private:
34     uint32_t fID;
35 };
36 
37 } // skgpu::graphite
38 
39 #endif // skgpu_graphite_UniquePaintParamsID_DEFINED
40