Commit 4b414bd7 authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

[RBS] Set the correct pixel size on RecordPaintCanvas for CanvasImageSource

When initializing a RecordPaintCanvas, the size set should be in pixels.
Right now we are setting the DIP size which is resulting in PaintOps
that are outside the clip bounds to be rejected all together.

This patch also adds a DCHECK to ensure that the clip bounds set on the
canvas matches the expected pixel size of the rasterized image.

Bug: 896203
Change-Id: I10cf95bc656950c217d3ae464f277a0cb7140063
Component: CanvasImageSource
Reviewed-on: https://chromium-review.googlesource.com/c/1296687
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602477}
parent 353d1a14
......@@ -9,6 +9,7 @@
#include "cc/paint/record_paint_canvas.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/switches.h"
......@@ -58,10 +59,17 @@ ImageSkiaRep CanvasImageSource::GetImageForScale(float scale) {
cc::DisplayItemList::kToBeReleasedAsPaintOpBuffer);
display_item_list->StartPaint();
SizeF size_in_pixel = ScaleSize(SizeF(size_), scale);
cc::RecordPaintCanvas record_canvas(
display_item_list.get(),
SkRect::MakeIWH(size_.width(), size_.height()));
SkRect::MakeWH(SkFloatToScalar(size_in_pixel.width()),
SkFloatToScalar(size_in_pixel.height())));
gfx::Canvas canvas(&record_canvas, scale);
#if DCHECK_IS_ON()
Rect clip_rect;
DCHECK(canvas.GetClipBounds(&clip_rect));
DCHECK(clip_rect.Contains(gfx::Rect(ToCeiledSize(size_in_pixel))));
#endif
canvas.Scale(scale, scale);
Draw(&canvas);
......
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