#include "src/gpu/ganesh/mock/GrMockGpu.h"
#include "include/gpu/GpuTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMath.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrGpuBuffer.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h"
#include "src/gpu/ganesh/mock/GrMockAttachment.h"
#include "src/gpu/ganesh/mock/GrMockBuffer.h"
#include "src/gpu/ganesh/mock/GrMockCaps.h"
#include "src/gpu/ganesh/mock/GrMockOpsRenderPass.h"
#include "src/gpu/ganesh/mock/GrMockTexture.h"
#include <atomic>
usingnamespaceskia_private;
int GrMockGpu::NextInternalTextureID() { … }
int GrMockGpu::NextExternalTextureID() { … }
int GrMockGpu::NextInternalRenderTargetID() { … }
int GrMockGpu::NextExternalRenderTargetID() { … }
std::unique_ptr<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
const GrContextOptions& contextOptions,
GrDirectContext* direct) { … }
GrOpsRenderPass* GrMockGpu::onGetOpsRenderPass(GrRenderTarget* rt,
bool ,
GrAttachment*,
GrSurfaceOrigin origin,
const SkIRect& bounds,
const GrOpsRenderPass::LoadAndStoreInfo& colorInfo,
const GrOpsRenderPass::StencilLoadAndStoreInfo&,
const TArray<GrSurfaceProxy*,true>& sampledProxies,
GrXferBarrierFlags renderPassXferBarriers) { … }
void GrMockGpu::submit(GrOpsRenderPass* renderPass) { … }
GrMockGpu::GrMockGpu(GrDirectContext* direct, const GrMockOptions& options,
const GrContextOptions& contextOptions)
: … { … }
GrMockGpu::~GrMockGpu() { … }
GrThreadSafePipelineBuilder* GrMockGpu::pipelineBuilder() { … }
sk_sp<GrThreadSafePipelineBuilder> GrMockGpu::refPipelineBuilder() { … }
sk_sp<GrTexture> GrMockGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
skgpu::Budgeted budgeted,
GrProtected isProtected,
int mipLevelCount,
uint32_t levelClearMask,
std::string_view label) { … }
sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(SkISize dimensions,
const GrBackendFormat& format,
skgpu::Budgeted budgeted,
skgpu::Mipmapped mipmapped,
GrProtected isProtected,
const void* data,
size_t dataSize) { … }
sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
GrWrapOwnership ownership,
GrWrapCacheable wrapType,
GrIOType ioType) { … }
sk_sp<GrTexture> GrMockGpu::onWrapCompressedBackendTexture(const GrBackendTexture& tex,
GrWrapOwnership ownership,
GrWrapCacheable wrapType) { … }
sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
int sampleCnt,
GrWrapOwnership ownership,
GrWrapCacheable cacheable) { … }
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) { … }
sk_sp<GrGpuBuffer> GrMockGpu::onCreateBuffer(size_t sizeInBytes,
GrGpuBufferType type,
GrAccessPattern accessPattern) { … }
sk_sp<GrAttachment> GrMockGpu::makeStencilAttachment(const GrBackendFormat& ,
SkISize dimensions, int numStencilSamples) { … }
GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable,
skgpu::Mipmapped mipmapped,
GrProtected isProtected,
std::string_view label) { … }
GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(SkISize dimensions,
const GrBackendFormat& format,
skgpu::Mipmapped mipmapped,
GrProtected isProtected) { … }
void GrMockGpu::deleteBackendTexture(const GrBackendTexture& tex) { … }
#if defined(GPU_TEST_UTILS)
bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
SkASSERT(GrBackendApi::kMock == tex.backend());
GrMockTextureInfo info;
if (!tex.getMockTextureInfo(&info)) {
return false;
}
return fOutstandingTestingOnlyTextureIDs.contains(info.id());
}
GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(SkISize dimensions,
GrColorType colorType,
int sampleCnt,
GrProtected isProtected) {
GrMockRenderTargetInfo info(colorType, NextExternalRenderTargetID(), isProtected);
static constexpr int kStencilBits = 8;
return GrBackendRenderTarget(dimensions.width(), dimensions.height(), sampleCnt, kStencilBits,
info);
}
void GrMockGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) {}
#endif