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_RecorderPriv_DEFINED 9 #define skgpu_graphite_RecorderPriv_DEFINED 10 11 #include <functional> 12 13 #include "include/gpu/graphite/Recorder.h" 14 #include "src/gpu/graphite/SharedContext.h" 15 16 namespace skgpu::graphite { 17 18 class ShaderCodeDictionary; 19 class TextureProxy; 20 21 class RecorderPriv { 22 public: 23 void add(sk_sp<Task>); 24 void flushTrackedDevices(); 25 caps()26 const Caps* caps() const { return fRecorder->fSharedContext->caps(); } 27 resourceProvider()28 ResourceProvider* resourceProvider() { return fRecorder->fResourceProvider.get(); } 29 runtimeEffectDictionary()30 const RuntimeEffectDictionary* runtimeEffectDictionary() const { 31 return fRecorder->fRuntimeEffectDict.get(); 32 } runtimeEffectDictionary()33 RuntimeEffectDictionary* runtimeEffectDictionary() { 34 return fRecorder->fRuntimeEffectDict.get(); 35 } shaderCodeDictionary()36 const ShaderCodeDictionary* shaderCodeDictionary() const { 37 return fRecorder->fSharedContext->shaderCodeDictionary(); 38 } shaderCodeDictionary()39 ShaderCodeDictionary* shaderCodeDictionary() { 40 return fRecorder->fSharedContext->shaderCodeDictionary(); 41 } 42 rendererProvider()43 const RendererProvider* rendererProvider() const { 44 return fRecorder->fSharedContext->rendererProvider(); 45 } 46 uniformDataCache()47 UniformDataCache* uniformDataCache() { return fRecorder->fUniformDataCache.get(); } textureDataCache()48 TextureDataCache* textureDataCache() { return fRecorder->fTextureDataCache.get(); } drawBufferManager()49 DrawBufferManager* drawBufferManager() { return fRecorder->fDrawBufferManager.get(); } uploadBufferManager()50 UploadBufferManager* uploadBufferManager() { return fRecorder->fUploadBufferManager.get(); } 51 atlasManager()52 AtlasManager* atlasManager() { return fRecorder->fAtlasManager.get(); } tokenTracker()53 TokenTracker* tokenTracker() { return fRecorder->fTokenTracker.get(); } strikeCache()54 sktext::gpu::StrikeCache* strikeCache() { return fRecorder->fStrikeCache.get(); } textBlobCache()55 sktext::gpu::TextBlobRedrawCoordinator* textBlobCache() { 56 return fRecorder->fTextBlobCache.get(); 57 } 58 59 #if GRAPHITE_TEST_UTILS 60 // used by the Context that created this Recorder to set a back pointer 61 void setContext(Context*); context()62 Context* context() { return fRecorder->fContext; } 63 #endif 64 65 private: RecorderPriv(Recorder * recorder)66 explicit RecorderPriv(Recorder* recorder) : fRecorder(recorder) {} 67 RecorderPriv& operator=(const RecorderPriv&) = delete; 68 69 // No taking addresses of this type. 70 const RecorderPriv* operator&() const = delete; 71 RecorderPriv* operator&() = delete; 72 73 Recorder* fRecorder; 74 75 friend class Recorder; // to construct/copy this type. 76 }; 77 priv()78inline RecorderPriv Recorder::priv() { 79 return RecorderPriv(this); 80 } 81 priv()82inline const RecorderPriv Recorder::priv() const { // NOLINT(readability-const-return-type) 83 return RecorderPriv(const_cast<Recorder*>(this)); 84 } 85 86 } // namespace skgpu::graphite 87 88 #endif // skgpu_graphite_RecorderPriv_DEFINED 89