| 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: |
| 19 |
explicit constexpr UniquePaintParamsID(uint32_t id) : fID(id) {} |
| 20 |
|
| 21 |
constexpr UniquePaintParamsID() : fID(SK_InvalidUniqueID) {} |
| 22 |
|
| 23 |
static constexpr UniquePaintParamsID Invalid() { return UniquePaintParamsID(); } |
| 24 |
|
| 25 |
bool operator==(const UniquePaintParamsID &that) const { return fID == that.fID; } |
| 26 |
bool operator!=(const UniquePaintParamsID &that) const { return !(*this == that); } |
| 27 |
|
| 28 |
bool isValid() const { return fID != SK_InvalidUniqueID; } |
| 29 |
uint32_t asUInt() const { return fID; } |
| 30 |
|
| 31 |
private: |
| 32 |
uint32_t fID; |
| 33 |
}; |
| 34 |
|
| 35 |
} // skgpu::graphite |
| 36 |
|
| 37 |
#endif // skgpu_graphite_UniquePaintParamsID_DEFINED |