Flutter Impeller
device_buffer_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 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_DEVICE_BUFFER_MTL_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_DEVICE_BUFFER_MTL_H_
7 
8 #include <Metal/Metal.h>
9 
10 #include "flutter/fml/macros.h"
13 
14 namespace impeller {
15 
16 class DeviceBufferMTL final
17  : public DeviceBuffer,
18  public BackendCast<DeviceBufferMTL, DeviceBuffer> {
19  public:
21 
22  // |DeviceBuffer|
23  ~DeviceBufferMTL() override;
24 
25  id<MTLBuffer> GetMTLBuffer() const;
26 
27  private:
28  friend class AllocatorMTL;
29 
30  const id<MTLBuffer> buffer_;
31  const MTLStorageMode storage_mode_;
32 
34  id<MTLBuffer> buffer,
35  MTLStorageMode storage_mode);
36 
37  // |DeviceBuffer|
38  uint8_t* OnGetContents() const override;
39 
40  // |DeviceBuffer|
41  std::shared_ptr<Texture> AsTexture(Allocator& allocator,
42  const TextureDescriptor& descriptor,
43  uint16_t row_bytes) const override;
44 
45  // |DeviceBuffer|
46  bool OnCopyHostBuffer(const uint8_t* source,
47  Range source_range,
48  size_t offset) override;
49 
50  // |DeviceBuffer|
51  bool SetLabel(const std::string& label) override;
52 
53  // |DeviceBuffer|
54  bool SetLabel(const std::string& label, Range range) override;
55 
56  // |DeviceBuffer|
57  void Flush(std::optional<Range> range) const override;
58 
59  DeviceBufferMTL(const DeviceBufferMTL&) = delete;
60 
61  DeviceBufferMTL& operator=(const DeviceBufferMTL&) = delete;
62 };
63 
64 } // namespace impeller
65 
66 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_DEVICE_BUFFER_MTL_H_
impeller::AllocatorMTL
Definition: allocator_mtl.h:15
impeller::DeviceBuffer
Definition: device_buffer.h:19
impeller::DeviceBufferMTL::DeviceBufferMTL
DeviceBufferMTL()
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
device_buffer.h
impeller::DeviceBufferMTL
Definition: device_buffer_mtl.h:16
backend_cast.h
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:22
impeller::DeviceBufferMTL::GetMTLBuffer
id< MTLBuffer > GetMTLBuffer() const
Definition: device_buffer_mtl.mm:21
impeller::Range
Definition: range.h:14
impeller::BackendCast
Definition: backend_cast.h:11
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
offset
Point offset
Definition: stroke_path_geometry.cc:300
impeller::DeviceBufferMTL::~DeviceBufferMTL
~DeviceBufferMTL() override
impeller
Definition: aiks_blur_unittests.cc:20