-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] fix drawVertices dest fast path to apply alpha. #47695
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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/entity/contents/test/contents_test_helpers.h" | ||
|
||
namespace impeller { | ||
|
||
// | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 "impeller/renderer/command.h" | ||
|
||
namespace impeller { | ||
|
||
/// @brief Retrieve the [VertInfo] struct data from the provided [command]. | ||
template <typename T> | ||
typename T::VertInfo* GetVertInfo(const Command& command) { | ||
auto resource = command.vertex_bindings.buffers.find(0u); | ||
if (resource == command.vertex_bindings.buffers.end()) { | ||
return nullptr; | ||
} | ||
|
||
auto data = (resource->second.view.resource.contents + | ||
resource->second.view.resource.range.offset); | ||
return reinterpret_cast<typename T::VertInfo*>(data); | ||
} | ||
|
||
/// @brief Retrieve the [FragInfo] struct data from the provided [command]. | ||
template <typename T> | ||
typename T::FragInfo* GetFragInfo(const Command& command) { | ||
auto resource = command.fragment_bindings.buffers.find(0u); | ||
if (resource == command.fragment_bindings.buffers.end()) { | ||
return nullptr; | ||
} | ||
|
||
auto data = (resource->second.view.resource.contents + | ||
resource->second.view.resource.range.offset); | ||
return reinterpret_cast<typename T::FragInfo*>(data); | ||
} | ||
|
||
} // namespace impeller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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 <memory> | ||
#include <optional> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "impeller/entity/contents/contents.h" | ||
#include "impeller/entity/contents/solid_color_contents.h" | ||
#include "impeller/entity/contents/test/contents_test_helpers.h" | ||
#include "impeller/entity/contents/vertices_contents.h" | ||
#include "impeller/entity/entity.h" | ||
#include "impeller/entity/entity_playground.h" | ||
#include "impeller/entity/vertices.frag.h" | ||
#include "impeller/geometry/path_builder.h" | ||
#include "impeller/renderer/render_target.h" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
||
using EntityTest = EntityPlayground; | ||
INSTANTIATE_PLAYGROUND_SUITE(EntityTest); | ||
|
||
std::shared_ptr<VerticesGeometry> CreateColorVertices( | ||
const std::vector<Point>& vertices, | ||
const std::vector<Color>& colors) { | ||
auto bounds = Rect::MakePointBounds(vertices.begin(), vertices.end()); | ||
std::vector<uint16_t> indices = {}; | ||
for (auto i = 0u; i < vertices.size(); i++) { | ||
indices.emplace_back(i); | ||
} | ||
std::vector<Point> texture_coordinates = {}; | ||
|
||
return std::make_shared<VerticesGeometry>( | ||
vertices, indices, texture_coordinates, colors, | ||
bounds.value_or(Rect::MakeLTRB(0, 0, 0, 0)), | ||
VerticesGeometry::VertexMode::kTriangles); | ||
} | ||
|
||
// Verifies that the destination blend fast path still sets an alpha value. | ||
TEST_P(EntityTest, RendersDstPerColorWithAlpha) { | ||
using FS = GeometryColorPipeline::FragmentShader; | ||
|
||
auto contents = std::make_shared<VerticesContents>(); | ||
auto vertices = CreateColorVertices( | ||
{{0, 0}, {100, 0}, {0, 100}, {100, 0}, {0, 100}, {100, 100}}, | ||
{Color::Red(), Color::Red(), Color::Red(), Color::Red(), Color::Red(), | ||
Color::Red()}); | ||
auto src_contents = SolidColorContents::Make( | ||
PathBuilder{}.AddRect(Rect::MakeLTRB(0, 0, 100, 100)).TakePath(), | ||
Color::Red()); | ||
|
||
contents->SetGeometry(vertices); | ||
contents->SetAlpha(0.5); | ||
contents->SetBlendMode(BlendMode::kDestination); | ||
contents->SetSourceContents(std::move(src_contents)); | ||
|
||
auto content_context = GetContentContext(); | ||
auto buffer = content_context->GetContext()->CreateCommandBuffer(); | ||
auto render_target = RenderTarget::CreateOffscreenMSAA( | ||
*content_context->GetContext(), | ||
*GetContentContext()->GetRenderTargetCache(), {100, 100}); | ||
auto render_pass = buffer->CreateRenderPass(render_target); | ||
Entity entity; | ||
|
||
ASSERT_TRUE(render_pass->GetCommands().empty()); | ||
ASSERT_TRUE(contents->Render(*content_context, entity, *render_pass)); | ||
|
||
const auto& cmd = render_pass->GetCommands()[0]; | ||
auto* frag_uniforms = GetFragInfo<FS>(cmd); | ||
|
||
ASSERT_EQ(frag_uniforms->alpha, 0.5); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace impeller |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is the bug