/* * Copyright 2021 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef skgpu_graphite_Recording_DEFINED #define skgpu_graphite_Recording_DEFINED #include "include/core/SkRefCnt.h" #include "include/private/SkAPI.h" #include "include/private/SkTArray.h" #include #include #include #include #include struct SkISize; class SkPicture; namespace skgpu { class RefCntedCallback; } namespace skgpu::graphite { class Caps; class CommandBuffer; class RecordingPriv; class Resource; class ResourceProvider; class TaskList; class Texture; class TextureInfo; class TextureProxy; class SK_API Recording final { public: ~Recording(); RecordingPriv priv(); private: friend class Recorder; // for ctor and LazyProxyData friend class RecordingPriv; // LazyProxyData is used if this recording should be replayed to a target that is provided on // replay, and it handles the target proxy's instantiation with the provided target. class LazyProxyData { public: LazyProxyData(const Caps*, SkISize dimensions, const TextureInfo&); ~LazyProxyData(); TextureProxy* lazyProxy(); sk_sp refLazyProxy(); bool lazyInstantiate(ResourceProvider*, sk_sp); private: sk_sp fTarget; sk_sp fTargetProxy; }; struct ProxyHash { std::size_t operator()(const sk_sp& proxy) const; }; Recording(uint32_t uniqueID, uint32_t recorderID, std::unique_ptr targetProxyData, skia_private::TArray>&& finishedProcs); void addResourceRef(sk_sp); // Used to verify ordering if recorder ID is not SK_InvalidGenID uint32_t fUniqueID; uint32_t fRecorderID; // We don't always take refs to all resources used by specific Tasks (e.g. a common buffer used // for uploads). Instead we'll just hold onto one ref for those Resources outside the Tasks. // Those refs are stored in the array here and will eventually be passed onto a CommandBuffer // when the Recording adds its commands. std::vector> fExtraResourceRefs; // This is held by a pointer instead of being inline to allow TaskList to be forward declared. // Depends on fExtraResourceRefs (tasks reference resources). Must be destroyed first. std::unique_ptr fRootTaskList; std::unordered_set, ProxyHash> fNonVolatileLazyProxies; std::unordered_set, ProxyHash> fVolatileLazyProxies; std::unique_ptr fTargetProxyData; skia_private::TArray> fFinishedProcs; skia_private::TArray> fCapturedPictures; }; } // namespace skgpu::graphite #endif // skgpu_graphite_Recording_DEFINED