Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3e0d9cc

Browse files
committed
Don't skip transparent draw calls
1 parent 0082b6d commit 3e0d9cc

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

impeller/entity/contents/solid_color_contents.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ VertexBuffer SolidColorContents::CreateSolidFillVertices(const Path& path,
6363
bool SolidColorContents::Render(const ContentContext& renderer,
6464
const Entity& entity,
6565
RenderPass& pass) const {
66-
if (color_.IsTransparent()) {
67-
return true;
68-
}
69-
7066
using VS = SolidFillPipeline::VertexShader;
7167

7268
Command cmd;

impeller/entity/contents/solid_stroke_contents.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void SolidStrokeContents::SetPath(Path path) {
3535

3636
std::optional<Rect> SolidStrokeContents::GetCoverage(
3737
const Entity& entity) const {
38+
if (color_.IsTransparent()) {
39+
return std::nullopt;
40+
}
41+
3842
auto path_bounds = path_.GetBoundingBox();
3943
if (!path_bounds.has_value()) {
4044
return std::nullopt;
@@ -173,7 +177,7 @@ static VertexBuffer CreateSolidStrokeVertices(
173177
bool SolidStrokeContents::Render(const ContentContext& renderer,
174178
const Entity& entity,
175179
RenderPass& pass) const {
176-
if (color_.IsTransparent() || stroke_size_ <= 0.0) {
180+
if (stroke_size_ <= 0.0) {
177181
return true;
178182
}
179183

impeller/entity/contents/texture_contents.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "texture_contents.h"
66

7+
#include <optional>
8+
79
#include "impeller/entity/contents/content_context.h"
810
#include "impeller/entity/entity.h"
911
#include "impeller/entity/texture_fill.frag.h"
@@ -35,6 +37,9 @@ void TextureContents::SetOpacity(Scalar opacity) {
3537
}
3638

3739
std::optional<Rect> TextureContents::GetCoverage(const Entity& entity) const {
40+
if (opacity_ == 0) {
41+
return std::nullopt;
42+
}
3843
return path_.GetTransformedBoundingBox(entity.GetTransformation());
3944
};
4045

impeller/entity/entity_unittests.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
897897
contents->SetStrokeCap(SolidStrokeContents::Cap::kButt);
898898
contents->SetStrokeJoin(SolidStrokeContents::Join::kBevel);
899899
contents->SetStrokeSize(4);
900+
contents->SetColor(Color::Black());
900901
entity.SetContents(std::move(contents));
901902
auto actual = entity.GetCoverage();
902903
auto expected = Rect::MakeLTRB(-2, -2, 12, 12);
@@ -912,6 +913,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
912913
contents->SetStrokeCap(SolidStrokeContents::Cap::kSquare);
913914
contents->SetStrokeJoin(SolidStrokeContents::Join::kBevel);
914915
contents->SetStrokeSize(4);
916+
contents->SetColor(Color::Black());
915917
entity.SetContents(std::move(contents));
916918
auto actual = entity.GetCoverage();
917919
auto expected =
@@ -929,6 +931,7 @@ TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
929931
contents->SetStrokeJoin(SolidStrokeContents::Join::kMiter);
930932
contents->SetStrokeSize(4);
931933
contents->SetStrokeMiter(2);
934+
contents->SetColor(Color::Black());
932935
entity.SetContents(std::move(contents));
933936
auto actual = entity.GetCoverage();
934937
auto expected = Rect::MakeLTRB(-4, -4, 14, 14);

0 commit comments

Comments
 (0)