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

Conversation

@JsouLiang
Copy link
Contributor

Implement blend param in DrawVertices and DrawAtlas
Association issue: flutter/flutter#108047

std::min(value.z, threshold), std::min(value.w, threshold));
}

Color blendColor(const Color& src,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an expert about rendering here, but I wonder whether this is efficient or not? Seems that the cost of a switch has to be performed for each and every color.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry about the performance until we have traces that show performance here is a bottleneck. That said, if we did need to change things, we could always up this function to operate over an entire vector at once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry about the performance until we have traces that show performance here is a bottleneck.

You are right!

we could always up this function to operate over an entire vector at once

That is what I was thinking :)

auto sample_rect = texture_coords_[i];
auto matrix = transforms_[i];
auto color = (colors_.size() > 0 ? colors_[i] : Color::Black());
auto color = (colors_.size() > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that this is correct - for drawAtlas we blend the colors with the texture sample which must be done in the shader: https://api.flutter.dev/flutter/dart-ui/Canvas/drawAtlas.html

Blend each rectangular portion of the image specified by an entry in the rects argument with its associated entry in the colors list using the blendMode argument (if a color is specified). In this part of the operation, the image part will be considered the source of the operation and the associated color will be considered the destination.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far -- mostly comments about where stuff should live.

@JsouLiang JsouLiang requested review from bdero, fzyzcjy and jonahwilliams and removed request for fzyzcjy September 14, 2022 13:38
@JsouLiang JsouLiang force-pushed the blend-color-for-vertices-atlas branch from 92c86f6 to 2e2ff17 Compare September 14, 2022 13:40
}
};

auto generator_expected_colors = [](Color& src,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not use a closure like this to generate the expected colors. A frequent mistake made with this sorts of tests, is that someone writes some code (with a bug), copies and pastes the implementation into the test generator (with the same bug) and asserts that they are the same - which they will be, but still wrong.

Instead each test case should have a specified color that a developer could easily cross reference with an external source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after addressing final comments, thanks!

@JsouLiang JsouLiang force-pushed the blend-color-for-vertices-atlas branch from d334e58 to 9695976 Compare September 15, 2022 06:49
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JsouLiang JsouLiang force-pushed the blend-color-for-vertices-atlas branch from 11e82a2 to 8ad01de Compare September 19, 2022 03:08
@JsouLiang JsouLiang merged commit ba7eee9 into flutter:main Sep 19, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
* Add color blend mode

* Move Entrity::BlendMode to Color file; Add unittest for blendMode color

* Fix some comments

* fix comments

* delete the redundancy code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants