diff options
author | 2018-06-28 15:50:36 -0400 | |
---|---|---|
committer | 2018-06-28 20:21:17 +0000 | |
commit | 036fdfe5aa1266dbc35f0a2c680f648b62b9c28b (patch) | |
tree | 5daf6dd36649795833724d954994438c9ab35dd2 /src | |
parent | be0ab883e796b190cd20a4b1cfaedea932f9e0bf (diff) |
implemented getting format from texture as virtual in gpu caps
Bug: skia:
Change-Id: If6bbbd212ff472ea322d2bbed61995fe7ba85df7
Reviewed-on: https://skia-review.googlesource.com/138240
Commit-Queue: Timothy Liang <timliang@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrBackendSurface.cpp | 28 | ||||
-rw-r--r-- | src/gpu/GrCaps.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrCaps.h | 16 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 4 | ||||
-rw-r--r-- | src/gpu/mock/GrMockCaps.h | 9 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlCaps.h | 5 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlCaps.mm | 9 | ||||
-rw-r--r-- | src/gpu/vk/GrVkCaps.cpp | 9 | ||||
-rw-r--r-- | src/gpu/vk/GrVkCaps.h | 4 |
10 files changed, 72 insertions, 28 deletions
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp index eb7aea2020..d68b42a9ba 100644 --- a/src/gpu/GrBackendSurface.cpp +++ b/src/gpu/GrBackendSurface.cpp @@ -221,34 +221,6 @@ bool GrBackendTexture::getMockTextureInfo(GrMockTextureInfo* outInfo) const { return false; } -GrBackendFormat GrBackendTexture::format() const { - if (!this->isValid()) { - return GrBackendFormat(); - } - - switch (this->backend()) { -#ifdef SK_VULKAN - case kVulkan_GrBackend: { - GrVkImageInfo vkInfo; - SkAssertResult(this->getVkImageInfo(&vkInfo)); - return GrBackendFormat::MakeVk(vkInfo.fFormat); - } -#endif - case kOpenGL_GrBackend: { - GrGLTextureInfo glInfo; - SkAssertResult(this->getGLTextureInfo(&glInfo)); - return GrBackendFormat::MakeGL(glInfo.fFormat, glInfo.fTarget); - } - case kMock_GrBackend: { - GrMockTextureInfo mockInfo; - SkAssertResult(this->getMockTextureInfo(&mockInfo)); - return GrBackendFormat::MakeMock(mockInfo.fConfig); - } - default: - return GrBackendFormat(); - } -} - #if GR_TEST_UTILS bool GrBackendTexture::TestingOnly_Equals(const GrBackendTexture& t0, const GrBackendTexture& t1) { if (!t0.isValid() || !t1.isValid()) { diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index db4681a3aa..c70033578c 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -262,3 +262,10 @@ bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrMipMapped mipped) return true; } + +GrBackendFormat GrCaps::createFormatFromBackendTexture(const GrBackendTexture& backendTex) const { + if (!backendTex.isValid()) { + return GrBackendFormat(); + } + return this->onCreateFormatFromBackendTexture(backendTex); +} diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h index 4b6f78789c..9e18c383d6 100644 --- a/src/gpu/GrCaps.h +++ b/src/gpu/GrCaps.h @@ -271,6 +271,14 @@ public: virtual bool getConfigFromBackendFormat(const GrBackendFormat& format, SkColorType ct, GrPixelConfig*) const = 0; +#ifdef GR_TEST_UTILS + /** + * Creates a GrBackendFormat which matches the backend texture. If the backend texture is + * invalid, the function will return the default GrBackendFormat. + */ + GrBackendFormat createFormatFromBackendTexture(const GrBackendTexture&) const; +#endif + const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; } protected: @@ -279,6 +287,14 @@ protected: expand them. */ void applyOptionsOverrides(const GrContextOptions& options); +#ifdef GR_TEST_UTILS + /** + * Subclasses implement this to actually create a GrBackendFormat to match backend texture. At + * this point, the backend texture has already been validated. + */ + virtual GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const = 0; +#endif + sk_sp<GrShaderCaps> fShaderCaps; bool fNPOTTextureTileSupport : 1; diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 43979fa290..12d99087cd 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -2931,4 +2931,13 @@ bool GrGLCaps::getConfigFromBackendFormat(const GrBackendFormat& format, SkColor return validate_sized_format(*glFormat, ct, config, fStandard); } +#ifdef GR_TEST_UTILS +GrBackendFormat GrGLCaps::onCreateFormatFromBackendTexture( + const GrBackendTexture& backendTex) const { + GrGLTextureInfo glInfo; + SkAssertResult(backendTex.getGLTextureInfo(&glInfo)); + return GrBackendFormat::MakeGL(glInfo.fFormat, glInfo.fTarget); +} +#endif + diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 7380146c56..38435ccb18 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -461,6 +461,10 @@ private: void onApplyOptionsOverrides(const GrContextOptions& options) override; +#ifdef GR_TEST_UTILS + GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override; +#endif + bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const override; void initFSAASupport(const GrContextOptions& contextOptions, const GrGLContextInfo&, diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h index e8d1cbdd5a..3f301ea51c 100644 --- a/src/gpu/mock/GrMockCaps.h +++ b/src/gpu/mock/GrMockCaps.h @@ -107,6 +107,15 @@ public: } private: +#ifdef GR_TEST_UTILS + GrBackendFormat onCreateFormatFromBackendTexture( + const GrBackendTexture& backendTex) const override { + GrMockTextureInfo mockInfo; + SkAssertResult(backendTex.getMockTextureInfo(&mockInfo)); + return GrBackendFormat::MakeMock(mockInfo.fConfig); + } +#endif + static const int kMaxSampleCnt = 16; GrMockOptions fOptions; diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h index 0918f36807..1ff16adba4 100644 --- a/src/gpu/mtl/GrMtlCaps.h +++ b/src/gpu/mtl/GrMtlCaps.h @@ -75,6 +75,11 @@ private: void initGrCaps(const id<MTLDevice> device); void initShaderCaps(); + +#ifdef GR_TEST_UTILS + GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override; +#endif + void initConfigTable(); struct ConfigInfo { diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm index 93d801fd72..a1ecf08c35 100644 --- a/src/gpu/mtl/GrMtlCaps.mm +++ b/src/gpu/mtl/GrMtlCaps.mm @@ -7,6 +7,7 @@ #include "GrMtlCaps.h" +#include "GrBackendSurface.h" #include "GrShaderCaps.h" GrMtlCaps::GrMtlCaps(const GrContextOptions& contextOptions, const id<MTLDevice> device, @@ -314,3 +315,11 @@ void GrMtlCaps::initConfigTable() { info = &fConfigTable[kRGBA_half_GrPixelConfig]; info->fFlags = ConfigInfo::kAllFlags; } + +#ifdef GR_TEST_UTILS +GrBackendFormat GrMtlCaps::onCreateFormatFromBackendTexture( + const GrBackendTexture& backendTex) const { + return GrBackendFormat(); // Metal BackendFormat not yet implemented. +} +#endif + diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp index 1a14648642..58a7778b5e 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -664,3 +664,12 @@ bool GrVkCaps::getConfigFromBackendFormat(const GrBackendFormat& format, SkColor return validate_image_info(*vkFormat, ct, config); } +#ifdef GR_TEST_UTILS +GrBackendFormat GrVkCaps::onCreateFormatFromBackendTexture( + const GrBackendTexture& backendTex) const { + GrVkImageInfo vkInfo; + SkAssertResult(backendTex.getVkImageInfo(&vkInfo)); + return GrBackendFormat::MakeVk(vkInfo.fFormat); +} +#endif + diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h index 2ed225423b..a3c714403f 100644 --- a/src/gpu/vk/GrVkCaps.h +++ b/src/gpu/vk/GrVkCaps.h @@ -157,6 +157,10 @@ private: uint32_t featureFlags); void initShaderCaps(const VkPhysicalDeviceProperties&, uint32_t featureFlags); +#ifdef GR_TEST_UTILS + GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override; +#endif + void initConfigTable(const GrVkInterface*, VkPhysicalDevice, const VkPhysicalDeviceProperties&); void initStencilFormat(const GrVkInterface* iface, VkPhysicalDevice physDev); |