Graphite: add MtlGpu.
Bug: skia:12466 Change-Id: I51dc73a213e672578767b41c01c487c942465964 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452722 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
31fe2c5145
commit
ff733b3f39
12
BUILD.gn
12
BUILD.gn
@ -1026,10 +1026,22 @@ optional("ndk_images") {
|
||||
}
|
||||
|
||||
optional("graphite") {
|
||||
libs = []
|
||||
frameworks = []
|
||||
|
||||
enabled = skia_enable_graphite
|
||||
public_defines = [ "SK_GRAPHITE_ENABLED" ]
|
||||
public = skia_graphite_public
|
||||
sources = skia_graphite_sources
|
||||
if (skia_use_metal) {
|
||||
public_defines += [ "SK_METAL" ]
|
||||
sources += skia_graphite_mtl_sources
|
||||
if (skia_enable_metal_debug_info) {
|
||||
public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ]
|
||||
}
|
||||
frameworks += [ "Metal.framework" ]
|
||||
frameworks += [ "Foundation.framework" ]
|
||||
}
|
||||
}
|
||||
|
||||
optional("pdf") {
|
||||
|
36
experimental/graphite/src/mtl/MtlGpu.h
Normal file
36
experimental/graphite/src/mtl/MtlGpu.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef skgpu_MtlGpu_DEFINED
|
||||
#define skgpu_MtlGpu_DEFINED
|
||||
|
||||
#include "experimental/graphite/src/Gpu.h"
|
||||
|
||||
#include "include/gpu/mtl/GrMtlBackendContext.h"
|
||||
#include "include/ports/SkCFObject.h"
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
namespace skgpu::mtl {
|
||||
|
||||
class Gpu final : public skgpu::Gpu {
|
||||
public:
|
||||
static sk_sp<skgpu::Gpu> Make(const GrMtlBackendContext&);
|
||||
~Gpu() override;
|
||||
|
||||
id<MTLDevice> device() const { return fDevice.get(); }
|
||||
|
||||
private:
|
||||
Gpu(sk_cfp<id<MTLDevice>>, sk_cfp<id<MTLCommandQueue>>);
|
||||
|
||||
sk_cfp<id<MTLDevice>> fDevice;
|
||||
sk_cfp<id<MTLCommandQueue>> fQueue;
|
||||
};
|
||||
|
||||
} // namespace skgpu::mtl
|
||||
|
||||
#endif // skgpu_MtlGpu_DEFINED
|
29
experimental/graphite/src/mtl/MtlGpu.mm
Normal file
29
experimental/graphite/src/mtl/MtlGpu.mm
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "experimental/graphite/src/mtl/MtlGpu.h"
|
||||
|
||||
#include "experimental/graphite/src/Caps.h"
|
||||
|
||||
namespace skgpu::mtl {
|
||||
|
||||
sk_sp<skgpu::Gpu> Gpu::Make(const GrMtlBackendContext& context) {
|
||||
sk_cfp<id<MTLDevice>> device = sk_ret_cfp((id<MTLDevice>)(context.fDevice.get()));
|
||||
sk_cfp<id<MTLCommandQueue>> queue = sk_ret_cfp((id<MTLCommandQueue>)(context.fQueue.get()));
|
||||
|
||||
return sk_sp<skgpu::Gpu>(new Gpu(std::move(device), std::move(queue)));
|
||||
}
|
||||
|
||||
Gpu::Gpu(sk_cfp<id<MTLDevice>> device, sk_cfp<id<MTLCommandQueue>> queue)
|
||||
: fDevice(std::move(device))
|
||||
, fQueue(std::move(queue)) {
|
||||
}
|
||||
|
||||
Gpu::~Gpu() {
|
||||
}
|
||||
|
||||
} // namespace skgpu::mtl
|
@ -37,3 +37,8 @@ skia_graphite_sources = [
|
||||
"$_src/Task.cpp",
|
||||
"$_src/Task.h",
|
||||
]
|
||||
|
||||
skia_graphite_mtl_sources = [
|
||||
"$_src/mtl/MtlGpu.h",
|
||||
"$_src/mtl/MtlGpu.mm",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user