-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] fix incorrect origins for mesh gradient computation. #54762
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,7 +379,7 @@ TEST_P(AiksTest, DrawVerticesWithInvalidIndices) { | |
| } | ||
|
|
||
| // All four vertices should form a solid red rectangle with no gaps. | ||
| // The blur rectangle drawn under them should not be visible. | ||
| // The blue rectangle drawn under them should not be visible. | ||
| TEST_P(AiksTest, DrawVerticesTextureCoordinatesWithFragmentShader) { | ||
| std::vector<SkPoint> positions_lt = { | ||
| SkPoint::Make(0, 0), // | ||
|
|
@@ -468,5 +468,54 @@ TEST_P(AiksTest, DrawVerticesTextureCoordinatesWithFragmentShader) { | |
| ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); | ||
| } | ||
|
|
||
| // The vertices should form a solid red rectangle with no gaps. | ||
| // The blue rectangle drawn under them should not be visible. | ||
| TEST_P(AiksTest, | ||
| DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOrigin) { | ||
| std::vector<SkPoint> positions_lt = { | ||
| SkPoint::Make(200, 200), // | ||
| SkPoint::Make(250, 200), // | ||
| SkPoint::Make(200, 250), // | ||
| SkPoint::Make(250, 250), // | ||
| }; | ||
|
|
||
| auto vertices = flutter::DlVertices::Make( | ||
| flutter::DlVertexMode::kTriangleStrip, positions_lt.size(), | ||
| positions_lt.data(), | ||
| /*texture_coordinates=*/positions_lt.data(), /*colors=*/nullptr, | ||
| /*index_count=*/0, | ||
| /*indices=*/nullptr); | ||
|
|
||
| flutter::DisplayListBuilder builder; | ||
| flutter::DlPaint paint; | ||
| flutter::DlPaint rect_paint; | ||
| rect_paint.setColor(DlColor::kBlue()); | ||
|
|
||
| auto runtime_stages = | ||
| OpenAssetAsRuntimeStage("runtime_stage_position.frag.iplr"); | ||
|
|
||
| auto runtime_stage = | ||
| runtime_stages[PlaygroundBackendToRuntimeStageBackend(GetBackend())]; | ||
| ASSERT_TRUE(runtime_stage); | ||
|
|
||
| auto runtime_effect = DlRuntimeEffect::MakeImpeller(runtime_stage); | ||
| auto rect_data = std::vector<Rect>{Rect::MakeLTRB(200, 200, 250, 250)}; | ||
|
|
||
| auto uniform_data = std::make_shared<std::vector<uint8_t>>(); | ||
| uniform_data->resize(rect_data.size() * sizeof(Rect)); | ||
| memcpy(uniform_data->data(), rect_data.data(), uniform_data->size()); | ||
|
|
||
| auto color_source = flutter::DlColorSource::MakeRuntimeEffect( | ||
| runtime_effect, {}, uniform_data); | ||
|
|
||
| paint.setColorSource(color_source); | ||
|
|
||
| builder.Scale(GetContentScale().x, GetContentScale().y); | ||
| builder.DrawRect(SkRect::MakeLTRB(200, 200, 250, 250), rect_paint); | ||
| builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint); | ||
|
|
||
| ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heads up you are going to need to add the included golden file to the list.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually just wait for the check to fail first and then copy the string.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // 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 <flutter/runtime_effect.glsl> | ||
|
|
||
| uniform vec4 ltrb; | ||
|
|
||
| out vec4 frag_color; | ||
|
|
||
| // Output solid red if frag position is within LTRB rectangle. | ||
| void main() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only outputs red if the rendered coordiantes match the expected coordinates. |
||
| if (FlutterFragCoord().x >= ltrb.x && FlutterFragCoord().x <= ltrb.z && | ||
| FlutterFragCoord().y >= ltrb.y && FlutterFragCoord().y <= ltrb.w) { | ||
| frag_color = vec4(1.0, 0.0, 0.0, 1.0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, what is frag_color if it's outside of the box? Shouldn't that be explicit here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can set it to transparent black, I think that is implied already.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering we are cross compiling the shaders it doesn't hurt, thanks. |
||
| } else { | ||
| frag_color = vec4(0.0); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No abbreviations ("lt").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done