Make createTestingOnlyBackendTexture and deleteTestingOnlyBackendTexture no longer be behind GR_TEST_UTILS
Change-Id: Iec44bc46aa2ab2899af3f6df130a93adf3f26e2a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213821 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
9b2633e294
commit
50a4e6e3b1
@ -457,7 +457,6 @@ void GrGpu::dumpJSON(SkJSONWriter* writer) const {
|
||||
void GrGpu::dumpJSON(SkJSONWriter* writer) const { }
|
||||
#endif
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture GrGpu::createTestingOnlyBackendTexture(int w, int h, SkColorType colorType,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
@ -471,6 +470,8 @@ GrBackendTexture GrGpu::createTestingOnlyBackendTexture(int w, int h, SkColorTyp
|
||||
pixels, rowBytes);
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
#if GR_GPU_STATS
|
||||
void GrGpu::Stats::dump(SkString* out) {
|
||||
out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
|
||||
|
@ -394,7 +394,6 @@ public:
|
||||
Stats* stats() { return &fStats; }
|
||||
void dumpJSON(SkJSONWriter*) const;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(int w, int h, SkColorType,
|
||||
GrMipMapped, GrRenderable,
|
||||
const void* pixels = nullptr,
|
||||
@ -408,14 +407,16 @@ public:
|
||||
const void* pixels = nullptr,
|
||||
size_t rowBytes = 0) = 0;
|
||||
|
||||
/** Check a handle represents an actual texture in the backend API that has not been freed. */
|
||||
virtual bool isTestingOnlyBackendTexture(const GrBackendTexture&) const = 0;
|
||||
/**
|
||||
* Frees a texture created by createTestingOnlyBackendTexture(). If ownership of the backend
|
||||
* texture has been transferred to a GrContext using adopt semantics this should not be called.
|
||||
*/
|
||||
virtual void deleteTestingOnlyBackendTexture(const GrBackendTexture&) = 0;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
/** Check a handle represents an actual texture in the backend API that has not been freed. */
|
||||
virtual bool isTestingOnlyBackendTexture(const GrBackendTexture&) const = 0;
|
||||
|
||||
virtual GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h,
|
||||
GrColorType) = 0;
|
||||
|
||||
|
@ -4008,7 +4008,6 @@ void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) {
|
||||
}
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
static bool gl_format_to_pixel_config(GrGLenum format, GrPixelConfig* config) {
|
||||
GrPixelConfig dontCare;
|
||||
if (!config) {
|
||||
@ -4192,12 +4191,25 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(int w, int h,
|
||||
GL_CALL(BindTexture(info.fTarget, 0));
|
||||
|
||||
GrBackendTexture beTex = GrBackendTexture(w, h, mipMapped, info);
|
||||
#if GR_TEST_UTILS
|
||||
// Lots of tests don't go through Skia's public interface which will set the config so for
|
||||
// testing we make sure we set a config here.
|
||||
beTex.setPixelConfig(config);
|
||||
#endif
|
||||
return beTex;
|
||||
}
|
||||
|
||||
void GrGLGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kOpenGL == tex.backend());
|
||||
|
||||
GrGLTextureInfo info;
|
||||
if (tex.getGLTextureInfo(&info)) {
|
||||
GL_CALL(DeleteTextures(1, &info.fID));
|
||||
}
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
SkASSERT(GrBackendApi::kOpenGL == tex.backend());
|
||||
|
||||
@ -4212,15 +4224,6 @@ bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
return (GR_GL_TRUE == result);
|
||||
}
|
||||
|
||||
void GrGLGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kOpenGL == tex.backend());
|
||||
|
||||
GrGLTextureInfo info;
|
||||
if (tex.getGLTextureInfo(&info)) {
|
||||
GL_CALL(DeleteTextures(1, &info.fID));
|
||||
}
|
||||
}
|
||||
|
||||
GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h,
|
||||
GrColorType colorType) {
|
||||
if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
|
||||
|
@ -136,16 +136,16 @@ public:
|
||||
GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
|
||||
int width,
|
||||
int height) override;
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(int w, int h, const GrBackendFormat&,
|
||||
GrMipMapped, GrRenderable,
|
||||
const void* pixels = nullptr,
|
||||
size_t rowBytes = 0) override;
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override;
|
||||
#if GR_TEST_UTILS
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
|
||||
GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override;
|
||||
void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
const GrGLContext* glContextForTesting() const override { return &this->glContext(); }
|
||||
|
@ -196,7 +196,6 @@ GrStencilAttachment* GrMockGpu::createStencilAttachmentForRenderTarget(const GrR
|
||||
return new GrMockStencilAttachment(this, width, height, kBits, rt->numColorSamples());
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture GrMockGpu::createTestingOnlyBackendTexture(int w, int h,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
@ -220,6 +219,16 @@ GrBackendTexture GrMockGpu::createTestingOnlyBackendTexture(int w, int h,
|
||||
return GrBackendTexture(w, h, mipMapped, info);
|
||||
}
|
||||
|
||||
void GrMockGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kMock == tex.backend());
|
||||
|
||||
GrMockTextureInfo info;
|
||||
if (tex.getMockTextureInfo(&info)) {
|
||||
fOutstandingTestingOnlyTextureIDs.remove(info.fID);
|
||||
}
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
SkASSERT(GrBackendApi::kMock == tex.backend());
|
||||
|
||||
@ -231,15 +240,6 @@ bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
return fOutstandingTestingOnlyTextureIDs.contains(info.fID);
|
||||
}
|
||||
|
||||
void GrMockGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kMock == tex.backend());
|
||||
|
||||
GrMockTextureInfo info;
|
||||
if (tex.getMockTextureInfo(&info)) {
|
||||
fOutstandingTestingOnlyTextureIDs.remove(info.fID);
|
||||
}
|
||||
}
|
||||
|
||||
GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(int w, int h,
|
||||
GrColorType colorType) {
|
||||
auto config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
|
@ -121,14 +121,15 @@ private:
|
||||
GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*,
|
||||
int width,
|
||||
int height) override;
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(int w, int h, const GrBackendFormat&,
|
||||
GrMipMapped, GrRenderable,
|
||||
const void* pixels = nullptr,
|
||||
size_t rowBytes = 0) override;
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
|
||||
GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override;
|
||||
void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
|
@ -60,7 +60,6 @@ public:
|
||||
// command buffer to finish before creating a new buffer and returning.
|
||||
void submitCommandBuffer(SyncQueue sync);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(int w, int h,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
@ -68,12 +67,12 @@ public:
|
||||
const void* pixels = nullptr,
|
||||
size_t rowBytes = 0) override;
|
||||
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override;
|
||||
#if GR_TEST_UTILS
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
|
||||
GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, GrColorType) override;
|
||||
void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
void testingOnly_flushGpuAndSync() override;
|
||||
@ -214,13 +213,11 @@ private:
|
||||
int width,
|
||||
int height) override;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool createTestingOnlyMtlTextureInfo(GrPixelConfig, MTLPixelFormat,
|
||||
int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped,
|
||||
const void* srcData, size_t rowBytes,
|
||||
GrMtlTextureInfo* info);
|
||||
#endif
|
||||
|
||||
sk_sp<GrMtlCaps> fMtlCaps;
|
||||
|
||||
|
@ -608,7 +608,6 @@ bool GrMtlGpu::onRegenerateMipMapLevels(GrTexture* texture) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrPixelConfig config, MTLPixelFormat format,
|
||||
int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped,
|
||||
@ -800,6 +799,17 @@ GrBackendTexture GrMtlGpu::createTestingOnlyBackendTexture(int w, int h,
|
||||
return backendTex;
|
||||
}
|
||||
|
||||
void GrMtlGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kMetal == tex.fBackend);
|
||||
|
||||
GrMtlTextureInfo info;
|
||||
if (tex.getMtlTextureInfo(&info)) {
|
||||
// Adopts the metal texture so that ARC will clean it up.
|
||||
GrGetMTLTexture(info.fTexture, GrWrapOwnership::kAdopt_GrWrapOwnership);
|
||||
}
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool GrMtlGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
SkASSERT(GrBackendApi::kMetal == tex.backend());
|
||||
|
||||
@ -815,16 +825,6 @@ bool GrMtlGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
return mtlTexture.usage & MTLTextureUsageShaderRead;
|
||||
}
|
||||
|
||||
void GrMtlGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kMetal == tex.fBackend);
|
||||
|
||||
GrMtlTextureInfo info;
|
||||
if (tex.getMtlTextureInfo(&info)) {
|
||||
// Adopts the metal texture so that ARC will clean it up.
|
||||
GrGetMTLTexture(info.fTexture, GrWrapOwnership::kAdopt_GrWrapOwnership);
|
||||
}
|
||||
}
|
||||
|
||||
GrBackendRenderTarget GrMtlGpu::createTestingOnlyBackendRenderTarget(int w, int h, GrColorType ct) {
|
||||
if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
|
||||
return GrBackendRenderTarget();
|
||||
|
@ -1482,7 +1482,6 @@ bool copy_testing_data(GrVkGpu* gpu, const void* srcData, const GrVkAlloc& alloc
|
||||
return true;
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
static size_t compute_combined_buffer_size(VkFormat format, size_t bpp, int w, int h,
|
||||
SkTArray<size_t>* individualMipOffsets,
|
||||
uint32_t mipLevels) {
|
||||
@ -1923,12 +1922,24 @@ GrBackendTexture GrVkGpu::createTestingOnlyBackendTexture(int w, int h,
|
||||
return {};
|
||||
}
|
||||
GrBackendTexture beTex = GrBackendTexture(w, h, info);
|
||||
#if GR_TEST_UTILS
|
||||
// Lots of tests don't go through Skia's public interface which will set the config so for
|
||||
// testing we make sure we set a config here.
|
||||
beTex.setPixelConfig(config);
|
||||
#endif
|
||||
return beTex;
|
||||
}
|
||||
|
||||
void GrVkGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kVulkan == tex.fBackend);
|
||||
|
||||
GrVkImageInfo info;
|
||||
if (tex.getVkImageInfo(&info)) {
|
||||
GrVkImage::DestroyImageInfo(this, const_cast<GrVkImageInfo*>(&info));
|
||||
}
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
SkASSERT(GrBackendApi::kVulkan == tex.fBackend);
|
||||
|
||||
@ -1951,15 +1962,6 @@ bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void GrVkGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) {
|
||||
SkASSERT(GrBackendApi::kVulkan == tex.fBackend);
|
||||
|
||||
GrVkImageInfo info;
|
||||
if (tex.getVkImageInfo(&info)) {
|
||||
GrVkImage::DestroyImageInfo(this, const_cast<GrVkImageInfo*>(&info));
|
||||
}
|
||||
}
|
||||
|
||||
GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h, GrColorType ct) {
|
||||
if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
|
||||
return GrBackendRenderTarget();
|
||||
|
Loading…
Reference in New Issue
Block a user