7 #include "flutter/fml/logging.h"
19 const std::shared_ptr<impeller::Context>& context) {
21 FML_DLOG(ERROR) <<
"Invalid gradient data.";
35 const std::vector<Scalar>& stops) {
36 FML_DCHECK(stops.size() == colors.size());
38 std::vector<StopData> result;
39 result.reserve(stops.size());
41 for (
auto i = 0u; i < stops.size(); i++) {
42 Scalar delta = stops[i] - last_stop;
43 Scalar inverse_delta = delta == 0.0f ? 0.0 : 1.0 / delta;
45 .
color = colors[i], .stop = stops[i], .inverse_delta = inverse_delta});
52 const std::vector<Color>& colors,
53 const std::vector<Scalar>& stops,
56 FML_DCHECK(stops.size() == colors.size());
61 Scalar cur_stop = stops[i];
62 Scalar delta = cur_stop - last_stop;
63 Scalar inverse_delta = delta == 0.0f ? 0.0 : 1.0 / delta;
64 frag_info_colors[index] = colors[i];
66 frag_info_stop_pairs[index / 2].x = cur_stop;
67 frag_info_stop_pairs[index / 2].y = inverse_delta;
69 frag_info_stop_pairs[index / 2].z = cur_stop;
70 frag_info_stop_pairs[index / 2].w = inverse_delta;
int PopulateUniformGradientColors(const std::vector< Color > &colors, const std::vector< Scalar > &stops, Vector4 frag_info_colors[kMaxUniformGradientStops], Vector4 frag_info_stop_pairs[kMaxUniformGradientStops/2])
Populate 2 arrays with the colors and stop data for a gradient.
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.
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.
static constexpr uint32_t kMaxUniformGradientStops
std::shared_ptr< Texture > CreateTexture(const TextureDescriptor &texture_descriptor, const std::vector< uint8_t > &data, const std::shared_ptr< impeller::Context > &context, std::string_view debug_label)
std::vector< uint8_t > color_bytes
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...