| 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_GraphiteResourceKey_DEFINED |
| 9 |
#define skgpu_graphite_GraphiteResourceKey_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/ResourceKey.h" |
| 12 |
#include "src/gpu/graphite/ResourceTypes.h" |
| 13 |
|
| 14 |
namespace skgpu::graphite { |
| 15 |
|
| 16 |
/** |
| 17 |
* GraphiteResourceKey is no different from the base skgpu::ResourceKey except that its type is |
| 18 |
* specific to Graphite. Graphite does not use different types of keys to manage reusability or |
| 19 |
* resource sharing like in Ganesh. Instead a key simply encodes the underlying configuration of the |
| 20 |
* resource and whether or not the resource can be shared is handled externally through coordination |
| 21 |
* between the ResourceCache and ResourceProvider. |
| 22 |
*/ |
| 23 |
class GraphiteResourceKey : public skgpu::ResourceKey { |
| 24 |
public: |
| 25 |
/** Generate a unique ResourceType. */ |
| 26 |
static ResourceType GenerateResourceType(); |
| 27 |
|
| 28 |
/** Creates an invalid key. It must be initialized using a Builder object before use. */ |
| 29 |
GraphiteResourceKey() {} |
| 30 |
|
| 31 |
GraphiteResourceKey(const GraphiteResourceKey& that) { *this = that; } |
| 32 |
|
| 33 |
ResourceType resourceType() const { return this->domain(); } |
| 34 |
|
| 35 |
GraphiteResourceKey& operator=(const GraphiteResourceKey& that) { |
| 36 |
this->ResourceKey::operator=(that); |
| 37 |
return *this; |
| 38 |
} |
| 39 |
|
| 40 |
bool operator==(const GraphiteResourceKey& that) const { |
| 41 |
return this->ResourceKey::operator==(that); |
| 42 |
} |
| 43 |
bool operator!=(const GraphiteResourceKey& that) const { |
| 44 |
return !(*this == that); |
| 45 |
} |
| 46 |
|
| 47 |
class Builder : public ResourceKey::Builder { |
| 48 |
public: |
| 49 |
Builder(GraphiteResourceKey* key, ResourceType type, uint16_t data32Count) |
| 50 |
: ResourceKey::Builder(key, type, data32Count) {} |
| 51 |
}; |
| 52 |
}; |
| 53 |
|
| 54 |
} // namespace skgpu::graphite |
| 55 |
|
| 56 |
#endif // skgpu_graphite_GraphiteResourceKey_DEFINED |