26int GrMockGpu::NextInternalTextureID() {
27 static std::atomic<int> nextID{1};
30 id = nextID.fetch_add(1, std::memory_order_relaxed);
35int GrMockGpu::NextExternalTextureID() {
38 static std::atomic<int> nextID{-1};
39 return nextID.fetch_add(-1, std::memory_order_relaxed);
42int GrMockGpu::NextInternalRenderTargetID() {
45 static std::atomic<int> nextID{
SK_MaxS32};
46 return nextID.fetch_add(-1, std::memory_order_relaxed);
49int GrMockGpu::NextExternalRenderTargetID() {
52 static std::atomic<int> nextID{
SK_MinS32};
53 return nextID.fetch_add(1, std::memory_order_relaxed);
61 mockOptions = &kDefaultOptions;
63 return std::unique_ptr<GrGpu>(
new GrMockGpu(direct, *mockOptions, contextOptions));
79 for (
int i = 0; i < static_cast<GrMockOpsRenderPass*>(renderPass)->numDraws(); ++i) {
105 int renderTargetSampleCnt,
109 uint32_t levelClearMask,
110 std::string_view label) {
125 if (renderable == GrRenderable::kYes) {
128 renderTargetSampleCnt,
135 this, budgeted, dimensions, mipmapStatus, texInfo, label));
156 GrMipmapStatus mipmapStatus = (mipmapped == skgpu::Mipmapped::kYes)
160 format.asMockCompressionType(),
161 NextInternalTextureID(),
165 this, budgeted, dimensions, mipmapStatus, texInfo,
166 "MockGpu_CreateCompressedTexture"));
189 "MockGpu_WrapBackendTexture"));
221 "MockGpu_WrapRenderableBackendTexture"));
234 "MockGpu_WrapBackendRenderTarget"));
242 "MockGpu_CreateBuffer"));
246 SkISize dimensions,
int numStencilSamples) {
252 "MockGpu_MakeStencilAttachment"));
260 std::string_view label) {
274 fOutstandingTestingOnlyTextureIDs.
add(
info.id());
294 fOutstandingTestingOnlyTextureIDs.
add(
info.id());
303 fOutstandingTestingOnlyTextureIDs.
remove(
info.id());
307#if defined(GR_TEST_UTILS)
308bool GrMockGpu::isTestingOnlyBackendTexture(
const GrBackendTexture& tex)
const {
316 return fOutstandingTestingOnlyTextureIDs.
contains(
info.id());
324 static constexpr int kStencilBits = 8;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SkAssertResult(cond)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr int32_t SK_MinS32
static constexpr int32_t SK_MaxS32
#define INHERITED(method,...)
bool getMockRenderTargetInfo(GrMockRenderTargetInfo *) const
SkISize dimensions() const
SkISize dimensions() const
bool getMockTextureInfo(GrMockTextureInfo *) const
GrBackendApi backend() const
void incStencilAttachmentCreates()
const GrCaps * caps() const
void initCaps(sk_sp< const GrCaps > caps)
sk_sp< GrThreadSafePipelineBuilder > refPipelineBuilder() override
sk_sp< GrGpuBuffer > onCreateBuffer(size_t sizeInBytes, GrGpuBufferType, GrAccessPattern) override
static std::unique_ptr< GrGpu > Make(const GrMockOptions *, const GrContextOptions &, GrDirectContext *)
void submit(GrOpsRenderPass *renderPass) override
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions, const GrBackendFormat &, skgpu::Mipmapped, GrProtected) override
sk_sp< GrTexture > onWrapCompressedBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable) override
sk_sp< GrRenderTarget > onWrapBackendRenderTarget(const GrBackendRenderTarget &) override
GrThreadSafePipelineBuilder * pipelineBuilder() override
sk_sp< GrTexture > onWrapRenderableBackendTexture(const GrBackendTexture &, int sampleCnt, GrWrapOwnership, GrWrapCacheable) override
sk_sp< GrTexture > onCreateTexture(SkISize, const GrBackendFormat &, GrRenderable, int renderTargetSampleCnt, skgpu::Budgeted, GrProtected, int mipLevelCount, uint32_t levelClearMask, std::string_view label) override
sk_sp< GrTexture > onCreateCompressedTexture(SkISize dimensions, const GrBackendFormat &, skgpu::Budgeted, skgpu::Mipmapped, GrProtected, const void *data, size_t dataSize) override
sk_sp< GrAttachment > makeStencilAttachment(const GrBackendFormat &, SkISize dimensions, int numStencilSamples) override
void deleteBackendTexture(const GrBackendTexture &) override
GrBackendTexture onCreateBackendTexture(SkISize dimensions, const GrBackendFormat &, GrRenderable, skgpu::Mipmapped, GrProtected, std::string_view label) override
GrOpsRenderPass * onGetOpsRenderPass(GrRenderTarget *, bool useMSAASurface, GrAttachment *, GrSurfaceOrigin, const SkIRect &, const GrOpsRenderPass::LoadAndStoreInfo &, const GrOpsRenderPass::StencilLoadAndStoreInfo &, const skia_private::TArray< GrSurfaceProxy *, true > &sampledProxies, GrXferBarrierFlags renderPassXferBarriers) override
sk_sp< GrTexture > onWrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType) override
bool contains(const T &item) const
void remove(const T &item)
uint32_t uint32_t * format
bool fFailTextureAllocations
SkTextureCompressionType compressionType() const
GrColorType colorType() const
skgpu::Protected getProtected() const
constexpr int32_t width() const
constexpr int32_t height() const