Flutter Engine
The Flutter Engine
GrRecordingContextPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
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 GrRecordingContextPriv_DEFINED
9#define GrRecordingContextPriv_DEFINED
10
19
20class GrImageInfo;
22namespace skgpu {
23 class Swizzle;
24}
25namespace skgpu::ganesh {
26class SurfaceContext;
27class SurfaceFillContext;
28} // namespace skgpu::ganesh
29
30/** Class that exposes methods on GrRecordingContext that are only intended for use internal to
31 Skia. This class is purely a privileged window into GrRecordingContext. It should never have
32 additional data members or virtual methods. */
34public:
36 const GrRecordingContext* context() const {
37 return static_cast<const GrRecordingContext*>(fContext);
38 }
39
41 const GrProxyProvider* proxyProvider() const { return this->context()->proxyProvider(); }
42
44
47 return this->context()->arenas().recordTimeSubRunAllocator();
48 }
50
52
53 void recordProgramInfo(const GrProgramInfo* programInfo) {
54 this->context()->recordProgramInfo(programInfo);
55 }
56
58 this->context()->detachProgramData(dst);
59 }
60
62 return this->context()->getTextBlobRedrawCoordinator();
63 }
64
66
68
69 /**
70 * Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.)
71 *
72 * NOTE: the drawing manager tracks this object as a raw pointer; it is up to the caller to
73 * ensure its lifetime is tied to that of the context.
74 */
76
77 GrAuditTrail* auditTrail() { return this->context()->fAuditTrail.get(); }
78
79#if defined(GR_TEST_UTILS)
80 // Used by tests that intentionally exercise codepaths that print warning messages, in order to
81 // not confuse users with output that looks like a testing failure.
82 class AutoSuppressWarningMessages {
83 public:
84 AutoSuppressWarningMessages(GrRecordingContext* context) : fContext(context) {
85 ++fContext->fSuppressWarningMessages;
86 }
87 ~AutoSuppressWarningMessages() {
88 --fContext->fSuppressWarningMessages;
89 }
90 private:
92 };
93 void incrSuppressWarningMessages() { ++this->context()->fSuppressWarningMessages; }
94 void decrSuppressWarningMessages() { --this->context()->fSuppressWarningMessages; }
95#endif
96
97 void printWarningMessage(const char* msg) const {
98#if defined(GR_TEST_UTILS)
99 if (this->context()->fSuppressWarningMessages > 0) {
100 return;
101 }
102#endif
103 SkDebugf("%s", msg);
104 }
105
107 return &this->context()->fStats;
108 }
109
110#if GR_GPU_STATS && defined(GR_TEST_UTILS)
111 using DMSAAStats = GrRecordingContext::DMSAAStats;
112 DMSAAStats& dmsaaStats() { return this->context()->fDMSAAStats; }
113#endif
114
115 sktext::gpu::SDFTControl getSDFTControl(bool useSDFTForSmallText) const;
116
117 /**
118 * Create a GrRecordingContext without a resource cache
119 */
121
126 const SkSurfaceProps&,
129 const SkImageInfo&,
131 int sampleCount,
135 const SkSurfaceProps&,
137
138 // If the passed in GrSurfaceProxy is renderable this will return a SurfaceDrawContext,
139 // otherwise it will return a SurfaceContext.
140 std::unique_ptr<skgpu::ganesh::SurfaceContext> makeSC(GrSurfaceProxyView readView,
141 const GrColorInfo&);
142
143 // Makes either a SurfaceContext, SurfaceFillContext, or a SurfaceDrawContext, depending on
144 // GrRenderable and the GrImageInfo.
145 std::unique_ptr<skgpu::ganesh::SurfaceContext> makeSC(
146 const GrImageInfo&,
147 const GrBackendFormat&,
148 std::string_view label,
152 int renderTargetSampleCnt = 1,
156
157 /**
158 * Uses GrImageInfo's color type to pick the default texture format. Will return a
159 * SurfaceDrawContext if possible.
160 */
161 std::unique_ptr<skgpu::ganesh::SurfaceFillContext> makeSFC(
163 std::string_view label,
165 int sampleCount = 1,
170
171 /**
172 * Makes a custom configured SurfaceFillContext where the caller specifies the specific
173 * texture format and swizzles. The color type will be kUnknown. Returns a SurfaceDrawContext
174 * if possible.
175 */
176 std::unique_ptr<skgpu::ganesh::SurfaceFillContext> makeSFC(SkAlphaType,
178 SkISize dimensions,
180 const GrBackendFormat&,
181 int sampleCount,
184 skgpu::Swizzle readSwizzle,
185 skgpu::Swizzle writeSwizzle,
188 std::string_view label);
189
190 /**
191 * Like the above but uses GetFallbackColorTypeAndFormat to find a fallback color type (and
192 * compatible format) if the passed GrImageInfo's color type is not renderable.
193 */
194 std::unique_ptr<skgpu::ganesh::SurfaceFillContext> makeSFCWithFallback(
197 int sampleCount,
202
203 /**
204 * Creates a SurfaceFillContext from an existing GrBackendTexture. The GrColorInfo's color
205 * type must be compatible with backend texture's format or this will fail. All formats are
206 * considered compatible with kUnknown. Returns a SurfaceDrawContext if possible.
207 */
208 std::unique_ptr<skgpu::ganesh::SurfaceFillContext> makeSFCFromBackendTexture(
210 const GrBackendTexture&,
211 int sampleCount,
213 sk_sp<skgpu::RefCntedCallback> releaseHelper);
214
215protected:
217
218private:
220 GrRecordingContextPriv& operator=(const GrRecordingContextPriv&) = delete;
221
222 // No taking addresses of this type.
223 const GrRecordingContextPriv* operator&() const;
224 GrRecordingContextPriv* operator&();
225
226 friend class GrRecordingContext; // to construct/copy this type.
227
229};
230
232
233inline const GrRecordingContextPriv GrRecordingContext::priv () const { // NOLINT(readability-const-return-type)
234 return GrRecordingContextPriv(const_cast<GrRecordingContext*>(this));
235}
236
237#endif
GrColorType
Definition: GrTypesPriv.h:540
GrSurfaceOrigin
Definition: GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
SkAlphaType
Definition: SkAlphaType.h:26
SkBackingFit
Definition: SkBackingFit.h:16
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GrContext_Base * fContext
friend class GrImageContextPriv
void addOnFlushCallbackObject(GrOnFlushCallbackObject *)
GrDrawingManager * drawingManager()
sktext::gpu::SubRunAllocator * recordTimeSubRunAllocator()
static sk_sp< GrRecordingContext > MakeDDL(sk_sp< GrContextThreadSafeProxy >)
GrProxyProvider * proxyProvider()
sktext::gpu::SDFTControl getSDFTControl(bool useSDFTForSmallText) const
GrThreadSafeCache * threadSafeCache()
GrRecordingContextPriv(GrRecordingContext *rContext)
GrRecordingContext::OwnedArenas && detachArenas()
void detachProgramData(skia_private::TArray< GrRecordingContext::ProgramData > *dst)
void recordProgramInfo(const GrProgramInfo *programInfo)
void printWarningMessage(const char *msg) const
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFCFromBackendTexture(GrColorInfo, const GrBackendTexture &, int sampleCount, GrSurfaceOrigin, sk_sp< skgpu::RefCntedCallback > releaseHelper)
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFCWithFallback(GrImageInfo, SkBackingFit, int sampleCount, skgpu::Mipmapped, skgpu::Protected, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
void moveRenderTasksToDDL(GrDeferredDisplayList *)
const GrProxyProvider * proxyProvider() const
GrRecordingContext::Arenas arenas()
const GrRecordingContext * context() const
sktext::gpu::TextBlobRedrawCoordinator * getTextBlobCache()
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
GrRecordingContext * context()
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFC(GrImageInfo, std::string_view label, SkBackingFit=SkBackingFit::kExact, int sampleCount=1, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Protected=skgpu::Protected::kNo, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
SkArenaAlloc * recordTimeAllocator()
sk_sp< skgpu::ganesh::Device > createDevice(GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &, skgpu::ganesh::Device::InitContents)
GrRecordingContext::Stats * stats()
SkArenaAlloc * recordTimeAllocator()
sktext::gpu::SubRunAllocator * recordTimeSubRunAllocator()
GrThreadSafeCache * threadSafeCache()
GrRecordingContextPriv priv()
virtual void detachProgramData(skia_private::TArray< ProgramData > *)
sktext::gpu::TextBlobRedrawCoordinator * getTextBlobRedrawCoordinator()
OwnedArenas && detachArenas()
class GrRecordingContext::Stats fStats
GrDrawingManager * drawingManager()
virtual void recordProgramInfo(const GrProgramInfo *)
GrProxyProvider * proxyProvider()
friend class GrRecordingContextPriv
std::unique_ptr< GrAuditTrail > fAuditTrail
dst
Definition: cp.py:12
Definition: GpuTools.h:21
Budgeted
Definition: GpuTypes.h:35
Renderable
Definition: GpuTypes.h:69
Mipmapped
Definition: GpuTypes.h:53
Protected
Definition: GpuTypes.h:61
Definition: SkSize.h:16