| Flutter Impeller |

runtime_types.cc
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 #include "impeller/core/runtime_types.h"
6
7 namespace impeller {
8
9 size_t RuntimeUniformDescription::GetDartSize() const {
10 size_t size = 0;
11 if (!padding_layout.empty()) {
12 for (impeller::RuntimePaddingType byte_type : padding_layout) {
13 if (byte_type == RuntimePaddingType::kFloat) {
14 size += sizeof(float);
15 }
16 }
17 } else {
18 size = dimensions.rows * dimensions.cols * bit_width / 8u;
19 }
20 if (array_elements.value_or(0) > 0) {
21 // Covered by check on the line above.
22 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
23 size *= array_elements.value();
24 }
25 return size;
26 }
27
28 size_t RuntimeUniformDescription::GetGPUSize() const {
29 size_t size = 0;
30 if (padding_layout.empty()) {
31 size = dimensions.rows * dimensions.cols * bit_width / 8u;
32 } else {
33 size = sizeof(float) * padding_layout.size();
34 }
35 if (array_elements.value_or(0) > 0) {
36 // Covered by check on the line above.
37 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
38 size *= array_elements.value();
39 }
40 return size;
41 }
42
43 } // namespace impeller
impeller
Definition: allocation.cc:12
impeller::RuntimePaddingType
RuntimePaddingType
Definition: runtime_types.h:41
impeller::RuntimePaddingType::kFloat
@ kFloat
runtime_types.h
impeller::RuntimeUniformDescription::GetGPUSize
size_t GetGPUSize() const
Computes the total number of bytes that this uniform requires for representation in the GPU.
Definition: runtime_types.cc:28
impeller::RuntimeUniformDescription::dimensions
RuntimeUniformDimensions dimensions
Definition: runtime_types.h:58
impeller::RuntimeUniformDescription::GetDartSize
size_t GetDartSize() const
Computes the total number of bytes that this uniform requires for representation in the Dart float bu...
Definition: runtime_types.cc:9
impeller::RuntimeUniformDescription::padding_layout
std::vector< RuntimePaddingType > padding_layout
Definition: runtime_types.h:61
impeller::RuntimeUniformDescription::array_elements
std::optional< size_t > array_elements
Definition: runtime_types.h:60
impeller::RuntimeUniformDescription::bit_width
size_t bit_width
Definition: runtime_types.h:59
impeller::RuntimeUniformDimensions::cols
size_t cols
Definition: runtime_types.h:38
impeller::RuntimeUniformDimensions::rows
size_t rows
Definition: runtime_types.h:37