diff options
author | Greg Daniel <egdaniel@google.com> | 2017-07-13 15:07:54 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-13 21:29:33 +0000 |
commit | b76a72a659f53b8bf449c5ca2685045d08a21e43 (patch) | |
tree | cc2e1b3c997817f514438e79c248d3b890e65ef7 /src/gpu/mtl/GrMtlGpu.mm | |
parent | ee3e0bacc8bedd1e3ebfb52fbc8b1cc3ccdad358 (diff) |
Add support for creating a GrContext backed by Metal.
Also adds the support code to allow our TestContext to create a Metal
backend.
Bug: skia:
Change-Id: Ia850687019d79b897bb16e2c151f4f8526721ad9
Reviewed-on: https://skia-review.googlesource.com/22644
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/mtl/GrMtlGpu.mm')
-rw-r--r-- | src/gpu/mtl/GrMtlGpu.mm | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index 7d9339cf29..986bb8a6f7 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -11,8 +11,31 @@ #error This file must be compiled with Arc. Use -fobjc-arc flag #endif -GrGpu* GrMtlGpu::Create(GrBackendContext backendContext, const GrContextOptions& options, - GrContext* context) { - return nullptr; +GrGpu* GrMtlGpu::Create(GrContext* context, const GrContextOptions& options, + id<MTLDevice> device, id<MTLCommandQueue> queue) { + if (!device || !queue) { + return nullptr; + } + return new GrMtlGpu(context, options, device, queue); } +GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options, + id<MTLDevice> device, id<MTLCommandQueue> queue) + : INHERITED(context) + , fDevice(device) + , fQueue(queue) { + MTLTextureDescriptor* txDesc = [[MTLTextureDescriptor alloc] init]; + txDesc.textureType = MTLTextureType3D; + txDesc.height = 64; + txDesc.width = 64; + txDesc.depth = 64; + txDesc.pixelFormat = MTLPixelFormatRGBA8Unorm; + txDesc.arrayLength = 1; + txDesc.mipmapLevelCount = 1; + id<MTLTexture> testTexture = [fDevice newTextureWithDescriptor:txDesc]; + // To get ride of unused var warning + int width = [testTexture width]; + SkDebugf("width: %d\n", width); + // Unused queue warning fix + SkDebugf("ptr to queue: %p\n", fQueue); +} |