Flutter Impeller
texture_mtl.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <Metal/Metal.h>
8 
9 #include "flutter/fml/macros.h"
11 #include "impeller/core/texture.h"
12 
13 namespace impeller {
14 
15 class TextureMTL final : public Texture,
16  public BackendCast<TextureMTL, Texture> {
17  public:
19  id<MTLTexture> texture,
20  bool wrapped = false);
21 
22  static std::shared_ptr<TextureMTL> Wrapper(
23  TextureDescriptor desc,
24  id<MTLTexture> texture,
25  std::function<void()> deletion_proc = nullptr);
26 
27  // |Texture|
28  ~TextureMTL() override;
29 
30  id<MTLTexture> GetMTLTexture() const;
31 
32  bool IsWrapped() const;
33 
34  bool GenerateMipmap(id<MTLBlitCommandEncoder> encoder);
35 
36  private:
37  id<MTLTexture> texture_ = nullptr;
38  bool is_valid_ = false;
39  bool is_wrapped_ = false;
40 
41  // |Texture|
42  void SetLabel(std::string_view label) override;
43 
44  // |Texture|
45  bool OnSetContents(const uint8_t* contents,
46  size_t length,
47  size_t slice) override;
48 
49  // |Texture|
50  bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
51  size_t slice) override;
52 
53  // |Texture|
54  bool IsValid() const override;
55 
56  // |Texture|
57  ISize GetSize() const override;
58 
59  FML_DISALLOW_COPY_AND_ASSIGN(TextureMTL);
60 };
61 
62 } // namespace impeller
impeller::TextureMTL::GenerateMipmap
bool GenerateMipmap(id< MTLBlitCommandEncoder > encoder)
Definition: texture_mtl.mm:112
impeller::TextureMTL::TextureMTL
TextureMTL(TextureDescriptor desc, id< MTLTexture > texture, bool wrapped=false)
Definition: texture_mtl.mm:19
impeller::TextureMTL::GetMTLTexture
id< MTLTexture > GetMTLTexture() const
Definition: texture_mtl.mm:100
impeller::TextureMTL
Definition: texture_mtl.h:15
impeller::Texture
Definition: texture.h:17
impeller::TSize< int64_t >
backend_cast.h
impeller::TextureMTL::Wrapper
static std::shared_ptr< TextureMTL > Wrapper(TextureDescriptor desc, id< MTLTexture > texture, std::function< void()> deletion_proc=nullptr)
Definition: texture_mtl.mm:38
impeller::TextureMTL::~TextureMTL
~TextureMTL() override
impeller::BackendCast
Definition: backend_cast.h:12
impeller::TextureMTL::IsWrapped
bool IsWrapped() const
Definition: texture_mtl.mm:108
texture.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:39
impeller
Definition: aiks_context.cc:10