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