aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-15 11:15:19 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-15 16:51:36 +0000
commit7f4419696b8ef299a321561336c0353a5a7d8e61 (patch)
treecc3a3ece311892099a8730b7e65b4e283442d598
parent4f4a53f94852f801d89d8e22c4511d34fa6907e2 (diff)
Make CreateBackendFormatFromTexture shared code
TBR=bsalomon@google.com Change-Id: I19e6e6c8dc32ba584738545d443de092e4987a5a Reviewed-on: https://skia-review.googlesource.com/114374 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--dm/DMSrcSink.cpp27
-rw-r--r--include/gpu/GrBackendSurface.h5
-rw-r--r--src/gpu/GrBackendSurface.cpp24
-rw-r--r--tests/PromiseImageTest.cpp2
-rw-r--r--tools/gpu/GrTest.cpp24
-rw-r--r--tools/gpu/GrTest.h2
6 files changed, 31 insertions, 53 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 7256348632..9b68dc99cf 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1254,31 +1254,6 @@ public:
SkDeferredDisplayListRecorder* fRecorder;
};
-// duplicate of method in GrTest.cpp
-GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex) {
- switch (tex.backend()) {
-#ifdef SK_VULKAN
- case kVulkan_GrBackend: {
- const GrVkImageInfo* vkInfo = tex.getVkImageInfo();
- SkASSERT(vkInfo);
- return GrBackendFormat::MakeVk(vkInfo->fFormat);
- }
-#endif
- case kOpenGL_GrBackend: {
- const GrGLTextureInfo* glInfo = tex.getGLTextureInfo();
- SkASSERT(glInfo);
- return GrBackendFormat::MakeGL(glInfo->fFormat, glInfo->fTarget);
- }
- case kMock_GrBackend: {
- const GrMockTextureInfo* mockInfo = tex.getMockTextureInfo();
- SkASSERT(mockInfo);
- return GrBackendFormat::MakeMock(mockInfo->fConfig);
- }
- default:
- return GrBackendFormat();
- }
-}
-
// This generates promise images to replace the indices in the compressed picture. This
// reconstitution is performed separately in each thread so we end of with multiple
// promise image referring to the same GrBackendTexture.
@@ -1295,7 +1270,7 @@ static sk_sp<SkImage> promise_image_creator(const void* rawData, size_t length,
const PromiseImageInfo& curImage = (*imageInfo)[*indexPtr];
SkASSERT(curImage.fIndex == *indexPtr);
- GrBackendFormat backendFormat = CreateBackendFormatFromTexture(curImage.fBackendTexture);
+ GrBackendFormat backendFormat = curImage.fBackendTexture.format();
// DDL TODO: sort out mipmapping
sk_sp<SkImage> image = recorder->makePromiseTexture(backendFormat,
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 76714eca0f..a57edcd9d1 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -138,6 +138,11 @@ public:
// Returns true if the backend texture has been initialized.
bool isValid() const { return fConfig != kUnknown_GrPixelConfig; }
+ /**
+ * Create a GrBackendFormat object that matches this texture
+ */
+ GrBackendFormat format() const;
+
GrPixelConfig testingOnly_getPixelConfig() const;
private:
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index fa2582a18e..863f531b2e 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -138,6 +138,30 @@ const GrMockTextureInfo* GrBackendTexture::getMockTextureInfo() const {
return nullptr;
}
+GrBackendFormat GrBackendTexture::format() const {
+ switch (this->backend()) {
+#ifdef SK_VULKAN
+ case kVulkan_GrBackend: {
+ const GrVkImageInfo* vkInfo = this->getVkImageInfo();
+ SkASSERT(vkInfo);
+ return GrBackendFormat::MakeVk(vkInfo->fFormat);
+ }
+#endif
+ case kOpenGL_GrBackend: {
+ const GrGLTextureInfo* glInfo = this->getGLTextureInfo();
+ SkASSERT(glInfo);
+ return GrBackendFormat::MakeGL(glInfo->fFormat, glInfo->fTarget);
+ }
+ case kMock_GrBackend: {
+ const GrMockTextureInfo* mockInfo = this->getMockTextureInfo();
+ SkASSERT(mockInfo);
+ return GrBackendFormat::MakeMock(mockInfo->fConfig);
+ }
+ default:
+ return GrBackendFormat();
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SK_VULKAN
diff --git a/tests/PromiseImageTest.cpp b/tests/PromiseImageTest.cpp
index 4ba011b0fe..c5bd9cd268 100644
--- a/tests/PromiseImageTest.cpp
+++ b/tests/PromiseImageTest.cpp
@@ -96,7 +96,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid());
- GrBackendFormat backendFormat = GrTest::CreateBackendFormatFromTexture(backendTex);
+ GrBackendFormat backendFormat = backendTex.format();
REPORTER_ASSERT(reporter, backendFormat.isValid());
PromiseTextureChecker promiseChecker(backendTex);
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index e1a7924062..132f8a5054 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -78,30 +78,6 @@ GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
}
}
-GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex) {
- switch (tex.backend()) {
-#ifdef SK_VULKAN
- case kVulkan_GrBackend: {
- const GrVkImageInfo* vkInfo = tex.getVkImageInfo();
- SkASSERT(vkInfo);
- return GrBackendFormat::MakeVk(vkInfo->fFormat);
- }
-#endif
- case kOpenGL_GrBackend: {
- const GrGLTextureInfo* glInfo = tex.getGLTextureInfo();
- SkASSERT(glInfo);
- return GrBackendFormat::MakeGL(glInfo->fFormat, glInfo->fTarget);
- }
- case kMock_GrBackend: {
- const GrMockTextureInfo* mockInfo = tex.getMockTextureInfo();
- SkASSERT(mockInfo);
- return GrBackendFormat::MakeMock(mockInfo->fConfig);
- }
- default:
- return GrBackendFormat();
- }
-}
-
} // namespace GrTest
bool GrSurfaceProxy::isWrapped_ForTesting() const {
diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h
index 76e5e93e03..6666ab1a20 100644
--- a/tools/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
@@ -22,8 +22,6 @@ namespace GrTest {
// TODO: remove this. It is only used in the SurfaceSemaphores Test.
GrBackendTexture CreateBackendTexture(GrBackend, int width, int height,
GrPixelConfig, GrMipMapped, GrBackendObject);
-
- GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex);
};
#endif