| 1 |
/* |
| 2 |
* Copyright 2025 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 GraphiteMemoryPipelineStorage_DEFINED |
| 9 |
#define GraphiteMemoryPipelineStorage_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkData.h" |
| 12 |
#include "include/gpu/graphite/PersistentPipelineStorage.h" |
| 13 |
|
| 14 |
namespace sk_gpu_test { |
| 15 |
|
| 16 |
/** |
| 17 |
* This class can be used to store backend-specific Pipeline data |
| 18 |
*/ |
| 19 |
class GraphiteMemoryPipelineStorage : public skgpu::graphite::PersistentPipelineStorage { |
| 20 |
public: |
| 21 |
GraphiteMemoryPipelineStorage() = default; |
| 22 |
GraphiteMemoryPipelineStorage(const GraphiteMemoryPipelineStorage&) = delete; |
| 23 |
GraphiteMemoryPipelineStorage& operator=(const GraphiteMemoryPipelineStorage&) = delete; |
| 24 |
|
| 25 |
sk_sp<SkData> load() override; |
| 26 |
void store(const SkData& data) override; |
| 27 |
|
| 28 |
int numLoads() const { return fLoadCount; } |
| 29 |
int numStores() const { return fStoreCount; } |
| 30 |
void resetCacheStats() { |
| 31 |
fLoadCount = 0; |
| 32 |
fStoreCount = 0; |
| 33 |
} |
| 34 |
void reset() { |
| 35 |
this->resetCacheStats(); |
| 36 |
fData.reset(); |
| 37 |
} |
| 38 |
|
| 39 |
private: |
| 40 |
int fLoadCount = 0; |
| 41 |
int fStoreCount = 0; |
| 42 |
sk_sp<SkData> fData; |
| 43 |
}; |
| 44 |
|
| 45 |
} // namespace sk_gpu_test |
| 46 |
|
| 47 |
#endif // GraphiteMemoryPipelineStorage_DEFINED |