[Impeller] Implement two-point conical gradient. (flutter/engine#40236)
[Impeller] Implement two-point conical gradient.
This commit is contained in:
@@ -1123,6 +1123,8 @@ ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.cc + ../
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/content_context.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/content_context.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/contents.cc + ../../../flutter/LICENSE
|
||||
@@ -1237,6 +1239,8 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag + ../../.
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur.glsl + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/gaussian_blur.vert + ../../../flutter/LICENSE
|
||||
@@ -3652,6 +3656,8 @@ FILE: ../../../flutter/impeller/entity/contents/color_source_contents.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/color_source_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/content_context.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/content_context.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/contents.cc
|
||||
@@ -3766,6 +3772,8 @@ FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/conical_gradient_ssbo_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur.glsl
|
||||
FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur.vert
|
||||
|
||||
@@ -7,6 +7,29 @@
|
||||
|
||||
#include <impeller/texture.glsl>
|
||||
|
||||
/// Compute the t value for a conical gradient at point `p` between the 2
|
||||
/// circles defined by (c0, r0) and (c1, r1).
|
||||
///
|
||||
/// This assumes that c0 != c1.
|
||||
float IPComputeConicalT(vec2 c0, float r0, vec2 c1, float r1, vec2 p) {
|
||||
float w = 1.0;
|
||||
float result = 0.0;
|
||||
vec2 ab = c1 - c0;
|
||||
float dr = r1 - r0;
|
||||
// Set sample rate to a minimum for the case where c0 and c1 are close.
|
||||
float delta = max(1.0 / length(ab), 100.0);
|
||||
while (w >= 0.0) {
|
||||
vec2 cw = w * ab + c0;
|
||||
float rw = w * dr + r0;
|
||||
if (length(p - cw) <= rw) {
|
||||
result = w;
|
||||
break;
|
||||
}
|
||||
w -= delta;
|
||||
}
|
||||
return 1.0 - result;
|
||||
}
|
||||
|
||||
/// Compute the indexes and mix coefficient used to mix colors for an
|
||||
/// arbitrarily sized color gradient.
|
||||
///
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "impeller/display_list/display_list_image_impeller.h"
|
||||
#include "impeller/display_list/display_list_vertices_geometry.h"
|
||||
#include "impeller/display_list/nine_patch_converter.h"
|
||||
#include "impeller/entity/contents/conical_gradient_contents.h"
|
||||
#include "impeller/entity/contents/filters/filter_contents.h"
|
||||
#include "impeller/entity/contents/filters/inputs/filter_input.h"
|
||||
#include "impeller/entity/contents/linear_gradient_contents.h"
|
||||
@@ -405,6 +406,43 @@ void DisplayListDispatcher::setColorSource(
|
||||
};
|
||||
return;
|
||||
}
|
||||
case Paint::ColorSourceType::kConicalGradient: {
|
||||
const flutter::DlConicalGradientColorSource* conical_gradient =
|
||||
source->asConicalGradient();
|
||||
FML_DCHECK(conical_gradient);
|
||||
Point center = ToPoint(conical_gradient->end_center());
|
||||
SkScalar radius = conical_gradient->end_radius();
|
||||
Point focus_center = ToPoint(conical_gradient->start_center());
|
||||
SkScalar focus_radius = conical_gradient->start_radius();
|
||||
std::vector<Color> colors;
|
||||
std::vector<float> stops;
|
||||
ConvertStops(conical_gradient, &colors, &stops);
|
||||
|
||||
auto tile_mode = ToTileMode(conical_gradient->tile_mode());
|
||||
auto matrix = ToMatrix(conical_gradient->matrix());
|
||||
paint_.color_source = [center, radius, colors = std::move(colors),
|
||||
stops = std::move(stops), tile_mode, matrix,
|
||||
focus_center, focus_radius]() {
|
||||
std::shared_ptr<ConicalGradientContents> contents =
|
||||
std::make_shared<ConicalGradientContents>();
|
||||
contents->SetColors(colors);
|
||||
contents->SetStops(stops);
|
||||
contents->SetCenterAndRadius(center, radius);
|
||||
contents->SetTileMode(tile_mode);
|
||||
contents->SetEffectTransform(matrix);
|
||||
contents->SetFocus(focus_center, focus_radius);
|
||||
|
||||
auto radius_pt = Point(radius, radius);
|
||||
std::vector<Point> bounds{center + radius_pt, center - radius_pt};
|
||||
auto intrinsic_size =
|
||||
Rect::MakePointBounds(bounds.begin(), bounds.end());
|
||||
if (intrinsic_size.has_value()) {
|
||||
contents->SetColorSourceSize(intrinsic_size->size);
|
||||
}
|
||||
return contents;
|
||||
};
|
||||
return;
|
||||
}
|
||||
case Paint::ColorSourceType::kRadialGradient: {
|
||||
const flutter::DlRadialGradientColorSource* radialGradient =
|
||||
source->asRadialGradient();
|
||||
@@ -541,9 +579,6 @@ void DisplayListDispatcher::setColorSource(
|
||||
#endif // IMPELLER_ENABLE_3D
|
||||
return;
|
||||
}
|
||||
case Paint::ColorSourceType::kConicalGradient:
|
||||
UNIMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ impeller_shaders("entity_shaders") {
|
||||
"shaders/border_mask_blur.vert",
|
||||
"shaders/color_matrix_color_filter.frag",
|
||||
"shaders/color_matrix_color_filter.vert",
|
||||
"shaders/conical_gradient_fill.frag",
|
||||
"shaders/gaussian_blur.frag",
|
||||
"shaders/gaussian_blur_decal.frag",
|
||||
"shaders/gaussian_blur.vert",
|
||||
@@ -72,6 +73,7 @@ impeller_shaders("modern_entity_shaders") {
|
||||
}
|
||||
|
||||
shaders = [
|
||||
"shaders/conical_gradient_ssbo_fill.frag",
|
||||
"shaders/linear_gradient_ssbo_fill.frag",
|
||||
"shaders/radial_gradient_ssbo_fill.frag",
|
||||
"shaders/sweep_gradient_ssbo_fill.frag",
|
||||
@@ -122,6 +124,8 @@ impeller_component("entity") {
|
||||
"contents/color_source_contents.h",
|
||||
"contents/color_source_text_contents.cc",
|
||||
"contents/color_source_text_contents.h",
|
||||
"contents/conical_gradient_contents.cc",
|
||||
"contents/conical_gradient_contents.h",
|
||||
"contents/content_context.cc",
|
||||
"contents/content_context.h",
|
||||
"contents/contents.cc",
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "conical_gradient_contents.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "impeller/entity/contents/clip_contents.h"
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/entity/contents/gradient_generator.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/geometry.h"
|
||||
#include "impeller/geometry/gradient.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/sampler_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ConicalGradientContents::ConicalGradientContents() = default;
|
||||
|
||||
ConicalGradientContents::~ConicalGradientContents() = default;
|
||||
|
||||
void ConicalGradientContents::SetCenterAndRadius(Point center, Scalar radius) {
|
||||
center_ = center;
|
||||
radius_ = radius;
|
||||
}
|
||||
|
||||
void ConicalGradientContents::SetTileMode(Entity::TileMode tile_mode) {
|
||||
tile_mode_ = tile_mode;
|
||||
}
|
||||
|
||||
void ConicalGradientContents::SetColors(std::vector<Color> colors) {
|
||||
colors_ = std::move(colors);
|
||||
}
|
||||
|
||||
void ConicalGradientContents::SetStops(std::vector<Scalar> stops) {
|
||||
stops_ = std::move(stops);
|
||||
}
|
||||
|
||||
const std::vector<Color>& ConicalGradientContents::GetColors() const {
|
||||
return colors_;
|
||||
}
|
||||
|
||||
const std::vector<Scalar>& ConicalGradientContents::GetStops() const {
|
||||
return stops_;
|
||||
}
|
||||
|
||||
void ConicalGradientContents::SetFocus(std::optional<Point> focus,
|
||||
Scalar radius) {
|
||||
focus_ = focus;
|
||||
focus_radius_ = radius;
|
||||
}
|
||||
|
||||
bool ConicalGradientContents::Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetDeviceCapabilities().SupportsSSBO()) {
|
||||
return RenderSSBO(renderer, entity, pass);
|
||||
}
|
||||
return RenderTexture(renderer, entity, pass);
|
||||
}
|
||||
|
||||
bool ConicalGradientContents::RenderSSBO(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
using VS = ConicalGradientSSBOFillPipeline::VertexShader;
|
||||
using FS = ConicalGradientSSBOFillPipeline::FragmentShader;
|
||||
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.center = center_;
|
||||
frag_info.radius = radius_;
|
||||
frag_info.tile_mode = static_cast<Scalar>(tile_mode_);
|
||||
frag_info.alpha = GetAlpha();
|
||||
if (focus_) {
|
||||
frag_info.focus = focus_.value();
|
||||
frag_info.focus_radius = focus_radius_;
|
||||
} else {
|
||||
frag_info.focus = center_;
|
||||
frag_info.focus_radius = 0.0;
|
||||
}
|
||||
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
auto colors = CreateGradientColors(colors_, stops_);
|
||||
|
||||
frag_info.colors_length = colors.size();
|
||||
auto color_buffer =
|
||||
host_buffer.Emplace(colors.data(), colors.size() * sizeof(StopData),
|
||||
DefaultUniformAlignment());
|
||||
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
|
||||
entity.GetTransformation();
|
||||
frame_info.matrix = GetInverseMatrix();
|
||||
|
||||
Command cmd;
|
||||
cmd.label = "ConicalGradientSSBOFill";
|
||||
cmd.stencil_reference = entity.GetStencilDepth();
|
||||
|
||||
auto geometry_result =
|
||||
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
|
||||
auto options = OptionsFromPassAndEntity(pass, entity);
|
||||
if (geometry_result.prevent_overdraw) {
|
||||
options.stencil_compare = CompareFunction::kEqual;
|
||||
options.stencil_operation = StencilOperation::kIncrementClamp;
|
||||
}
|
||||
options.primitive_type = geometry_result.type;
|
||||
cmd.pipeline = renderer.GetConicalGradientSSBOFillPipeline(options);
|
||||
|
||||
cmd.BindVertices(geometry_result.vertex_buffer);
|
||||
FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info));
|
||||
FS::BindColorData(cmd, color_buffer);
|
||||
VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info));
|
||||
|
||||
if (!pass.AddCommand(std::move(cmd))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (geometry_result.prevent_overdraw) {
|
||||
auto restore = ClipRestoreContents();
|
||||
restore.SetRestoreCoverage(GetCoverage(entity));
|
||||
return restore.Render(renderer, entity, pass);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConicalGradientContents::RenderTexture(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
using VS = ConicalGradientFillPipeline::VertexShader;
|
||||
using FS = ConicalGradientFillPipeline::FragmentShader;
|
||||
|
||||
auto gradient_data = CreateGradientBuffer(colors_, stops_);
|
||||
auto gradient_texture =
|
||||
CreateGradientTexture(gradient_data, renderer.GetContext());
|
||||
if (gradient_texture == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FS::FragInfo frag_info;
|
||||
frag_info.center = center_;
|
||||
frag_info.radius = radius_;
|
||||
frag_info.tile_mode = static_cast<Scalar>(tile_mode_);
|
||||
frag_info.texture_sampler_y_coord_scale = gradient_texture->GetYCoordScale();
|
||||
frag_info.alpha = GetAlpha();
|
||||
frag_info.half_texel = Vector2(0.5 / gradient_texture->GetSize().width,
|
||||
0.5 / gradient_texture->GetSize().height);
|
||||
if (focus_) {
|
||||
frag_info.focus = focus_.value();
|
||||
frag_info.focus_radius = focus_radius_;
|
||||
} else {
|
||||
frag_info.focus = center_;
|
||||
frag_info.focus_radius = 0.0;
|
||||
}
|
||||
|
||||
auto geometry_result =
|
||||
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
|
||||
|
||||
VS::FrameInfo frame_info;
|
||||
frame_info.mvp = geometry_result.transform;
|
||||
frame_info.matrix = GetInverseMatrix();
|
||||
|
||||
Command cmd;
|
||||
cmd.label = "ConicalGradientFill";
|
||||
cmd.stencil_reference = entity.GetStencilDepth();
|
||||
|
||||
auto options = OptionsFromPassAndEntity(pass, entity);
|
||||
if (geometry_result.prevent_overdraw) {
|
||||
options.stencil_compare = CompareFunction::kEqual;
|
||||
options.stencil_operation = StencilOperation::kIncrementClamp;
|
||||
}
|
||||
options.primitive_type = geometry_result.type;
|
||||
cmd.pipeline = renderer.GetConicalGradientFillPipeline(options);
|
||||
|
||||
cmd.BindVertices(geometry_result.vertex_buffer);
|
||||
FS::BindFragInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frag_info));
|
||||
SamplerDescriptor sampler_desc;
|
||||
sampler_desc.min_filter = MinMagFilter::kLinear;
|
||||
sampler_desc.mag_filter = MinMagFilter::kLinear;
|
||||
FS::BindTextureSampler(
|
||||
cmd, gradient_texture,
|
||||
renderer.GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc));
|
||||
VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info));
|
||||
|
||||
if (!pass.AddCommand(std::move(cmd))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (geometry_result.prevent_overdraw) {
|
||||
auto restore = ClipRestoreContents();
|
||||
restore.SetRestoreCoverage(GetCoverage(entity));
|
||||
return restore.Render(renderer, entity, pass);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/entity/contents/color_source_contents.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
#include "impeller/geometry/gradient.h"
|
||||
#include "impeller/geometry/path.h"
|
||||
#include "impeller/geometry/point.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ConicalGradientContents final : public ColorSourceContents {
|
||||
public:
|
||||
ConicalGradientContents();
|
||||
|
||||
~ConicalGradientContents() override;
|
||||
|
||||
// |Contents|
|
||||
bool Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const override;
|
||||
|
||||
void SetCenterAndRadius(Point center, Scalar radius);
|
||||
|
||||
void SetColors(std::vector<Color> colors);
|
||||
|
||||
void SetStops(std::vector<Scalar> stops);
|
||||
|
||||
const std::vector<Color>& GetColors() const;
|
||||
|
||||
const std::vector<Scalar>& GetStops() const;
|
||||
|
||||
void SetTileMode(Entity::TileMode tile_mode);
|
||||
|
||||
void SetFocus(std::optional<Point> focus, Scalar radius);
|
||||
|
||||
private:
|
||||
bool RenderTexture(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const;
|
||||
|
||||
bool RenderSSBO(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const;
|
||||
Point center_;
|
||||
Scalar radius_ = 0.0f;
|
||||
std::vector<Color> colors_;
|
||||
std::vector<Scalar> stops_;
|
||||
Entity::TileMode tile_mode_;
|
||||
std::optional<Point> focus_;
|
||||
Scalar focus_radius_ = 0.0f;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ConicalGradientContents);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -175,11 +175,15 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
CreateDefaultPipeline<LinearGradientFillPipeline>(*context_);
|
||||
radial_gradient_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<RadialGradientFillPipeline>(*context_);
|
||||
conical_gradient_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<ConicalGradientFillPipeline>(*context_);
|
||||
if (context_->GetDeviceCapabilities().SupportsSSBO()) {
|
||||
linear_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<LinearGradientSSBOFillPipeline>(*context_);
|
||||
radial_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<RadialGradientSSBOFillPipeline>(*context_);
|
||||
conical_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<ConicalGradientSSBOFillPipeline>(*context_);
|
||||
sweep_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SweepGradientSSBOFillPipeline>(*context_);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "impeller/entity/border_mask_blur.vert.h"
|
||||
#include "impeller/entity/color_matrix_color_filter.frag.h"
|
||||
#include "impeller/entity/color_matrix_color_filter.vert.h"
|
||||
#include "impeller/entity/conical_gradient_fill.frag.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/gaussian_blur.frag.h"
|
||||
#include "impeller/entity/gaussian_blur.vert.h"
|
||||
@@ -57,6 +58,7 @@
|
||||
#include "impeller/scene/scene_context.h"
|
||||
#include "impeller/typographer/glyph_atlas.h"
|
||||
|
||||
#include "impeller/entity/conical_gradient_ssbo_fill.frag.h"
|
||||
#include "impeller/entity/linear_gradient_ssbo_fill.frag.h"
|
||||
#include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
|
||||
#include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"
|
||||
@@ -103,11 +105,17 @@ using SolidFillPipeline =
|
||||
RenderPipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
using RadialGradientFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader, RadialGradientFillFragmentShader>;
|
||||
using ConicalGradientFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader,
|
||||
ConicalGradientFillFragmentShader>;
|
||||
using SweepGradientFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader, SweepGradientFillFragmentShader>;
|
||||
using LinearGradientSSBOFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader,
|
||||
LinearGradientSsboFillFragmentShader>;
|
||||
using ConicalGradientSSBOFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader,
|
||||
ConicalGradientSsboFillFragmentShader>;
|
||||
using RadialGradientSSBOFillPipeline =
|
||||
RenderPipelineT<GradientFillVertexShader,
|
||||
RadialGradientSsboFillFragmentShader>;
|
||||
@@ -323,6 +331,12 @@ class ContentContext {
|
||||
return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||
return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const {
|
||||
FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
|
||||
@@ -334,6 +348,11 @@ class ContentContext {
|
||||
return GetPipeline(radial_gradient_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetConicalGradientFillPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(conical_gradient_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(rrect_blur_pipelines_, opts);
|
||||
@@ -630,11 +649,15 @@ class ContentContext {
|
||||
mutable Variants<SolidFillPipeline> solid_fill_pipelines_;
|
||||
mutable Variants<LinearGradientFillPipeline> linear_gradient_fill_pipelines_;
|
||||
mutable Variants<RadialGradientFillPipeline> radial_gradient_fill_pipelines_;
|
||||
mutable Variants<ConicalGradientFillPipeline>
|
||||
conical_gradient_fill_pipelines_;
|
||||
mutable Variants<SweepGradientFillPipeline> sweep_gradient_fill_pipelines_;
|
||||
mutable Variants<LinearGradientSSBOFillPipeline>
|
||||
linear_gradient_ssbo_fill_pipelines_;
|
||||
mutable Variants<RadialGradientSSBOFillPipeline>
|
||||
radial_gradient_ssbo_fill_pipelines_;
|
||||
mutable Variants<ConicalGradientSSBOFillPipeline>
|
||||
conical_gradient_ssbo_fill_pipelines_;
|
||||
mutable Variants<SweepGradientSSBOFillPipeline>
|
||||
sweep_gradient_ssbo_fill_pipelines_;
|
||||
mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/gradient.glsl>
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
uniform sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
vec2 center;
|
||||
float radius;
|
||||
float tile_mode;
|
||||
float texture_sampler_y_coord_scale;
|
||||
float alpha;
|
||||
vec2 half_texel;
|
||||
vec2 focus;
|
||||
float focus_radius;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
float t =
|
||||
IPComputeConicalT(frag_info.center, frag_info.radius, frag_info.focus,
|
||||
frag_info.focus_radius, v_position);
|
||||
frag_color = IPSampleLinearWithTileMode(
|
||||
texture_sampler, vec2(t, 0.5), frag_info.texture_sampler_y_coord_scale,
|
||||
frag_info.half_texel, frag_info.tile_mode);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * frag_info.alpha;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <impeller/gradient.glsl>
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
struct ColorPoint {
|
||||
vec4 color;
|
||||
float stop;
|
||||
};
|
||||
|
||||
layout(std140) readonly buffer ColorData {
|
||||
ColorPoint colors[];
|
||||
}
|
||||
color_data;
|
||||
|
||||
uniform FragInfo {
|
||||
vec2 center;
|
||||
float radius;
|
||||
float tile_mode;
|
||||
float alpha;
|
||||
int colors_length;
|
||||
vec2 focus;
|
||||
float focus_radius;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
float t =
|
||||
IPComputeConicalT(frag_info.center, frag_info.radius, frag_info.focus,
|
||||
frag_info.focus_radius, v_position);
|
||||
|
||||
if ((t < 0.0 || t > 1.0) && frag_info.tile_mode == kTileModeDecal) {
|
||||
frag_color = vec4(0);
|
||||
return;
|
||||
}
|
||||
t = IPFloatTile(t, frag_info.tile_mode);
|
||||
|
||||
vec4 result_color = vec4(0);
|
||||
for (int i = 1; i < frag_info.colors_length; i++) {
|
||||
ColorPoint prev_point = color_data.colors[i - 1];
|
||||
ColorPoint current_point = color_data.colors[i];
|
||||
if (t >= prev_point.stop && t <= current_point.stop) {
|
||||
float delta = (current_point.stop - prev_point.stop);
|
||||
if (delta < 0.001) {
|
||||
result_color = current_point.color;
|
||||
} else {
|
||||
float ratio = (t - prev_point.stop) / delta;
|
||||
result_color = mix(prev_point.color, current_point.color, ratio);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
frag_color =
|
||||
vec4(result_color.xyz * result_color.a, result_color.a) * frag_info.alpha;
|
||||
}
|
||||
@@ -2794,6 +2794,123 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/conical_gradient_fill.frag.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
"filename": "flutter/impeller/entity/gles/conical_gradient_fill.frag.gles",
|
||||
"has_side_effects": false,
|
||||
"has_uniform_computation": true,
|
||||
"modifies_coverage": false,
|
||||
"reads_color_buffer": false,
|
||||
"type": "Fragment",
|
||||
"uses_late_zs_test": false,
|
||||
"uses_late_zs_update": false,
|
||||
"variants": {
|
||||
"Main": {
|
||||
"fp16_arithmetic": 61,
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
null
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
],
|
||||
"pipelines": [
|
||||
"arith_total",
|
||||
"arith_fma",
|
||||
"arith_cvt",
|
||||
"arith_sfu",
|
||||
"load_store",
|
||||
"varying",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_cvt"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
0.25,
|
||||
0.234375,
|
||||
0.25,
|
||||
0.1875,
|
||||
0.0,
|
||||
0.125,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arith_total",
|
||||
"arith_cvt"
|
||||
],
|
||||
"total_cycles": [
|
||||
0.59375,
|
||||
0.375,
|
||||
0.59375,
|
||||
0.1875,
|
||||
0.0,
|
||||
0.125,
|
||||
0.25
|
||||
]
|
||||
},
|
||||
"stack_spill_bytes": 0,
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 14,
|
||||
"work_registers_used": 20
|
||||
}
|
||||
}
|
||||
},
|
||||
"Mali-T880": {
|
||||
"core": "Mali-T880",
|
||||
"filename": "flutter/impeller/entity/gles/conical_gradient_fill.frag.gles",
|
||||
"has_uniform_computation": true,
|
||||
"type": "Fragment",
|
||||
"variants": {
|
||||
"Main": {
|
||||
"has_stack_spilling": false,
|
||||
"performance": {
|
||||
"longest_path_bound_pipelines": [
|
||||
null
|
||||
],
|
||||
"longest_path_cycles": [
|
||||
null,
|
||||
null,
|
||||
null
|
||||
],
|
||||
"pipelines": [
|
||||
"arithmetic",
|
||||
"load_store",
|
||||
"texture"
|
||||
],
|
||||
"shortest_path_bound_pipelines": [
|
||||
"arithmetic"
|
||||
],
|
||||
"shortest_path_cycles": [
|
||||
1.9800000190734863,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"total_bound_pipelines": [
|
||||
"arithmetic"
|
||||
],
|
||||
"total_cycles": [
|
||||
9.333333015441895,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"thread_occupancy": 100,
|
||||
"uniform_registers_used": 3,
|
||||
"work_registers_used": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"flutter/impeller/entity/gles/gaussian_blur.frag.gles": {
|
||||
"Mali-G78": {
|
||||
"core": "Mali-G78",
|
||||
|
||||
Reference in New Issue
Block a user