[Impeller] Switch SolidStrokeContents to use solid fill shaders; remove solid stroke shaders (flutter/engine#36624)
This commit is contained in:
@@ -1280,8 +1280,6 @@ FILE: ../../../flutter/impeller/entity/shaders/rrect_blur.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/rrect_blur.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/solid_fill.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/solid_fill.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/solid_stroke.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/solid_stroke.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/srgb_to_linear_filter.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/srgb_to_linear_filter.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/sweep_gradient_fill.frag
|
||||
|
||||
@@ -49,8 +49,6 @@ impeller_shaders("entity_shaders") {
|
||||
"shaders/rrect_blur.frag",
|
||||
"shaders/solid_fill.frag",
|
||||
"shaders/solid_fill.vert",
|
||||
"shaders/solid_stroke.frag",
|
||||
"shaders/solid_stroke.vert",
|
||||
"shaders/srgb_to_linear_filter.frag",
|
||||
"shaders/srgb_to_linear_filter.vert",
|
||||
"shaders/sweep_gradient_fill.frag",
|
||||
|
||||
@@ -204,8 +204,6 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
CreateDefaultPipeline<LinearToSrgbFilterPipeline>(*context_);
|
||||
srgb_to_linear_filter_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SrgbToLinearFilterPipeline>(*context_);
|
||||
solid_stroke_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SolidStrokePipeline>(*context_);
|
||||
glyph_atlas_pipelines_[{}] =
|
||||
CreateDefaultPipeline<GlyphAtlasPipeline>(*context_);
|
||||
glyph_atlas_sdf_pipelines_[{}] =
|
||||
|
||||
@@ -53,8 +53,6 @@
|
||||
#include "impeller/entity/rrect_blur.vert.h"
|
||||
#include "impeller/entity/solid_fill.frag.h"
|
||||
#include "impeller/entity/solid_fill.vert.h"
|
||||
#include "impeller/entity/solid_stroke.frag.h"
|
||||
#include "impeller/entity/solid_stroke.vert.h"
|
||||
#include "impeller/entity/srgb_to_linear_filter.frag.h"
|
||||
#include "impeller/entity/srgb_to_linear_filter.vert.h"
|
||||
#include "impeller/entity/sweep_gradient_fill.frag.h"
|
||||
@@ -145,8 +143,6 @@ using LinearToSrgbFilterPipeline =
|
||||
using SrgbToLinearFilterPipeline =
|
||||
RenderPipelineT<SrgbToLinearFilterVertexShader,
|
||||
SrgbToLinearFilterFragmentShader>;
|
||||
using SolidStrokePipeline =
|
||||
RenderPipelineT<SolidStrokeVertexShader, SolidStrokeFragmentShader>;
|
||||
using GlyphAtlasPipeline =
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
using GlyphAtlasSdfPipeline =
|
||||
@@ -271,11 +267,6 @@ class ContentContext {
|
||||
return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidStrokePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(solid_stroke_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(clip_pipelines_, opts);
|
||||
@@ -420,7 +411,6 @@ class ContentContext {
|
||||
color_matrix_color_filter_pipelines_;
|
||||
mutable Variants<LinearToSrgbFilterPipeline> linear_to_srgb_filter_pipelines_;
|
||||
mutable Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter_pipelines_;
|
||||
mutable Variants<SolidStrokePipeline> solid_stroke_pipelines_;
|
||||
mutable Variants<ClipPipeline> clip_pipelines_;
|
||||
mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_;
|
||||
mutable Variants<GlyphAtlasSdfPipeline> glyph_atlas_sdf_pipelines_;
|
||||
|
||||
@@ -73,7 +73,7 @@ static VertexBuffer CreateSolidStrokeVertices(
|
||||
const SolidStrokeContents::JoinProc& join_proc,
|
||||
Scalar miter_limit,
|
||||
const SmoothingApproximation& smoothing) {
|
||||
using VS = SolidStrokeVertexShader;
|
||||
using VS = SolidFillVertexShader;
|
||||
|
||||
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
|
||||
auto polyline = path.CreatePolyline();
|
||||
@@ -187,9 +187,6 @@ bool SolidStrokeContents::Render(const ContentContext& renderer,
|
||||
return true;
|
||||
}
|
||||
|
||||
using VS = SolidStrokePipeline::VertexShader;
|
||||
using FS = SolidStrokePipeline::FragmentShader;
|
||||
|
||||
VS::VertInfo vert_info;
|
||||
vert_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
|
||||
entity.GetTransformation();
|
||||
@@ -209,7 +206,7 @@ bool SolidStrokeContents::Render(const ContentContext& renderer,
|
||||
options.stencil_compare = CompareFunction::kEqual;
|
||||
options.stencil_operation = StencilOperation::kIncrementClamp;
|
||||
}
|
||||
cmd.pipeline = renderer.GetSolidStrokePipeline(options);
|
||||
cmd.pipeline = renderer.GetSolidFillPipeline(options);
|
||||
cmd.stencil_reference = entity.GetStencilDepth();
|
||||
|
||||
auto smoothing = SmoothingApproximation(
|
||||
@@ -255,7 +252,6 @@ Scalar SolidStrokeContents::GetStrokeMiter() {
|
||||
void SolidStrokeContents::SetStrokeCap(Cap cap) {
|
||||
cap_ = cap;
|
||||
|
||||
using VS = SolidStrokeVertexShader;
|
||||
switch (cap) {
|
||||
case Cap::kButt:
|
||||
cap_proc_ = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
@@ -266,7 +262,7 @@ void SolidStrokeContents::SetStrokeCap(Cap cap) {
|
||||
cap_proc_ = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
const Point& position, const Point& offset,
|
||||
const SmoothingApproximation& smoothing) {
|
||||
SolidStrokeVertexShader::PerVertexData vtx;
|
||||
VS::PerVertexData vtx;
|
||||
|
||||
Point forward(offset.y, -offset.x);
|
||||
Point forward_normal = forward.Normalize();
|
||||
@@ -293,7 +289,7 @@ void SolidStrokeContents::SetStrokeCap(Cap cap) {
|
||||
cap_proc_ = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
const Point& position, const Point& offset,
|
||||
const SmoothingApproximation& smoothing) {
|
||||
SolidStrokeVertexShader::PerVertexData vtx;
|
||||
VS::PerVertexData vtx;
|
||||
vtx.position = position;
|
||||
|
||||
Point forward(offset.y, -offset.x);
|
||||
@@ -316,11 +312,11 @@ SolidStrokeContents::Cap SolidStrokeContents::GetStrokeCap() {
|
||||
}
|
||||
|
||||
static Scalar CreateBevelAndGetDirection(
|
||||
VertexBufferBuilder<SolidStrokeVertexShader::PerVertexData>& vtx_builder,
|
||||
VertexBufferBuilder<SolidFillVertexShader::PerVertexData>& vtx_builder,
|
||||
const Point& position,
|
||||
const Point& start_offset,
|
||||
const Point& end_offset) {
|
||||
SolidStrokeVertexShader::PerVertexData vtx;
|
||||
SolidFillVertexShader::PerVertexData vtx;
|
||||
vtx.position = position;
|
||||
vtx_builder.AppendVertex(vtx);
|
||||
|
||||
@@ -336,7 +332,6 @@ static Scalar CreateBevelAndGetDirection(
|
||||
void SolidStrokeContents::SetStrokeJoin(Join join) {
|
||||
join_ = join;
|
||||
|
||||
using VS = SolidStrokeVertexShader;
|
||||
switch (join) {
|
||||
case Join::kBevel:
|
||||
join_proc_ = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
@@ -371,7 +366,7 @@ void SolidStrokeContents::SetStrokeJoin(Join join) {
|
||||
}
|
||||
|
||||
// Outer miter point.
|
||||
SolidStrokeVertexShader::PerVertexData vtx;
|
||||
VS::PerVertexData vtx;
|
||||
vtx.position = position + miter_point * dir;
|
||||
vtx_builder.AppendVertex(vtx);
|
||||
};
|
||||
@@ -409,7 +404,7 @@ void SolidStrokeContents::SetStrokeJoin(Join join) {
|
||||
middle_handle, middle)
|
||||
.CreatePolyline(smoothing);
|
||||
|
||||
SolidStrokeVertexShader::PerVertexData vtx;
|
||||
VS::PerVertexData vtx;
|
||||
for (const auto& point : arc_points) {
|
||||
vtx.position = position + point * dir;
|
||||
vtx_builder.AppendVertex(vtx);
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/entity/contents/contents.h"
|
||||
#include "impeller/entity/solid_stroke.vert.h"
|
||||
#include "impeller/entity/solid_fill.frag.h"
|
||||
#include "impeller/entity/solid_fill.vert.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
#include "impeller/geometry/path_component.h"
|
||||
#include "impeller/geometry/point.h"
|
||||
@@ -18,6 +20,9 @@
|
||||
namespace impeller {
|
||||
|
||||
class SolidStrokeContents final : public Contents {
|
||||
using VS = SolidFillVertexShader;
|
||||
using FS = SolidFillFragmentShader;
|
||||
|
||||
public:
|
||||
enum class Cap {
|
||||
kButt,
|
||||
@@ -31,18 +36,18 @@ class SolidStrokeContents final : public Contents {
|
||||
kBevel,
|
||||
};
|
||||
|
||||
using CapProc = std::function<void(
|
||||
VertexBufferBuilder<SolidStrokeVertexShader::PerVertexData>& vtx_builder,
|
||||
const Point& position,
|
||||
const Point& offset,
|
||||
const SmoothingApproximation& smoothing)>;
|
||||
using JoinProc = std::function<void(
|
||||
VertexBufferBuilder<SolidStrokeVertexShader::PerVertexData>& vtx_builder,
|
||||
const Point& position,
|
||||
const Point& start_offset,
|
||||
const Point& end_offset,
|
||||
Scalar miter_limit,
|
||||
const SmoothingApproximation& smoothing)>;
|
||||
using CapProc =
|
||||
std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
const Point& position,
|
||||
const Point& offset,
|
||||
const SmoothingApproximation& smoothing)>;
|
||||
using JoinProc =
|
||||
std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
|
||||
const Point& position,
|
||||
const Point& start_offset,
|
||||
const Point& end_offset,
|
||||
Scalar miter_limit,
|
||||
const SmoothingApproximation& smoothing)>;
|
||||
|
||||
SolidStrokeContents();
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// 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.
|
||||
|
||||
uniform FragInfo {
|
||||
vec4 color;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = frag_info.color;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// 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.
|
||||
|
||||
uniform VertInfo {
|
||||
mat4 mvp;
|
||||
}
|
||||
vert_info;
|
||||
|
||||
in vec2 position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vert_info.mvp * vec4(position, 0.0, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user