| 1 |
/* |
| 2 |
* Copyright 2024 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_PrecompileContextPriv_DEFINED |
| 9 |
#define skgpu_graphite_PrecompileContextPriv_DEFINED |
| 10 |
|
| 11 |
#include "include/gpu/graphite/PrecompileContext.h" |
| 12 |
#include "src/gpu/graphite/SharedContext.h" |
| 13 |
|
| 14 |
class Caps; |
| 15 |
|
| 16 |
namespace skgpu::graphite { |
| 17 |
|
| 18 |
/** |
| 19 |
* Class that adds methods to PrecompileContext that are only intended for use internal to Skia. |
| 20 |
* This class is purely a privileged window into PrecompileContext. It should never have additional |
| 21 |
* data members or virtual methods. |
| 22 |
*/ |
| 23 |
class PrecompileContextPriv { |
| 24 |
public: |
| 25 |
const Caps* caps() const { return fPrecompileContext->fSharedContext->caps(); } |
| 26 |
const ShaderCodeDictionary* shaderCodeDictionary() const { |
| 27 |
return fPrecompileContext->fSharedContext->shaderCodeDictionary(); |
| 28 |
} |
| 29 |
ShaderCodeDictionary* shaderCodeDictionary() { |
| 30 |
return fPrecompileContext->fSharedContext->shaderCodeDictionary(); |
| 31 |
} |
| 32 |
const RendererProvider* rendererProvider() const { |
| 33 |
return fPrecompileContext->fSharedContext->rendererProvider(); |
| 34 |
} |
| 35 |
SharedContext* sharedContext() { |
| 36 |
return fPrecompileContext->fSharedContext.get(); |
| 37 |
} |
| 38 |
ResourceProvider* resourceProvider() { |
| 39 |
return fPrecompileContext->fResourceProvider.get(); |
| 40 |
} |
| 41 |
#if defined(GPU_TEST_UTILS) |
| 42 |
GlobalCache* globalCache() { |
| 43 |
return fPrecompileContext->fSharedContext->globalCache(); |
| 44 |
} |
| 45 |
#endif |
| 46 |
|
| 47 |
private: |
| 48 |
friend class PrecompileContext; // to construct/copy this type. |
| 49 |
|
| 50 |
explicit PrecompileContextPriv(PrecompileContext* precompileContext) |
| 51 |
: fPrecompileContext(precompileContext) {} |
| 52 |
|
| 53 |
PrecompileContextPriv& operator=(const PrecompileContextPriv&) = delete; |
| 54 |
|
| 55 |
// No taking addresses of this type. |
| 56 |
const PrecompileContextPriv* operator&() const; |
| 57 |
PrecompileContextPriv *operator&(); |
| 58 |
|
| 59 |
PrecompileContext* fPrecompileContext; |
| 60 |
}; |
| 61 |
|
| 62 |
inline PrecompileContextPriv PrecompileContext::priv() { return PrecompileContextPriv(this); } |
| 63 |
|
| 64 |
// NOLINTNEXTLINE(readability-const-return-type) |
| 65 |
inline const PrecompileContextPriv PrecompileContext::priv() const { |
| 66 |
return PrecompileContextPriv(const_cast<PrecompileContext *>(this)); |
| 67 |
} |
| 68 |
|
| 69 |
} // namespace skgpu::graphite |
| 70 |
|
| 71 |
#endif // skgpu_graphite_PrecompileContextPriv_DEFINED |