| Flutter Impeller |

gradient_generator.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_GRADIENT_GENERATOR_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_GRADIENT_GENERATOR_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "flutter/impeller/core/texture.h"
12 #include "impeller/core/shader_types.h"
13 #include "impeller/geometry/color.h"
14 #include "impeller/geometry/gradient.h"
15
16 namespace impeller {
17
18 class Context;
19
20 /**
21 * @brief Create a host visible texture that contains the gradient defined
22 * by the provided gradient data.
23 */
24 std::shared_ptr<Texture> CreateGradientTexture(
25 const GradientData& gradient_data,
26 const std::shared_ptr<impeller::Context>& context);
27
28 struct StopData {
29 Color color;
30 Scalar stop;
31 Scalar inverse_delta;
32 Padding<8> _padding_;
33 };
34
35 static_assert(sizeof(StopData) == 32);
36
37 /**
38 * @brief Populate a vector with the color and stop data for a gradient
39 *
40 * @param colors
41 * @param stops
42 * @return StopData
43 */
44 std::vector<StopData> CreateGradientColors(const std::vector<Color>& colors,
45 const std::vector<Scalar>& stops);
46
47 } // namespace impeller
48
49 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_GRADIENT_GENERATOR_H_
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Color
Definition: color.h:123
impeller::StopData::stop
Scalar stop
Definition: gradient_generator.h:30
impeller::StopData::color
Color color
Definition: gradient_generator.h:29
gradient.h
impeller::StopData
Definition: gradient_generator.h:28
impeller::Padding< 8 >
impeller::StopData::inverse_delta
Scalar inverse_delta
Definition: gradient_generator.h:31
texture.h
impeller::StopData::_padding_
Padding< 8 > _padding_
Definition: gradient_generator.h:32
color.h
impeller::CreateGradientColors
std::vector< StopData > CreateGradientColors(const std::vector< Color > &colors, const std::vector< Scalar > &stops)
Populate a vector with the color and stop data for a gradient.
Definition: gradient_generator.cc:53
impeller::CreateGradientTexture
std::shared_ptr< Texture > CreateGradientTexture(const GradientData &gradient_data, const std::shared_ptr< impeller::Context > &context)
Create a host visible texture that contains the gradient defined by the provided gradient data.
Definition: gradient_generator.cc:16
shader_types.h
impeller
Definition: allocation.cc:12