forked from firka/flutter
[Impeller] add alpha to tiled texture (flutter/engine#36102)
This commit is contained in:
@@ -118,7 +118,9 @@ TEST_P(AiksTest, CanRenderTiledTexture) {
|
||||
static int selected_y_tile_mode = 0;
|
||||
static int selected_mip_filter = 0;
|
||||
static int selected_min_mag_filter = 0;
|
||||
static float alpha = 1.0;
|
||||
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::SliderFloat("Alpha", &alpha, 0.0, 1.0);
|
||||
ImGui::Combo("X tile mode", &selected_x_tile_mode, tile_mode_names,
|
||||
sizeof(tile_mode_names) / sizeof(char*));
|
||||
ImGui::Combo("Y tile mode", &selected_y_tile_mode, tile_mode_names,
|
||||
@@ -159,6 +161,7 @@ TEST_P(AiksTest, CanRenderTiledTexture) {
|
||||
contents->SetMatrix(matrix);
|
||||
return contents;
|
||||
};
|
||||
paint.color = Color(1, 1, 1, alpha);
|
||||
canvas.DrawRect({0, 0, 600, 600}, paint);
|
||||
return renderer.Render(canvas.EndRecordingAsPicture(), render_target);
|
||||
};
|
||||
|
||||
@@ -91,6 +91,7 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
|
||||
frag_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
|
||||
frag_info.x_tile_mode = static_cast<Scalar>(x_tile_mode_);
|
||||
frag_info.y_tile_mode = static_cast<Scalar>(y_tile_mode_);
|
||||
frag_info.alpha = GetAlpha();
|
||||
|
||||
Command cmd;
|
||||
cmd.label = "TiledTextureFill";
|
||||
|
||||
@@ -10,6 +10,7 @@ uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float x_tile_mode;
|
||||
float y_tile_mode;
|
||||
float alpha;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
@@ -25,5 +26,5 @@ void main() {
|
||||
frag_info.texture_sampler_y_coord_scale, // y coordinate scale
|
||||
frag_info.x_tile_mode, // x tile mode
|
||||
frag_info.y_tile_mode // y tile mode
|
||||
);
|
||||
) * frag_info.alpha;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user