Skip to content

Commit

Permalink
Scale broken canvas icon by device pixel ratio.
Browse files Browse the repository at this point in the history
After examining the results of Pixel_WebGLSadCanvas on multiple
devices, the icon's not clearly visible on high-DPI displays.

Bug: 1167246
Change-Id: Id472038378f93338014c9f9557704598cacddcd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3828151
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1034764}
  • Loading branch information
kenrussell authored and Chromium LUCI CQ committed Aug 13, 2022
1 parent f4199bf commit a56163b
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -818,8 +818,9 @@ void HTMLCanvasElement::Paint(GraphicsContext& context,
bool flatten_composited_layers) {
if (context_creation_was_blocked_ ||
(context_ && context_->isContextLost())) {
float dpr = GetDocument().DevicePixelRatio();
std::pair<Image*, float> broken_canvas_and_image_scale_factor =
BrokenCanvas(GetDocument().DevicePixelRatio());
BrokenCanvas(dpr);
Image* broken_canvas = broken_canvas_and_image_scale_factor.first;
context.Save();
context.FillRect(
Expand All @@ -834,6 +835,8 @@ void HTMLCanvasElement::Paint(GraphicsContext& context,
gfx::PointF upper_left =
gfx::PointF(r.PixelSnappedOffset()) +
gfx::Vector2dF(icon_size.width(), icon_size.height());
// Make the icon more visually prominent on high-DPI displays.
icon_size.Scale(dpr);
context.DrawImage(broken_canvas, Image::kSyncDecode,
ImageAutoDarkMode::Disabled(),
gfx::RectF(upper_left, icon_size));
Expand Down

0 comments on commit a56163b

Please sign in to comment.