Commit 5311279b authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Fix pixelated canvas

Update canvas filter quality when recording the foreign layer.

Change-Id: I7a5ae65eb45664718be6bf56ff80c6057b1bca28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2141611
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757547}
parent 0fa60cdc
...@@ -694,6 +694,16 @@ bool HTMLCanvasElement::LowLatencyEnabled() const { ...@@ -694,6 +694,16 @@ bool HTMLCanvasElement::LowLatencyEnabled() const {
return !!frame_dispatcher_; return !!frame_dispatcher_;
} }
void HTMLCanvasElement::UpdateFilterQuality() {
if (IsOffscreenCanvasRegistered())
UpdateOffscreenCanvasFilterQuality(FilterQuality());
if (context_ && Is3d())
context_->SetFilterQuality(FilterQuality());
else if (canvas2d_bridge_)
canvas2d_bridge_->UpdateFilterQuality();
}
// In some instances we don't actually want to paint to the parent layer // In some instances we don't actually want to paint to the parent layer
// We still might want to set filter quality and MarkFirstContentfulPaint though // We still might want to set filter quality and MarkFirstContentfulPaint though
void HTMLCanvasElement::Paint(GraphicsContext& context, void HTMLCanvasElement::Paint(GraphicsContext& context,
...@@ -724,11 +734,6 @@ void HTMLCanvasElement::Paint(GraphicsContext& context, ...@@ -724,11 +734,6 @@ void HTMLCanvasElement::Paint(GraphicsContext& context,
if (!context_ && !OffscreenCanvasFrame()) if (!context_ && !OffscreenCanvasFrame())
return; return;
if (Is3d())
context_->SetFilterQuality(FilterQuality());
else if (canvas2d_bridge_)
canvas2d_bridge_->UpdateFilterQuality();
if (HasResourceProvider() && !canvas_is_clear_) if (HasResourceProvider() && !canvas_is_clear_)
PaintTiming::From(GetDocument()).MarkFirstContentfulPaint(); PaintTiming::From(GetDocument()).MarkFirstContentfulPaint();
......
...@@ -154,6 +154,7 @@ class CORE_EXPORT HTMLCanvasElement final ...@@ -154,6 +154,7 @@ class CORE_EXPORT HTMLCanvasElement final
void DidDraw(const FloatRect&) override; void DidDraw(const FloatRect&) override;
void DidDraw() override; void DidDraw() override;
void UpdateFilterQuality();
void Paint(GraphicsContext&, void Paint(GraphicsContext&,
const PhysicalRect&, const PhysicalRect&,
bool flatten_composited_layers); bool flatten_composited_layers);
......
...@@ -37,8 +37,7 @@ void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info, ...@@ -37,8 +37,7 @@ void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info,
paint_rect.Move(paint_offset); paint_rect.Move(paint_offset);
auto* canvas = To<HTMLCanvasElement>(layout_html_canvas_.GetNode()); auto* canvas = To<HTMLCanvasElement>(layout_html_canvas_.GetNode());
if (canvas->IsOffscreenCanvasRegistered()) canvas->UpdateFilterQuality();
canvas->UpdateOffscreenCanvasFilterQuality(canvas->FilterQuality());
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
if (auto* layer = canvas->ContentsCcLayer()) { if (auto* layer = canvas->ContentsCcLayer()) {
......
...@@ -9,7 +9,6 @@ http/tests/devtools/tracing/* [ Skip ] ...@@ -9,7 +9,6 @@ http/tests/devtools/tracing/* [ Skip ]
virtual/composite-after-paint/* [ Skip ] virtual/composite-after-paint/* [ Skip ]
virtual/gpu/fast/canvas/* [ Skip ]
virtual/layout_ng_block_frag/* [ Skip ] virtual/layout_ng_block_frag/* [ Skip ]
virtual/layout_ng_fieldset/* [ Skip ] virtual/layout_ng_fieldset/* [ Skip ]
virtual/layout_ng_flex_box/* [ Skip ] virtual/layout_ng_flex_box/* [ Skip ]
...@@ -56,9 +55,6 @@ compositing/reflections/deeply-nested-reflections.html [ Failure ] ...@@ -56,9 +55,6 @@ compositing/reflections/deeply-nested-reflections.html [ Failure ]
# A fieldset paints its background twice. # A fieldset paints its background twice.
external/wpt/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow.html [ Crash ] external/wpt/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow.html [ Crash ]
#image-rendering: pixelated doesn't work on canvas.
fast/webgl/pixelated.html [ Failure ]
compositing/masks/broken-mask.html [ Failure ] compositing/masks/broken-mask.html [ Failure ]
compositing/masks/mask-with-removed-filters.html [ Failure ] compositing/masks/mask-with-removed-filters.html [ Failure ]
external/wpt/css/css-transforms/transform3d-backface-visibility-006.html [ Failure ] external/wpt/css/css-transforms/transform3d-backface-visibility-006.html [ Failure ]
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<html> <html>
<head> <head>
<title>Test ClearRect works properly if called during the first frame.</title> <title>Test ClearRect works properly if called during the first frame.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<canvas id="c" width=100 height=100></canvas> <canvas id="c" width=100 height=100></canvas>
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<html> <html>
<head> <head>
<title>Test ClearRect works properly if it doesn't clear the full canvas.</title> <title>Test ClearRect works properly if it doesn't clear the full canvas.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<canvas id="c" width=100 height=100></canvas> <canvas id="c" width=100 height=100></canvas>
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<html> <html>
<head> <head>
<title>Test if the users can change Image Rendering Quality in Offscreen Canvas</title> <title>Test if the users can change Image Rendering Quality in Offscreen Canvas</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style type="text/css"> <style type="text/css">
#can { #can {
width: 500px; width: 500px;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<html> <html>
<head> <head>
<title>Test if the users can change Image Rendering Quality in Offscreen Canvas</title> <title>Test if the users can change Image Rendering Quality in Offscreen Canvas</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style type="text/css"> <style type="text/css">
#can { #can {
width: 500px; width: 500px;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment