aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl
diff options
context:
space:
mode:
authorGravatar Timothy Liang <timliang@google.com>2018-06-28 16:37:18 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-29 13:32:17 +0000
commit4e85e80a5a32f11b850830f7bf6ee45ca195d137 (patch)
tree1b64d8594d3836b578bf1aead7101257cb8b1117 /src/gpu/mtl
parent8664a1d7d719153e8e854ff0112519d92916cfe2 (diff)
added Metal support to GrBackendSurface
Bug: skia: Change-Id: I58c7307f41df4694b0b46014bedd681adefed265 Reviewed-on: https://skia-review.googlesource.com/137891 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Timothy Liang <timliang@google.com>
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;
+ }
+}
+