aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/mtl')
-rw-r--r--src/gpu/mtl/GrMtlCaps.mm7
-rw-r--r--src/gpu/mtl/GrMtlUtil.h6
-rw-r--r--src/gpu/mtl/GrMtlUtil.mm9
3 files changed, 21 insertions, 1 deletions
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index a1ecf08c35..1bb3fb26bf 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -8,6 +8,7 @@
#include "GrMtlCaps.h"
#include "GrBackendSurface.h"
+#include "GrMtlUtil.h"
#include "GrShaderCaps.h"
GrMtlCaps::GrMtlCaps(const GrContextOptions& contextOptions, const id<MTLDevice> device,
@@ -319,7 +320,11 @@ void GrMtlCaps::initConfigTable() {
#ifdef GR_TEST_UTILS
GrBackendFormat GrMtlCaps::onCreateFormatFromBackendTexture(
const GrBackendTexture& backendTex) const {
- return GrBackendFormat(); // Metal BackendFormat not yet implemented.
+ GrMtlTextureInfo mtlInfo;
+ SkAssertResult(backendTex.getMtlTextureInfo(&mtlInfo));
+ id<MTLTexture> mtlTexture = GrGetMTLTexture(mtlInfo.fTexture,
+ GrWrapOwnership::kBorrow_GrWrapOwnership);
+ return GrBackendFormat::MakeMtl(mtlTexture.pixelFormat);
}
#endif
diff --git a/src/gpu/mtl/GrMtlUtil.h b/src/gpu/mtl/GrMtlUtil.h
index e53a8f5ee8..656b65cd6d 100644
--- a/src/gpu/mtl/GrMtlUtil.h
+++ b/src/gpu/mtl/GrMtlUtil.h
@@ -23,4 +23,10 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format);
*/
GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format);
+/**
+ * Returns a id<MTLTexture> to the MTLTexture pointed at by the const void*. Will use
+ * __bridge_transfer if we are adopting ownership.
+ */
+id<MTLTexture> GrGetMTLTexture(const void* mtlTexture, GrWrapOwnership);
+
#endif
diff --git a/src/gpu/mtl/GrMtlUtil.mm b/src/gpu/mtl/GrMtlUtil.mm
index 3c5df209c4..3bd3b280a5 100644
--- a/src/gpu/mtl/GrMtlUtil.mm
+++ b/src/gpu/mtl/GrMtlUtil.mm
@@ -113,3 +113,12 @@ GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format) {
return kUnknown_GrPixelConfig;
}
}
+
+id<MTLTexture> GrGetMTLTexture(const void* mtlTexture, GrWrapOwnership wrapOwnership) {
+ if (GrWrapOwnership::kAdopt_GrWrapOwnership == wrapOwnership) {
+ return (__bridge_transfer id<MTLTexture>)mtlTexture;
+ } else {
+ return (__bridge id<MTLTexture>)mtlTexture;
+ }
+}
+