Add MtlTexture class.
Bug: skia:12466 Change-Id: I6207af8bb34ccab28265ced733e1930f42e2db8b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454776 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
091694fe16
commit
f69f21e601
28
experimental/graphite/src/mtl/MtlTexture.h
Normal file
28
experimental/graphite/src/mtl/MtlTexture.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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_MtlTexture_DEFINED
|
||||
#define skgpu_MtlTexture_DEFINED
|
||||
|
||||
#include "experimental/graphite/src/Texture.h"
|
||||
|
||||
namespace skgpu::mtl {
|
||||
|
||||
class Texture : public skgpu::Texture {
|
||||
public:
|
||||
static sk_sp<Texture> Make(SkISize dimensions);
|
||||
|
||||
~Texture() override {}
|
||||
|
||||
private:
|
||||
Texture(SkISize dimensions, const skgpu::TextureInfo& info)
|
||||
: skgpu::Texture(dimensions, info) {}
|
||||
};
|
||||
|
||||
} // namepsace skgpu::mtl
|
||||
|
||||
#endif // skgpu_MtlTexture_DEFINED
|
33
experimental/graphite/src/mtl/MtlTexture.mm
Normal file
33
experimental/graphite/src/mtl/MtlTexture.mm
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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/MtlTexture.h"
|
||||
|
||||
#include "experimental/graphite/include/mtl/MtlTypes.h"
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
namespace skgpu::mtl {
|
||||
|
||||
sk_sp<Texture> Texture::Make(SkISize dimensions) {
|
||||
TextureInfo mtlInfo;
|
||||
mtlInfo.fSampleCount = 1;
|
||||
mtlInfo.fLevelCount = 1;
|
||||
|
||||
mtlInfo.fFormat = MTLPixelFormatRGBA8Unorm;
|
||||
if (@available(macOS 10.11, ios 9.0, *)) {
|
||||
mtlInfo.fUsage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
|
||||
mtlInfo.fStorageMode = MTLStorageModePrivate;
|
||||
}
|
||||
|
||||
skgpu::TextureInfo textureInfo(mtlInfo);
|
||||
|
||||
return sk_sp<Texture>(new Texture(dimensions, textureInfo));
|
||||
}
|
||||
|
||||
} // namespace skgpu::mtl
|
||||
|
@ -64,6 +64,8 @@ skia_graphite_mtl_sources = [
|
||||
"$_src/mtl/MtlPipeline.mm",
|
||||
"$_src/mtl/MtlResourceProvider.h",
|
||||
"$_src/mtl/MtlResourceProvider.mm",
|
||||
"$_src/mtl/MtlTexture.h",
|
||||
"$_src/mtl/MtlTexture.mm",
|
||||
"$_src/mtl/MtlTrampoline.h",
|
||||
"$_src/mtl/MtlTrampoline.mm",
|
||||
"$_src/mtl/MtlTypesPriv.mm",
|
||||
|
Loading…
Reference in New Issue
Block a user