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 #pragma once
6 
7 #include <Metal/Metal.h>
8 
9 #include "flutter/fml/macros.h"
12 
13 namespace impeller {
14 
15 class DeviceBufferMTL final : public DeviceBuffer,
16  public BackendCast<DeviceBufferMTL, Buffer> {
17  public:
19 
20  // |DeviceBuffer|
21  ~DeviceBufferMTL() override;
22 
23  id<MTLBuffer> GetMTLBuffer() const;
24 
25  private:
26  friend class AllocatorMTL;
27 
28  const id<MTLBuffer> buffer_;
29  const MTLStorageMode storage_mode_;
30 
32  id<MTLBuffer> buffer,
33  MTLStorageMode storage_mode);
34 
35  // |DeviceBuffer|
36  uint8_t* OnGetContents() const override;
37 
38  // |DeviceBuffer|
39  std::shared_ptr<Texture> AsTexture(Allocator& allocator,
40  const TextureDescriptor& descriptor,
41  uint16_t row_bytes) const override;
42 
43  // |DeviceBuffer|
44  bool OnCopyHostBuffer(const uint8_t* source,
45  Range source_range,
46  size_t offset) override;
47 
48  // |DeviceBuffer|
49  bool SetLabel(const std::string& label) override;
50 
51  // |DeviceBuffer|
52  bool SetLabel(const std::string& label, Range range) override;
53 
54  FML_DISALLOW_COPY_AND_ASSIGN(DeviceBufferMTL);
55 };
56 
57 } // namespace impeller
impeller::AllocatorMTL
Definition: allocator_mtl.h:14
impeller::DeviceBuffer
Definition: device_buffer.h:20
impeller::DeviceBufferMTL::DeviceBufferMTL
DeviceBufferMTL()
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:13
device_buffer.h
impeller::DeviceBufferMTL
Definition: device_buffer_mtl.h:15
backend_cast.h
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:25
impeller::DeviceBufferMTL::GetMTLBuffer
id< MTLBuffer > GetMTLBuffer() const
Definition: device_buffer_mtl.mm:21
impeller::Range
Definition: range.h:13
impeller::BackendCast
Definition: backend_cast.h:12
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::DeviceBufferMTL::~DeviceBufferMTL
~DeviceBufferMTL() override
impeller
Definition: aiks_context.cc:10