Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
14namespace impeller {
15
16class 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_
An object that allocates device memory.
Definition allocator.h:22
uint8_t * OnGetContents() const override
bool SetLabel(const std::string &label) override
id< MTLBuffer > GetMTLBuffer() const
void Flush(std::optional< Range > range) const override
bool OnCopyHostBuffer(const uint8_t *source, Range source_range, size_t offset) override
std::shared_ptr< Texture > AsTexture(Allocator &allocator, const TextureDescriptor &descriptor, uint16_t row_bytes) const override
SkBitmap source
Definition examples.cpp:28
static const uint8_t buffer[]
Point offset
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...