Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ copy("impeller") {
"color.glsl",
"conical_gradient_uniform_fill.glsl",
"constants.glsl",
"conversions.glsl",
"dithering.glsl",
"external_texture_oes.glsl",
"gaussian.glsl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ uniform FragInfo {
float radius;
float tile_mode;
vec4 decal_border_color;
float texture_sampler_y_coord_scale;
float alpha;
vec2 half_texel;
vec2 focus;
Expand All @@ -28,13 +27,11 @@ vec4 DoConicalGradientTextureFill(vec2 res) {
}

float t = res.x;
vec4 result =
IPSampleLinearWithTileMode(texture_sampler, //
vec2(t, 0.5), //
frag_info.texture_sampler_y_coord_scale, //
frag_info.half_texel, //
frag_info.tile_mode, //
frag_info.decal_border_color);
vec4 result = IPSampleLinearWithTileMode(texture_sampler, //
vec2(t, 0.5), //
frag_info.half_texel, //
frag_info.tile_mode, //
frag_info.decal_border_color);
result = IPPremultiply(result) * frag_info.alpha;
return result;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,25 @@
#define TEXTURE_GLSL_

#include <impeller/branching.glsl>
#include <impeller/conversions.glsl>
#include <impeller/tile_mode.glsl>
#include <impeller/types.glsl>

/// Sample from a texture.
///
/// If `y_coord_scale` < 0.0, the Y coordinate is flipped. This is useful
/// for Impeller graphics backends that use a flipped framebuffer coordinate
/// space.
///
/// A negative mip bias is applied to improve the sharpness of scaled down
/// images when mip sampling is enabled. See `kDefaultMipBias` for more detail.
vec4 IPSample(sampler2D texture_sampler, vec2 coords, float y_coord_scale) {
return texture(texture_sampler, IPRemapCoords(coords, y_coord_scale),
kDefaultMipBias);
vec4 IPSample(sampler2D texture_sampler, vec2 coords) {
return texture(texture_sampler, coords, kDefaultMipBias);
}

/// Sample from a texture.
///
/// If `y_coord_scale` < 0.0, the Y coordinate is flipped. This is useful
/// for Impeller graphics backends that use a flipped framebuffer coordinate
/// space.
/// The range of `coords` will be mapped from [0, 1] to [half_texel, 1 -
/// half_texel]
vec4 IPSampleLinear(sampler2D texture_sampler,
vec2 coords,
float y_coord_scale,
vec2 half_texel) {
vec4 IPSampleLinear(sampler2D texture_sampler, vec2 coords, vec2 half_texel) {
coords.x = mix(half_texel.x, 1 - half_texel.x, coords.x);
coords.y = mix(half_texel.y, 1 - half_texel.y, coords.y);
return IPSample(texture_sampler, coords, y_coord_scale);
return IPSample(texture_sampler, coords);
}

/// Remap a float using a tiling mode.
Expand Down Expand Up @@ -106,7 +94,6 @@ f16vec4 IPHalfSampleWithTileMode(f16sampler2D tex,
/// half_texel]
vec4 IPSampleLinearWithTileMode(sampler2D tex,
vec2 coords,
float y_coord_scale,
vec2 half_texel,
float x_tile_mode,
float y_tile_mode,
Expand All @@ -117,7 +104,7 @@ vec4 IPSampleLinearWithTileMode(sampler2D tex,
}

return IPSampleLinear(tex, IPVec2Tile(coords, x_tile_mode, y_tile_mode),
y_coord_scale, half_texel);
half_texel);
}

/// Sample a texture with decal tile mode.
Expand Down Expand Up @@ -146,12 +133,11 @@ f16vec4 IPHalfSampleDecal(f16sampler2D texture_sampler, vec2 coords) {
/// half_texel]
vec4 IPSampleLinearWithTileMode(sampler2D tex,
vec2 coords,
float y_coord_scale,
vec2 half_texel,
float tile_mode,
vec4 decal_border_color) {
return IPSampleLinearWithTileMode(tex, coords, y_coord_scale, half_texel,
tile_mode, tile_mode, decal_border_color);
return IPSampleLinearWithTileMode(tex, coords, half_texel, tile_mode,
tile_mode, decal_border_color);
}

#endif
4 changes: 0 additions & 4 deletions engine/src/flutter/impeller/core/texture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ TextureCoordinateSystem Texture::GetCoordinateSystem() const {
return coordinate_system_;
}

Scalar Texture::GetYCoordScale() const {
return 1.0;
}

bool Texture::NeedsMipmapGeneration() const {
return !mipmap_generated_ && desc_.mip_count > 1;
}
Expand Down
2 changes: 0 additions & 2 deletions engine/src/flutter/impeller/core/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class Texture {

TextureCoordinateSystem GetCoordinateSystem() const;

virtual Scalar GetYCoordScale() const;

/// Returns true if mipmaps have never been generated.
/// The contents of the mipmap may be out of date if the root texture has been
/// modified and the mipmaps hasn't been regenerated.
Expand Down
8 changes: 0 additions & 8 deletions engine/src/flutter/impeller/entity/contents/atlas_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ bool AtlasContents::Render(const ContentContext& renderer,

VS::FrameInfo frame_info;
frame_info.mvp = entity.GetShaderTransform(pass);
frame_info.texture_sampler_y_coord_scale =
geometry_->GetAtlas()->GetYCoordScale();

VS::BindFrameInfo(pass, data_host_buffer.EmplaceUniform(frame_info));

Expand Down Expand Up @@ -224,8 +222,6 @@ bool AtlasContents::Render(const ContentContext& renderer,
VS::FrameInfo frame_info;

FS::BindTextureSamplerDst(pass, geometry_->GetAtlas(), dst_sampler);
Comment thread
bdero marked this conversation as resolved.
frame_info.texture_sampler_y_coord_scale =
geometry_->GetAtlas()->GetYCoordScale();

frag_info.input_alpha_output_alpha_tmx_tmy =
Vector4(1.0, alpha_, static_cast<int>(Entity::TileMode::kDecal),
Expand Down Expand Up @@ -265,8 +261,6 @@ bool AtlasContents::Render(const ContentContext& renderer,
VUS::FrameInfo frame_info;
FS::FragInfo frag_info;

frame_info.texture_sampler_y_coord_scale =
geometry_->GetAtlas()->GetYCoordScale();
frame_info.mvp = entity.GetShaderTransform(pass);

frag_info.alpha = alpha_;
Expand Down Expand Up @@ -338,8 +332,6 @@ bool ColorFilterAtlasContents::Render(const ContentContext& renderer,
VS::FrameInfo frame_info;

FS::BindInputTexture(pass, geometry_->GetAtlas(), dst_sampler);
Comment thread
bdero marked this conversation as resolved.
frame_info.texture_sampler_y_coord_scale =
geometry_->GetAtlas()->GetYCoordScale();

frag_info.input_alpha = 1;
frag_info.output_alpha = alpha_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ bool ConicalGradientContents::RenderTexture(const ContentContext& renderer,
frag_info.radius = radius_;
frag_info.tile_mode = static_cast<Scalar>(tile_mode_);
frag_info.decal_border_color = decal_border_color_;
frag_info.texture_sampler_y_coord_scale =
gradient_texture->GetYCoordScale();
frag_info.alpha =
GetOpacityFactor() *
GetGeometry()->ComputeAlphaCoverage(entity.GetTransform());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ static std::optional<Entity> AdvancedBlend(
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
dst_snapshot->sampler_descriptor);
FS::BindTextureSamplerDst(pass, dst_snapshot->texture, dst_sampler);
frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();
blend_info.dst_input_alpha =
absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes
? dst_snapshot->opacity
Expand All @@ -223,7 +222,6 @@ static std::optional<Entity> AdvancedBlend(
blend_info.color_factor = 0;
blend_info.src_input_alpha = src_snapshot->opacity;
FS::BindTextureSamplerSrc(pass, src_snapshot->texture, src_sampler);
frame_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
}
auto blend_uniform = data_host_buffer.EmplaceUniform(blend_info);
FS::BindBlendInfo(pass, blend_uniform);
Expand Down Expand Up @@ -370,7 +368,6 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
dst_snapshot->sampler_descriptor);
FS::BindTextureSamplerDst(pass, dst_snapshot->texture, dst_sampler);
frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();

frame_info.mvp = Entity::GetShaderTransform(
entity.GetShaderClipDepth(), pass,
Expand Down Expand Up @@ -472,8 +469,6 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
renderer.GetContext()->GetSamplerLibrary()->GetSampler(
dst_snapshot->sampler_descriptor);
FS::BindTextureSamplerDst(pass, dst_snapshot->texture, dst_sampler);
frame_info.texture_sampler_y_coord_scale =
dst_snapshot->texture->GetYCoordScale();

frag_info.input_alpha_output_alpha_tmx_tmy =
Vector4(absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes
Expand Down Expand Up @@ -573,8 +568,6 @@ static std::optional<Entity> PipelineBlend(
frame_info.mvp = pass.GetOrthographicTransform() *
Matrix::MakeTranslation(-subpass_coverage.GetOrigin()) *
input->transform;
frame_info.texture_sampler_y_coord_scale =
input->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.alpha =
Expand Down Expand Up @@ -704,8 +697,6 @@ std::optional<Entity> BlendFilterContents::CreateFramebufferAdvancedBlend(

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
frame_info.texture_sampler_y_coord_scale =
dst_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.alpha = 1.0;
Expand Down Expand Up @@ -838,7 +829,6 @@ std::optional<Entity> BlendFilterContents::CreateFramebufferAdvancedBlend(
FS::BindTextureSamplerSrc(pass, src_texture, src_sampler);

frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
frame_info.src_y_coord_scale = src_texture->GetYCoordScale();
VS::BindFrameInfo(pass, data_host_buffer.EmplaceUniform(frame_info));

frag_info.src_input_alpha = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ std::optional<Entity> BorderMaskBlurFilterContents::RenderFilter(

VS::FrameInfo frame_info;
frame_info.mvp = entity.GetShaderTransform(pass);
frame_info.texture_sampler_y_coord_scale =
input_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.sigma_uv = sigma.Abs() / input_snapshot->texture->GetSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ std::optional<Entity> ColorMatrixFilterContents::RenderFilter(
entity.GetShaderClipDepth(), pass,
entity.GetTransform() * input_snapshot->transform *
Matrix::MakeScale(Vector2(size)));
frame_info.texture_sampler_y_coord_scale =
input_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
const float* matrix = color_matrix.array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,38 +207,6 @@ Scalar FloorToDivisible(Scalar val, Scalar divisor) {
}
}

// If `y_coord_scale` < 0.0, the Y coordinate is flipped. This is useful
// for Impeller graphics backends that use a flipped framebuffer coordinate
// space.
//
// Both input and output quads are expected to be in the order of [Top-Left,
// Top-Right, Bottom-Left, Bottom-Right], a "Z-order" layout that conforms to
// the return format of Rect::GetPoints().
//
// See also: IPRemapCoords in convergions.glsl.
Quad RemapQuadCoords(const Quad& input, Scalar texture_sampler_y_coord_scale) {
if (texture_sampler_y_coord_scale < 0.0f) {
// The 4 points need reordering, because vertically flipping the quad:
//
// 0 → 1
// ↙
// 2 → 3
//
// should be flipped to:
//
// 2 → 3
// ↙
// 0 → 1
auto remap_point = [&](const Point& p) -> Point {
return Point(p.x, 1.0f - p.y);
};
return Quad{remap_point(input[2]), remap_point(input[3]),
remap_point(input[0]), remap_point(input[1])};
} else {
return input;
}
}

// Precomputes the line equation parameters for a quadrilateral's bounds.
//
// This function takes an array of 4 vertices and returns an array of 4
Expand Down Expand Up @@ -465,8 +433,6 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(

TextureFillVertexShader::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
frame_info.texture_sampler_y_coord_scale =
input_texture->GetYCoordScale();

TextureFillFragmentShader::FragInfo frag_info;
frag_info.alpha = 1.0;
Expand Down Expand Up @@ -522,9 +488,8 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
renderer.GetDownsampleBoundedPipeline(pipeline_options));

TextureDownsampleBoundedFragmentShader::BoundInfo bound_info;
bound_info.quad_line_params = PrecomputeQuadLineParameters(
RemapQuadCoords(pass_args.uv_bounds.value(),
input_texture->GetYCoordScale()));
bound_info.quad_line_params =
PrecomputeQuadLineParameters(pass_args.uv_bounds.value());
TextureDownsampleBoundedFragmentShader::BindBoundInfo(
pass, data_host_buffer.EmplaceUniform(bound_info));
} else {
Expand All @@ -547,8 +512,6 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(

TextureFillVertexShader::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
frame_info.texture_sampler_y_coord_scale =
input_texture->GetYCoordScale();

TextureDownsampleFragmentShader::FragInfo frag_info;
frag_info.edge = edge;
Expand Down Expand Up @@ -609,9 +572,7 @@ fml::StatusOr<RenderTarget> MakeBlurSubpass(
ContentContext::SubpassCallback subpass_callback =
[&](const ContentContext& renderer, RenderPass& pass) {
GaussianBlurVertexShader::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1)),
frame_info.texture_sampler_y_coord_scale =
input_texture->GetYCoordScale();
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));

HostBuffer& data_host_buffer = renderer.GetTransientsDataBuffer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ std::optional<Entity> LinearToSrgbFilterContents::RenderFilter(
entity.GetShaderClipDepth(), pass,
entity.GetTransform() * input_snapshot->transform *
Matrix::MakeScale(Vector2(size)));
frame_info.texture_sampler_y_coord_scale =
input_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.input_alpha =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ std::optional<Entity> DirectionalMorphologyFilterContents::RenderFilter(

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
frame_info.texture_sampler_y_coord_scale =
input_snapshot->texture->GetYCoordScale();

auto transform = entity.GetTransform() * effect_transform.Basis();
auto transformed_radius =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ std::optional<Entity> SrgbToLinearFilterContents::RenderFilter(
entity.GetShaderClipDepth(), pass,
entity.GetTransform() * input_snapshot->transform *
Matrix::MakeScale(Vector2(size)));
frame_info.texture_sampler_y_coord_scale =
input_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.input_alpha =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ std::optional<Entity> YUVToRGBFilterContents::RenderFilter(
entity.GetShaderClipDepth(), pass,
entity.GetTransform() * y_input_snapshot->transform *
Matrix::MakeScale(Vector2(size)));
frame_info.texture_sampler_y_coord_scale =
y_input_snapshot->texture->GetYCoordScale();

FS::FragInfo frag_info;
frag_info.yuv_color_space = static_cast<Scalar>(yuv_color_space);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer,

frame_info.mvp = Entity::GetShaderTransform(entity.GetShaderClipDepth(), pass,
src_snapshot->transform);
frame_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
VS::BindFrameInfo(pass, data_host_buffer.EmplaceUniform(frame_info));

frag_info.src_input_alpha = src_snapshot->opacity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ bool LinearGradientContents::RenderTexture(const ContentContext& renderer,
frag_info.end_point = end_point_;
frag_info.tile_mode = static_cast<Scalar>(tile_mode_);
frag_info.decal_border_color = decal_border_color_;
frag_info.texture_sampler_y_coord_scale =
gradient_texture->GetYCoordScale();
frag_info.alpha =
GetOpacityFactor() *
GetGeometry()->ComputeAlphaCoverage(entity.GetTransform());
Expand Down
Loading
Loading