Flutter Engine
The Flutter Engine
GrMockGpu.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 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 GrMockGpu_DEFINED
9#define GrMockGpu_DEFINED
10
11#include "include/core/SkRect.h"
13#include "include/core/SkSize.h"
16#include "include/gpu/GrTypes.h"
21#include "src/core/SkTHash.h"
26#include "src/gpu/ganesh/GrSemaphore.h" // IWYU pragma: keep
28
29#include <array>
30#include <cstddef>
31#include <cstdint>
32#include <memory>
33#include <string_view>
34
36class GrDirectContext;
37class GrGpuBuffer;
38class GrProgramDesc;
39class GrProgramInfo;
40class GrRenderTarget;
41class GrSurface;
42class GrSurfaceProxy;
43class GrTexture;
45struct GrContextOptions;
46
47namespace skgpu {
48class RefCntedCallback;
49enum class Budgeted : bool;
50enum class Mipmapped : bool;
51}
52
53class GrMockGpu : public GrGpu {
54public:
55 static std::unique_ptr<GrGpu> Make(const GrMockOptions*,
56 const GrContextOptions&,
58
59 ~GrMockGpu() override;
60
63
64 [[nodiscard]] std::unique_ptr<GrSemaphore> makeSemaphore(bool isOwned) override {
65 return nullptr;
66 }
67 std::unique_ptr<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& /* semaphore */,
68 GrSemaphoreWrapType /* wraptype */,
69 GrWrapOwnership /* ownership */) override {
70 return nullptr;
71 }
72 void insertSemaphore(GrSemaphore* semaphore) override {}
73 void waitSemaphore(GrSemaphore* semaphore) override {}
74 std::unique_ptr<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override {
75 return nullptr;
76 }
77
78 void submit(GrOpsRenderPass* renderPass) override;
79
80 void checkFinishProcs() override {}
81 void finishOutstandingGpuWork() override {}
82
83private:
85
86 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
87
88 sk_sp<GrTexture> onCreateTexture(SkISize,
89 const GrBackendFormat&,
91 int renderTargetSampleCnt,
94 int mipLevelCount,
95 uint32_t levelClearMask,
96 std::string_view label) override;
97
98 sk_sp<GrTexture> onCreateCompressedTexture(SkISize dimensions,
99 const GrBackendFormat&,
103 const void* data,
104 size_t dataSize) override;
105
106 sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
109 GrIOType) override;
110 sk_sp<GrTexture> onWrapCompressedBackendTexture(const GrBackendTexture&,
112 GrWrapCacheable) override;
113
114 sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
115 int sampleCnt,
117 GrWrapCacheable) override;
118
119 sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
120
121 sk_sp<GrGpuBuffer> onCreateBuffer(size_t sizeInBytes,
123 GrAccessPattern) override;
124
125 bool onReadPixels(GrSurface*,
126 SkIRect,
127 GrColorType surfaceColorType,
128 GrColorType dstColorType,
129 void*,
130 size_t rowBytes) override {
131 return true;
132 }
133
134 bool onWritePixels(GrSurface*,
135 SkIRect,
136 GrColorType surfaceColorType,
137 GrColorType srcColorType,
138 const GrMipLevel[],
139 int mipLevelCount,
140 bool prepForTexSampling) override {
141 return true;
142 }
143
144 bool onTransferFromBufferToBuffer(sk_sp<GrGpuBuffer> src,
145 size_t srcOffset,
147 size_t dstOffset,
148 size_t size) override {
149 return true;
150 }
151
152 bool onTransferPixelsTo(GrTexture*,
153 SkIRect,
154 GrColorType surfaceColorType,
155 GrColorType bufferColorType,
157 size_t offset,
158 size_t rowBytes) override {
159 return true;
160 }
161
162 bool onTransferPixelsFrom(GrSurface*,
163 SkIRect,
164 GrColorType surfaceColorType,
165 GrColorType bufferColorType,
167 size_t offset) override {
168 return true;
169 }
170
171 bool onCopySurface(GrSurface* dst, const SkIRect& dstRect,
172 GrSurface* src, const SkIRect& srcRect,
173 GrSamplerState::Filter)override {
174 return true;
175 }
176
177 bool onRegenerateMipMapLevels(GrTexture*) override { return true; }
178
179 void onResolveRenderTarget(GrRenderTarget* target, const SkIRect&) override {}
180
181 void addFinishedProc(GrGpuFinishedProc finishedProc,
182 GrGpuFinishedContext finishedContext) override {
183 SkASSERT(finishedProc);
184 finishedProc(finishedContext);
185 }
186
187 GrOpsRenderPass* onGetOpsRenderPass(
189 bool useMSAASurface,
192 const SkIRect&,
196 GrXferBarrierFlags renderPassXferBarriers) override;
197
198 bool onSubmitToGpu(GrSyncCpu) override { return true; }
199
200 sk_sp<GrAttachment> makeStencilAttachment(const GrBackendFormat& /*colorFormat*/,
201 SkISize dimensions, int numStencilSamples) override;
202
203 GrBackendFormat getPreferredStencilFormat(const GrBackendFormat&) override {
205 true);
206 }
207
208 sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
209 const GrBackendFormat& format,
210 int numSamples,
211 GrProtected isProtected,
212 GrMemoryless isMemoryless) override {
213 return nullptr;
214 }
215
216 GrBackendTexture onCreateBackendTexture(SkISize dimensions,
217 const GrBackendFormat&,
221 std::string_view label) override;
222
223 bool onClearBackendTexture(const GrBackendTexture&,
224 sk_sp<skgpu::RefCntedCallback> finishedCallback,
225 std::array<float, 4> color) override {
226 return true;
227 }
228
229 GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
230 const GrBackendFormat&,
232 GrProtected) override;
233
234 bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
235 sk_sp<skgpu::RefCntedCallback> finishedCallback,
236 const void*,
237 size_t) override {
238 return true;
239 }
240
241 void deleteBackendTexture(const GrBackendTexture&) override;
242
243 bool compile(const GrProgramDesc&, const GrProgramInfo&) override { return false; }
244
245#if defined(GR_TEST_UTILS)
246 bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
247
248 GrBackendRenderTarget createTestingOnlyBackendRenderTarget(SkISize dimensions,
250 int sampleCnt,
251 GrProtected) override;
252 void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override;
253#endif
254
255 const GrMockOptions fMockOptions;
256
257 static int NextInternalTextureID();
258 static int NextExternalTextureID();
259 static int NextInternalRenderTargetID();
260 static int NextExternalRenderTargetID();
261
262 skia_private::THashSet<int> fOutstandingTestingOnlyTextureIDs;
263
264 using INHERITED = GrGpu;
265};
266
267#endif
GrWrapCacheable
Definition: GrTypesPriv.h:85
GrIOType
Definition: GrTypesPriv.h:402
GrWrapOwnership
Definition: GrTypesPriv.h:77
GrGpuBufferType
Definition: GrTypesPriv.h:411
GrMemoryless
Definition: GrTypesPriv.h:123
GrSemaphoreWrapType
Definition: GrTypesPriv.h:146
GrColorType
Definition: GrTypesPriv.h:540
GrAccessPattern
Definition: GrTypesPriv.h:424
GrSurfaceOrigin
Definition: GrTypes.h:147
void * GrGpuFinishedContext
Definition: GrTypes.h:178
void(* GrGpuFinishedProc)(GrGpuFinishedContext finishedContext)
Definition: GrTypes.h:179
GrSyncCpu
Definition: GrTypes.h:239
GrXferBarrierType
GrXferBarrierFlags
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkFilterMode
static GrBackendFormat MakeMock(GrColorType colorType, SkTextureCompressionType compression, bool isStencilFormat=false)
Definition: GrGpu.h:62
GrGpu(GrDirectContext *direct)
Definition: GrGpu.cpp:41
sk_sp< GrThreadSafePipelineBuilder > refPipelineBuilder() override
Definition: GrMockGpu.cpp:99
std::unique_ptr< GrSemaphore > prepareTextureForCrossContextUsage(GrTexture *) override
Definition: GrMockGpu.h:74
static std::unique_ptr< GrGpu > Make(const GrMockOptions *, const GrContextOptions &, GrDirectContext *)
Definition: GrMockGpu.cpp:57
void submit(GrOpsRenderPass *renderPass) override
Definition: GrMockGpu.cpp:79
std::unique_ptr< GrSemaphore > wrapBackendSemaphore(const GrBackendSemaphore &, GrSemaphoreWrapType, GrWrapOwnership) override
Definition: GrMockGpu.h:67
void checkFinishProcs() override
Definition: GrMockGpu.h:80
GrThreadSafePipelineBuilder * pipelineBuilder() override
Definition: GrMockGpu.cpp:95
void insertSemaphore(GrSemaphore *semaphore) override
Definition: GrMockGpu.h:72
~GrMockGpu() override
Definition: GrMockGpu.cpp:93
void finishOutstandingGpuWork() override
Definition: GrMockGpu.h:81
std::unique_ptr< GrSemaphore > makeSemaphore(bool isOwned) override
Definition: GrMockGpu.h:64
void waitSemaphore(GrSemaphore *semaphore) override
Definition: GrMockGpu.h:73
DlColor color
uint32_t uint32_t * format
uint32_t * target
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
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
SeparatedVector2 offset
Definition: SkRect.h:32
Definition: SkSize.h:16
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63