Skip to content

Commit

Permalink
Revert of Reland "Fix HTML5 video blurry" (patchset Pissandshittium#3
Browse files Browse the repository at this point in the history
…id:40001 of https://codereview.chromium.org/2547683003/ )

Reason for revert:
I suspect this breaks https://build.chromium.org/p/chromium.gpu.fyi/builders/Win7%20Release%20%28AMD%29/builds/565
Error compiling shader: ERROR: 0:7: '[]' : Index expression must be constant

Original issue's description:
> Reland "Fix HTML5 video blurry"
>
> Original CL: https://codereview.chromium.org/2418173002/
>
> Revert CL: https://codereview.chromium.org/2463103002/
> https://codereview.chromium.org/2474073004
>
> Changes: Skip failed gpu pixel tests until baseline is created.
> Fix following failures in Win7 dbg
> RendererPixelTest/2.PremultipliedTextureWithBackground
> GLRendererPixelTest.TextureQuadBatching
> RendererPixelTest/0.PremultipliedTextureWithBackground
> GLRendererPixelTest.NonPremultipliedTextureWithBackground
> IntersectingQuadGLPixelTest/0.Y16VideoQuads
> VideoGLRendererPixelTest.TwoColorY16Rect
> IntersectingQuadGLPixelTest/1.Y16VideoQuads
>
> TBR=dalecurtis@chromium.org,ccameron@chromium.org,dpranke@chromium.org,junov@chromium.org
> BUG=615325
> CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel
>
> Committed: https://crrev.com/60d375f8a6bd7b8c3e3abfd3771a228f3039bf62
> Cr-Commit-Position: refs/heads/master@{#436118}

TBR=ccameron@chromium.org,dalecurtis@chromium.org,dpranke@chromium.org,enne@chromium.org,junov@chromium.org,dongseong.hwang@chromium.org,dongseong.hwang@intel.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=615325

Review-Url: https://codereview.chromium.org/2544893006
Cr-Commit-Position: refs/heads/master@{#436176}
  • Loading branch information
y-novikov authored and Commit bot committed Dec 3, 2016
1 parent 1b019f5 commit 6c406fd
Show file tree
Hide file tree
Showing 27 changed files with 258 additions and 577 deletions.
19 changes: 12 additions & 7 deletions cc/layers/video_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,15 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,

// Pixels for macroblocked formats. To prevent sampling outside the visible
// rect, stretch the video if needed.
gfx::Rect visible_sample_rect = frame_->visible_rect();
if (visible_rect.width() < coded_size.width() && visible_rect.width() > 1)
visible_sample_rect.set_width(visible_rect.width() - 1);
if (visible_rect.height() < coded_size.height() && visible_rect.height() > 1)
visible_sample_rect.set_height(visible_rect.height() - 1);
const float tex_width_scale =
static_cast<float>(visible_rect.width()) / coded_size.width();
static_cast<float>(visible_sample_rect.width()) / coded_size.width();
const float tex_height_scale =
static_cast<float>(visible_rect.height()) / coded_size.height();
static_cast<float>(visible_sample_rect.height()) / coded_size.height();

switch (frame_resource_type_) {
// TODO(danakj): Remove this, hide it in the hardware path.
Expand Down Expand Up @@ -260,12 +265,12 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,
static_cast<float>(ya_tex_size.width()) / uv_tex_size.width();
float uv_subsampling_factor_y =
static_cast<float>(ya_tex_size.height()) / uv_tex_size.height();
gfx::RectF ya_tex_coord_rect(visible_rect);
gfx::RectF ya_tex_coord_rect(visible_sample_rect);
gfx::RectF uv_tex_coord_rect(
visible_rect.x() / uv_subsampling_factor_x,
visible_rect.y() / uv_subsampling_factor_y,
visible_rect.width() / uv_subsampling_factor_x,
visible_rect.height() / uv_subsampling_factor_y);
visible_sample_rect.x() / uv_subsampling_factor_x,
visible_sample_rect.y() / uv_subsampling_factor_y,
visible_sample_rect.width() / uv_subsampling_factor_x,
visible_sample_rect.height() / uv_subsampling_factor_y);

YUVVideoDrawQuad* yuv_video_quad =
render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
Expand Down
54 changes: 2 additions & 52 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,6 @@ Float4 UVTransform(const TextureDrawQuad* quad) {
return xform;
}

Float4 UVClampRect(gfx::RectF uv_clamp_rect,
const gfx::Size& texture_size,
SamplerType sampler) {
gfx::SizeF half_texel(0.5f, 0.5f);
if (sampler != SAMPLER_TYPE_2D_RECT) {
half_texel.Scale(1.f / texture_size.width(), 1.f / texture_size.height());
} else {
uv_clamp_rect.Scale(texture_size.width(), texture_size.height());
}
uv_clamp_rect.Inset(half_texel.width(), half_texel.height());
return {{uv_clamp_rect.x(), uv_clamp_rect.y(), uv_clamp_rect.right(),
uv_clamp_rect.bottom()}};
}

Float4 PremultipliedColor(SkColor color) {
const float factor = 1.0f / 255.0f;
const float alpha = SkColorGetA(color) * factor;
Expand Down Expand Up @@ -2497,15 +2483,8 @@ void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,

gl_->Uniform1i(program->fragment_shader().sampler_location(), 0);

gfx::Size texture_size = lock.size();
gfx::Vector2dF uv = quad->matrix.Scale2d();
gfx::RectF uv_clamp_rect(0, 0, uv.x(), uv.y());
const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target());
Float4 tex_clamp_rect = UVClampRect(uv_clamp_rect, texture_size, sampler);
gl_->Uniform4f(program->fragment_shader().tex_clamp_rect_location(),
tex_clamp_rect.data[0], tex_clamp_rect.data[1],
tex_clamp_rect.data[2], tex_clamp_rect.data[3]);

SetShaderOpacity(quad->shared_quad_state->opacity,
program->fragment_shader().alpha_location());
if (!clip_region) {
DrawQuadGeometry(frame->projection_matrix,
quad->shared_quad_state->quad_to_target_transform,
Expand Down Expand Up @@ -2548,12 +2527,9 @@ struct TexTransformTextureProgramBinding : TextureProgramBinding {
tex_transform_location = program->vertex_shader().tex_transform_location();
vertex_opacity_location =
program->vertex_shader().vertex_opacity_location();
tex_clamp_rect_location =
program->fragment_shader().tex_clamp_rect_location();
}
int tex_transform_location;
int vertex_opacity_location;
int tex_clamp_rect_location;
};

void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
Expand Down Expand Up @@ -2594,13 +2570,6 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
static_cast<int>(draw_cache_.uv_xform_data.size()),
reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front()));

if (draw_cache_.tex_clamp_rect_location != -1) {
gl_->Uniform4fv(
draw_cache_.tex_clamp_rect_location,
static_cast<int>(draw_cache_.tex_clamp_rect_data.size()),
reinterpret_cast<float*>(&draw_cache_.tex_clamp_rect_data.front()));
}

if (draw_cache_.background_color != SK_ColorTRANSPARENT) {
Float4 background_color = PremultipliedColor(draw_cache_.background_color);
gl_->Uniform4fv(draw_cache_.background_color_location, 1,
Expand Down Expand Up @@ -2644,7 +2613,6 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
// Clear the cache.
draw_cache_.program_id = -1;
draw_cache_.uv_xform_data.resize(0);
draw_cache_.tex_clamp_rect_data.resize(0);
draw_cache_.vertex_opacity_data.resize(0);
draw_cache_.matrix_data.resize(0);

Expand Down Expand Up @@ -2709,7 +2677,6 @@ void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
draw_cache_.background_color = quad->background_color;

draw_cache_.uv_xform_location = binding.tex_transform_location;
draw_cache_.tex_clamp_rect_location = binding.tex_clamp_rect_location;
draw_cache_.background_color_location = binding.background_color_location;
draw_cache_.vertex_opacity_location = binding.vertex_opacity_location;
draw_cache_.matrix_location = binding.matrix_location;
Expand All @@ -2730,23 +2697,6 @@ void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
}
draw_cache_.uv_xform_data.push_back(uv_transform);

if (draw_cache_.tex_clamp_rect_location != -1) {
// VideoLayerImpl always set background color to transparent.
DCHECK(quad->background_color == SK_ColorTRANSPARENT);
gfx::Size texture_size = lock.size();
if (texture_size.IsEmpty()) {
// TODO(dshwang): correct all code coming to here. crbug.com/615325
texture_size = quad->rect.size();
}
gfx::RectF uv_clamp_rect(quad->uv_top_left.x(), quad->uv_top_left.y(),
quad->uv_bottom_right.x() - quad->uv_top_left.x(),
quad->uv_bottom_right.y() - quad->uv_top_left.y());
Float4 tex_clamp_rect = UVClampRect(uv_clamp_rect, texture_size, sampler);
draw_cache_.tex_clamp_rect_data.push_back(tex_clamp_rect);
DCHECK_EQ(draw_cache_.uv_xform_data.size(),
draw_cache_.tex_clamp_rect_data.size());
}

// Generate the vertex opacity
const float opacity = quad->shared_quad_state->opacity;
draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
Expand Down
7 changes: 3 additions & 4 deletions cc/output/gl_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer {

// Texture shaders.
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexClampVaryingAlpha>
TextureProgram;
FragmentShaderRGBATexVaryingAlpha> TextureProgram;
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexClampPremultiplyAlpha>
FragmentShaderRGBATexPremultiplyAlpha>
NonPremultipliedTextureProgram;
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderTexBackgroundVaryingAlpha>
Expand Down Expand Up @@ -340,7 +339,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
RenderPassMaskColorMatrixProgram;

// Video shaders.
typedef ProgramBinding<VertexShaderVideoTransform, FragmentShaderRGBATexClamp>
typedef ProgramBinding<VertexShaderVideoTransform, FragmentShaderRGBATex>
VideoStreamTextureProgram;
typedef ProgramBinding<VertexShaderPosTexYUVStretchOffset,
FragmentShaderYUVVideo> VideoYUVProgram;
Expand Down
2 changes: 0 additions & 2 deletions cc/output/gl_renderer_draw_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ struct TexturedQuadDrawCache {

// Information about the program binding that is required to draw.
int uv_xform_location;
int tex_clamp_rect_location = -1;
int background_color_location;
int vertex_opacity_location;
int matrix_location;
int sampler_location;

// A cache for the coalesced quad data.
std::vector<Float4> uv_xform_data;
std::vector<Float4> tex_clamp_rect_data;
std::vector<float> vertex_opacity_data;
std::vector<Float16> matrix_data;

Expand Down
Loading

0 comments on commit 6c406fd

Please sign in to comment.