14 const void* mtl_texture,
17 std::move(deletion_proc));
24 :
Texture(p_desc), aquire_proc_(aquire_proc), is_drawable_(drawable) {
27 if (!
desc.IsValid() || !aquire_proc) {
31 if (
desc.size != GetSize()) {
32 VALIDATION_LOG <<
"The texture and its descriptor disagree about its size.";
45 return std::shared_ptr<TextureMTL>(
48 [deletion_proc = std::move(deletion_proc)](
TextureMTL* t) {
53 return std::shared_ptr<TextureMTL>(
64void TextureMTL::SetLabel(std::string_view label) {
68 [aquire_proc_() setLabel:@(label.
data())];
76 return OnSetContents(mapping->GetMapping(), mapping->GetSize(), slice);
80bool TextureMTL::OnSetContents(
const uint8_t* contents,
83 if (!
IsValid() || !contents || is_wrapped_ || is_drawable_) {
90 if (
length !=
desc.GetByteSizeOfBaseMipLevel()) {
95 MTLRegionMake2D(0u, 0u,
desc.size.width,
desc.size.height);
96 [aquire_proc_() replaceRegion:
region
100 bytesPerRow:
desc.GetBytesPerRow()
101 bytesPerImage:
desc.GetByteSizeOfBaseMipLevel()
111 const auto&
texture = aquire_proc_();
117 return aquire_proc_();
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
id< MTLTexture > GetMTLTexture() const
TextureMTL(TextureDescriptor desc, const AcquireTextureProc &aquire_proc, bool wrapped=false, bool drawable=false)
bool IsDrawable() const
Whether or not this texture is wrapping a Metal drawable.
bool IsValid() const override
std::function< id< MTLTexture >()> AcquireTextureProc
This callback needs to always return the same texture when called multiple times.
bool GenerateMipmap(id< MTLBlitCommandEncoder > encoder)
static std::shared_ptr< TextureMTL > Wrapper(TextureDescriptor desc, id< MTLTexture > texture, std::function< void()> deletion_proc=nullptr)
static std::shared_ptr< TextureMTL > Create(TextureDescriptor desc, id< MTLTexture > texture)
const TextureDescriptor & GetTextureDescriptor() const
Dart_NativeFunction function
ClipOpAndAA opAA SkRegion region
std::shared_ptr< Texture > WrapperMTL(TextureDescriptor desc, const void *mtl_texture, std::function< void()> deletion_proc)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
std::shared_ptr< const fml::Mapping > data