aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrRenderTarget.h3
-rw-r--r--include/gpu/GrTexture.h2
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp35
-rw-r--r--src/gpu/gl/GrGLRenderTarget.h9
-rw-r--r--src/gpu/gl/GrGLTexture.cpp6
-rw-r--r--src/gpu/gl/GrGLTexture.h1
-rw-r--r--src/gpu/mock/GrMockTexture.h10
-rw-r--r--src/gpu/mtl/GrMtlRenderTarget.h6
-rw-r--r--src/gpu/mtl/GrMtlTexture.h1
-rw-r--r--src/gpu/mtl/GrMtlTexture.mm4
-rw-r--r--src/gpu/vk/GrVkRenderTarget.cpp6
-rw-r--r--src/gpu/vk/GrVkRenderTarget.h1
-rw-r--r--src/gpu/vk/GrVkTexture.cpp4
-rw-r--r--src/gpu/vk/GrVkTexture.h1
-rw-r--r--tests/BlendTest.cpp9
-rw-r--r--tests/GrMipMappedTest.cpp10
-rw-r--r--tests/ImageFilterCacheTest.cpp8
-rw-r--r--tests/TextureProxyTest.cpp9
-rw-r--r--tools/fiddle/fiddle_main.cpp28
-rw-r--r--tools/gpu/GrTest.cpp22
-rw-r--r--tools/gpu/GrTest.h5
21 files changed, 69 insertions, 111 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index ff5eb0301d..93501db9af 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -15,6 +15,7 @@ class GrCaps;
class GrRenderTargetOpList;
class GrRenderTargetPriv;
class GrStencilAttachment;
+class GrBackendRenderTarget;
/**
* GrRenderTarget represents a 2D buffer of pixels that can be rendered to.
@@ -104,6 +105,8 @@ public:
*/
virtual GrBackendObject getRenderTargetHandle() const = 0;
+ virtual GrBackendRenderTarget getBackendRenderTarget() const = 0;
+
// Checked when this object is asked to attach a stencil buffer.
virtual bool canAttemptStencilAttachment() const = 0;
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index c32c0e97a8..28f0d4b548 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -30,6 +30,8 @@ public:
*/
virtual GrBackendObject getTextureHandle() const = 0;
+ virtual GrBackendTexture getBackendTexture() const = 0;
+
/**
* This function indicates that the texture parameters (wrap mode, filtering, ...) have been
* changed externally to Skia.
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 58dacf6549..186ca52446 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -30,32 +30,6 @@ GrBackendTextureImageGenerator::RefHelper::~RefHelper() {
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg);
}
-// TODO: I copied this from SkImage_Gpu, perhaps we put a version of this somewhere else?
-static GrBackendTexture make_backend_texture_from_handle(GrBackend backend,
- int width, int height,
- GrPixelConfig config,
- GrMipMapped mipMapped,
- GrBackendObject handle) {
- switch (backend) {
- case kOpenGL_GrBackend: {
- const GrGLTextureInfo* glInfo = (const GrGLTextureInfo*)(handle);
- return GrBackendTexture(width, height, config, mipMapped, *glInfo);
- }
-#ifdef SK_VULKAN
- case kVulkan_GrBackend: {
- const GrVkImageInfo* vkInfo = (const GrVkImageInfo*)(handle);
- return GrBackendTexture(width, height, *vkInfo);
- }
-#endif
- case kMock_GrBackend: {
- const GrMockTextureInfo* mockInfo = (const GrMockTextureInfo*)(handle);
- return GrBackendTexture(width, height, config, mipMapped, *mockInfo);
- }
- default:
- return GrBackendTexture();
- }
-}
-
std::unique_ptr<SkImageGenerator>
GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin origin,
sk_sp<GrSemaphore> semaphore,
@@ -76,14 +50,7 @@ GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin o
// this point. That ref will be released when the generator's RefHelper is freed.
context->getResourceCache()->insertCrossContextGpuResource(texture.get());
- GrBackend backend = context->contextPriv().getBackend();
- GrMipMapped mipMapped = texture->texturePriv().mipMapped();
- GrBackendTexture backendTexture = make_backend_texture_from_handle(backend,
- texture->width(),
- texture->height(),
- texture->config(),
- mipMapped,
- texture->getTextureHandle());
+ GrBackendTexture backendTexture = texture->getBackendTexture();
SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType,
std::move(colorSpace));
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index d38c557493..28c6e3d741 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -9,6 +9,7 @@
#ifndef GrGLRenderTarget_DEFINED
#define GrGLRenderTarget_DEFINED
+#include "GrBackendSurface.h"
#include "GrGLIRect.h"
#include "GrRenderTarget.h"
#include "SkScalar.h"
@@ -62,6 +63,14 @@ public:
GrBackendObject getRenderTargetHandle() const override { return fRTFBOID; }
+ GrBackendRenderTarget getBackendRenderTarget() const override {
+ GrGLFramebufferInfo fbi;
+ fbi.fFBOID = fRTFBOID;
+
+ return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(),
+ this->numStencilSamples(), this->config(), fbi);
+ }
+
bool canAttemptStencilAttachment() const override;
// GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 4a4f085081..597c213eda 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -9,6 +9,7 @@
#include "GrGLGpu.h"
#include "GrSemaphore.h"
#include "GrShaderCaps.h"
+#include "GrTexturePriv.h"
#include "SkTraceMemoryDump.h"
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
@@ -105,6 +106,11 @@ GrBackendObject GrGLTexture::getTextureHandle() const {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
+GrBackendTexture GrGLTexture::getBackendTexture() const {
+ return GrBackendTexture(this->width(), this->height(), this->config(),
+ this->texturePriv().mipMapped(), fInfo);
+}
+
void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
const SkString& dumpName) const {
SkString texture_id;
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index dfce602bf1..b7c8716cc7 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -40,6 +40,7 @@ public:
}
GrBackendObject getTextureHandle() const override;
+ GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override { fTexParams.invalidate(); }
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index 0469d4fced..a25ff9ba67 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -28,6 +28,11 @@ public:
GrBackendObject getTextureHandle() const override {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
+ GrBackendTexture getBackendTexture() const override {
+ return GrBackendTexture(this->width(), this->height(), this->config(),
+ this->texturePriv().mipMapped(), fInfo);
+ }
+
void textureParamsModified() override {}
void setRelease(ReleaseProc proc, ReleaseCtx ctx) override {
fReleaseProc = proc;
@@ -68,6 +73,11 @@ public:
}
ResolveType getResolveType() const override { return kCanResolve_ResolveType; }
GrBackendObject getRenderTargetHandle() const override { return 0; }
+
+ GrBackendRenderTarget getBackendRenderTarget() const override {
+ return GrBackendRenderTarget(); // invalid
+ }
+
bool canAttemptStencilAttachment() const override { return true; }
bool completeStencilAttachment() override { return true; }
GrTexture* asTexture() override { return this; }
diff --git a/src/gpu/mtl/GrMtlRenderTarget.h b/src/gpu/mtl/GrMtlRenderTarget.h
index 186f703792..4dac306e7e 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.h
+++ b/src/gpu/mtl/GrMtlRenderTarget.h
@@ -10,6 +10,8 @@
#include "GrRenderTarget.h"
+#include "GrBackendSurface.h"
+
#import <Metal/Metal.h>
class GrMtlGpu;
@@ -40,6 +42,10 @@ public:
GrBackendObject getRenderTargetHandle() const override;
+ GrBackendRenderTarget getBackendRenderTarget() const override {
+ return GrBackendRenderTarget(); // invalid
+ }
+
protected:
GrMtlRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
diff --git a/src/gpu/mtl/GrMtlTexture.h b/src/gpu/mtl/GrMtlTexture.h
index 3f223d5d52..2d7c3011df 100644
--- a/src/gpu/mtl/GrMtlTexture.h
+++ b/src/gpu/mtl/GrMtlTexture.h
@@ -27,6 +27,7 @@ public:
id<MTLTexture> mtlTexture() const { return fTexture; }
GrBackendObject getTextureHandle() const override;
+ GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override {}
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index 0bd50ed556..26e5918faf 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -79,3 +79,7 @@ GrBackendObject GrMtlTexture::getTextureHandle() const {
void* voidTex = (__bridge_retained void*)fTexture;
return (GrBackendObject)voidTex;
}
+
+GrBackendTexture GrMtlTexture::getBackendTexture() const {
+ return GrBackendTexture(); // invalid
+}
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 27cb119efc..c5a8628cc4 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -7,6 +7,7 @@
#include "GrVkRenderTarget.h"
+#include "GrBackendSurface.h"
#include "GrRenderTargetPriv.h"
#include "GrVkCommandBuffer.h"
#include "GrVkFramebuffer.h"
@@ -347,6 +348,11 @@ GrBackendObject GrVkRenderTarget::getRenderTargetHandle() const {
return (GrBackendObject)&fInfo;
}
+GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget() const {
+ return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(),
+ this->numStencilSamples(), fInfo);
+}
+
const GrVkResource* GrVkRenderTarget::stencilImageResource() const {
const GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment();
if (stencil) {
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index 18a0bd3eea..eb297a8a1d 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -70,6 +70,7 @@ public:
}
GrBackendObject getRenderTargetHandle() const override;
+ GrBackendRenderTarget getBackendRenderTarget() const override;
void getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc,
GrVkRenderPass::AttachmentFlags* flags) const;
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index c4f55d7bc7..e696dd1454 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -165,6 +165,10 @@ GrBackendObject GrVkTexture::getTextureHandle() const {
return (GrBackendObject)&fInfo;
}
+GrBackendTexture GrVkTexture::getBackendTexture() const {
+ return GrBackendTexture(this->width(), this->height(), fInfo);
+}
+
GrVkGpu* GrVkTexture::getVkGpu() const {
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 0749f6b62c..a2a357a182 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -29,6 +29,7 @@ public:
~GrVkTexture() override;
GrBackendObject getTextureHandle() const override;
+ GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override {}
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp
index 354bb3cebb..52f41dce59 100644
--- a/tests/BlendTest.cpp
+++ b/tests/BlendTest.cpp
@@ -100,13 +100,8 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
return nullptr;
}
- GrBackendTexture backendTex =
- GrTest::CreateBackendTexture(context->contextPriv().getBackend(),
- width,
- height,
- config,
- GrMipMapped::kNo,
- (*backingSurface)->getTextureHandle());
+ GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
+
sk_sp<SkSurface> surface =
SkSurface::MakeFromBackendTextureAsRenderTarget(context, backendTex, origin,
sampleCnt, nullptr, nullptr);
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 7caa4bb01c..58faec4f8b 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -159,21 +159,19 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
return;
}
- GrBackendObject genBackendObject = genTexture->getTextureHandle();
+ GrBackendTexture genBackendTex = genTexture->getBackendTexture();
- if (kOpenGL_GrBackend == context->contextPriv().getBackend()) {
+ if (const GrGLTextureInfo* genTexInfo = genBackendTex.getGLTextureInfo()) {
const GrGLTextureInfo* origTexInfo = backendTex.getGLTextureInfo();
- GrGLTextureInfo* genTexInfo = (GrGLTextureInfo*)genBackendObject;
if (willUseMips && GrMipMapped::kNo == mipMapped) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origTexInfo->fID != genTexInfo->fID);
} else {
REPORTER_ASSERT(reporter, origTexInfo->fID == genTexInfo->fID);
}
- } else if (kVulkan_GrBackend == context->contextPriv().getBackend()) {
#ifdef SK_VULKAN
+ } else if (const GrVkImageInfo* genImageInfo = genBackendTex.getVkImageInfo()) {
const GrVkImageInfo* origImageInfo = backendTex.getVkImageInfo();
- GrVkImageInfo* genImageInfo = (GrVkImageInfo*)genBackendObject;
if (willUseMips && GrMipMapped::kNo == mipMapped) {
// We did a copy so the texture IDs should be different
REPORTER_ASSERT(reporter, origImageInfo->fImage != genImageInfo->fImage);
@@ -181,8 +179,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
REPORTER_ASSERT(reporter, origImageInfo->fImage == genImageInfo->fImage);
}
#endif
- } else if (kMetal_GrBackend == context->contextPriv().getBackend()) {
- REPORTER_ASSERT(reporter, false);
} else {
REPORTER_ASSERT(reporter, false);
}
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index 449b252acf..bcd451127b 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -215,12 +215,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ct
}
GrTexture* tex = srcProxy->priv().peekTexture();
- GrBackendTexture backendTex = GrTest::CreateBackendTexture(context->contextPriv().getBackend(),
- kFullSize,
- kFullSize,
- kRGBA_8888_GrPixelConfig,
- GrMipMapped::kNo,
- tex->getTextureHandle());
+ GrBackendTexture backendTex = tex->getBackendTexture();
+
GrSurfaceOrigin texOrigin = kTopLeft_GrSurfaceOrigin;
sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context,
backendTex,
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index a4b93c8d7a..393e8c69e1 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -114,19 +114,14 @@ static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackin
sk_sp<GrTexture>* backingSurface) {
GrResourceProvider* provider = context->resourceProvider();
- GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
+ const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
*backingSurface = provider->createTexture(desc, SkBudgeted::kNo);
if (!(*backingSurface)) {
return nullptr;
}
- GrBackendTexture backendTex =
- GrTest::CreateBackendTexture(context->contextPriv().getBackend(),
- 64, 64,
- kRGBA_8888_GrPixelConfig,
- GrMipMapped::kNo,
- (*backingSurface)->getTextureHandle());
+ GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
return GrSurfaceProxy::MakeWrappedBackend(context, backendTex, kBottomLeft_GrSurfaceOrigin);
}
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp
index 776e9d1dd4..4c7a0878a2 100644
--- a/tools/fiddle/fiddle_main.cpp
+++ b/tools/fiddle/fiddle_main.cpp
@@ -124,15 +124,12 @@ static bool setup_backend_objects(GrContext* context,
return false;
}
- GrBackend backend = context->contextPriv().getBackend();
- const GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
-
GrSurfaceDesc backingDesc;
backingDesc.fFlags = kNone_GrSurfaceFlags;
backingDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
backingDesc.fWidth = bm.width();
backingDesc.fHeight = bm.height();
- backingDesc.fConfig = kConfig;
+ backingDesc.fConfig = kRGBA_8888_GrPixelConfig;
backingDesc.fSampleCnt = 0;
if (!bm.empty()) {
@@ -173,12 +170,7 @@ static bool setup_backend_objects(GrContext* context,
return false;
}
- backEndTexture = GrTest::CreateBackendTexture(backend,
- backingDesc.fWidth,
- backingDesc.fHeight,
- kConfig,
- options.fMipMapping,
- backingTexture->getTextureHandle());
+ backEndTexture = backingTexture->getBackendTexture();
if (!backEndTexture.isValid()) {
return false;
}
@@ -209,13 +201,7 @@ static bool setup_backend_objects(GrContext* context,
backingRenderTarget = sk_ref_sp(tmp->asRenderTarget());
- backEndRenderTarget = GrTest::CreateBackendRenderTarget(
- backend,
- backingDesc.fWidth,
- backingDesc.fHeight,
- backingDesc.fSampleCnt, 0,
- kConfig,
- backingRenderTarget->getRenderTargetHandle());
+ backEndRenderTarget = backingRenderTarget->getBackendRenderTarget();
if (!backEndRenderTarget.isValid()) {
return false;
}
@@ -243,13 +229,7 @@ static bool setup_backend_objects(GrContext* context,
return false;
}
- backEndTextureRenderTarget = GrTest::CreateBackendTexture(
- backend,
- backingDesc.fWidth,
- backingDesc.fHeight,
- kConfig,
- options.fOffScreenMipMapping,
- backingTextureRenderTarget->getTextureHandle());
+ backEndTextureRenderTarget = backingTextureRenderTarget->getBackendTexture();
if (!backEndTextureRenderTarget.isValid()) {
return false;
}
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 0001d1dc27..552dd8a67e 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -78,28 +78,6 @@ GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
}
}
-GrBackendRenderTarget CreateBackendRenderTarget(GrBackend backend, int width, int height,
- int sampleCnt, int stencilBits,
- GrPixelConfig config,
- GrBackendObject handle) {
- switch (backend) {
-#ifdef SK_VULKAN
- case kVulkan_GrBackend: {
- GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
- return GrBackendRenderTarget(width, height, sampleCnt, stencilBits, *vkInfo);
- }
-#endif
- case kOpenGL_GrBackend: {
- GrGLFramebufferInfo glInfo;
- glInfo.fFBOID = handle;
- return GrBackendRenderTarget(width, height, sampleCnt, stencilBits, config, glInfo);
- }
- case kMock_GrBackend: // fall through
- default:
- return GrBackendRenderTarget();
- }
-}
-
} // namespace GrTest
bool GrSurfaceProxy::isWrapped_ForTesting() const {
diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h
index 1134932ad9..5d988c7b04 100644
--- a/tools/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
@@ -18,12 +18,9 @@ namespace GrTest {
*/
void SetupAlwaysEvictAtlas(GrContext*);
+ // TODO: remove this. It is only used in the SurfaceSemaphores Test.
GrBackendTexture CreateBackendTexture(GrBackend, int width, int height,
GrPixelConfig, GrMipMapped, GrBackendObject);
-
- GrBackendRenderTarget CreateBackendRenderTarget(GrBackend, int width, int height,
- int sampleCnt, int stencilBits,
- GrPixelConfig, GrBackendObject);
};
#endif