23#include <unordered_set>
29Recording::Recording(uint32_t uniqueID,
33 std::unique_ptr<LazyProxyData> targetProxyData,
36 , fRecorderID(recorderID)
37 , fRootTaskList(new TaskList)
38 , fNonVolatileLazyProxies(
std::move(nonVolatileLazyProxies))
39 , fVolatileLazyProxies(
std::move(volatileLazyProxies))
40 , fTargetProxyData(
std::move(targetProxyData))
41 , fFinishedProcs(
std::move(finishedProcs)) {}
43Recording::~Recording() {
45 this->
priv().setFailureResultForFinishedProcs();
52Recording::LazyProxyData::LazyProxyData(
const TextureInfo& textureInfo) {
53 fTargetProxy = TextureProxy::MakeFullyLazy(
56 return std::move(fTarget);
60TextureProxy* Recording::LazyProxyData::lazyProxy() {
return fTargetProxy.get(); }
64bool Recording::LazyProxyData::lazyInstantiate(
ResourceProvider* resourceProvider,
67 return fTargetProxy->lazyInstantiate(resourceProvider);
71bool RecordingPriv::hasNonVolatileLazyProxies()
const {
72 return !fRecording->fNonVolatileLazyProxies.empty();
75bool RecordingPriv::instantiateNonVolatileLazyProxies(
ResourceProvider* resourceProvider) {
76 SkASSERT(this->hasNonVolatileLazyProxies());
78 for (
const auto& proxy : fRecording->fNonVolatileLazyProxies) {
79 if (!proxy->lazyInstantiate(resourceProvider)) {
86 fRecording->fNonVolatileLazyProxies.clear();
90bool RecordingPriv::hasVolatileLazyProxies()
const {
91 return !fRecording->fVolatileLazyProxies.empty();
94bool RecordingPriv::instantiateVolatileLazyProxies(
ResourceProvider* resourceProvider) {
95 SkASSERT(this->hasVolatileLazyProxies());
97 for (
const auto& proxy : fRecording->fVolatileLazyProxies) {
98 if (!proxy->lazyInstantiate(resourceProvider)) {
106void RecordingPriv::deinstantiateVolatileLazyProxies() {
107 if (!this->hasVolatileLazyProxies()) {
111 for (
const auto& proxy : fRecording->fVolatileLazyProxies) {
113 proxy->deinstantiate();
117void RecordingPriv::setFailureResultForFinishedProcs() {
118 for (
int i = 0;
i < fRecording->fFinishedProcs.size(); ++
i) {
119 fRecording->fFinishedProcs[
i]->setFailureResult();
121 fRecording->fFinishedProcs.clear();
124bool RecordingPriv::addCommands(
Context* context,
129 fRecording->fTargetProxyData ? fRecording->fTargetProxyData->lazyProxy() :
nullptr);
131 const Texture* replayTarget =
nullptr;
134 if (fRecording->fTargetProxyData) {
135 if (!targetSurface) {
136 SKGPU_LOG_E(
"No surface provided to instantiate target texture proxy.");
140 if (!surfaceTexture->
instantiate(resourceProvider)) {
141 SKGPU_LOG_E(
"Could not instantiate target texture proxy.");
144 if (!fRecording->fTargetProxyData->lazyInstantiate(resourceProvider,
146 SKGPU_LOG_E(
"Could not instantiate deferred texture proxy.");
149 replayTarget = surfaceTexture->
texture();
152 for (
size_t i = 0;
i < fRecording->fExtraResourceRefs.size(); ++
i) {
159 if (fRecording->fRootTaskList->addCommands(
163 for (
int i = 0;
i < fRecording->fFinishedProcs.size(); ++
i) {
166 fRecording->fFinishedProcs.clear();
172 fRecording->fExtraResourceRefs.push_back(std::move(
resource));
176 fRecording->fRootTaskList->add(std::move(task));
180 fRecording->fRootTaskList->add(std::move(tasks));
183#if defined(GRAPHITE_TEST_UTILS)
184bool RecordingPriv::isTargetProxyInstantiated()
const {
185 return fRecording->fTargetProxyData->lazyProxy()->isInstantiated();
188int RecordingPriv::numVolatilePromiseImages()
const {
189 return fRecording->fVolatileLazyProxies.size();
192int RecordingPriv::numNonVolatilePromiseImages()
const {
193 return fRecording->fNonVolatileLazyProxies.size();
196bool RecordingPriv::hasTasks()
const {
197 return fRecording->fRootTaskList->hasTasks();
#define SKGPU_LOG_E(fmt,...)
static SkString resource(SkPDFResourceType type, int index)
static constexpr bool SkToBool(const T &x)
void trackResource(sk_sp< Resource > resource)
void addFinishedProc(sk_sp< RefCntedCallback > finishedProc)
ResourceProvider * resourceProvider() const
TextureProxy * backingTextureProxy() const
bool instantiate(ResourceProvider *)
sk_sp< Texture > refTexture() const
const Texture * texture() const
FlPixelBufferTexturePrivate * priv