Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
contents_test_helpers.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_ENTITY_CONTENTS_TEST_CONTENTS_TEST_HELPERS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_TEST_CONTENTS_TEST_HELPERS_H_
7
9
10namespace impeller {
11
12/// @brief Retrieve the [VertInfo] struct data from the provided [command].
13template <typename T>
14typename T::VertInfo* GetVertInfo(const Command& command) {
15 auto resource = std::find_if(command.vertex_bindings.buffers.begin(),
16 command.vertex_bindings.buffers.end(),
17 [](const BufferAndUniformSlot& data) {
18 return data.slot.ext_res_0 == 0u;
19 });
20 if (resource == command.vertex_bindings.buffers.end()) {
21 return nullptr;
22 }
23
24 auto data = (resource->view.resource.buffer->OnGetContents() +
25 resource->view.resource.range.offset);
26 return reinterpret_cast<typename T::VertInfo*>(data);
27}
28
29/// @brief Retrieve the [FragInfo] struct data from the provided [command].
30template <typename T>
31typename T::FragInfo* GetFragInfo(const Command& command) {
32 auto resource = std::find_if(command.fragment_bindings.buffers.begin(),
33 command.fragment_bindings.buffers.end(),
34 [](const BufferAndUniformSlot& data) {
35 return data.slot.ext_res_0 == 0u ||
36 data.slot.binding == 64;
37 });
38 if (resource == command.fragment_bindings.buffers.end()) {
39 return nullptr;
40 }
41
42 auto data = (resource->view.resource.buffer->OnGetContents() +
43 resource->view.resource.range.offset);
44 return reinterpret_cast<typename T::FragInfo*>(data);
45}
46
47} // namespace impeller
48
49#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TEST_CONTENTS_TEST_HELPERS_H_
T::VertInfo * GetVertInfo(const Command &command)
Retrieve the [VertInfo] struct data from the provided [command].
T::FragInfo * GetFragInfo(const Command &command)
Retrieve the [FragInfo] struct data from the provided [command].
combines the buffer resource and its uniform slot information.
Definition command.h:68
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition command.h:92