1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/compositor/canvas_painter.h"
7 #include "cc/playback/display_item_list.h"
8 #include "cc/playback/display_item_list_settings.h"
9 #include "ui/gfx/canvas.h"
13 CanvasPainter::CanvasPainter(gfx::Canvas
* canvas
, float raster_scale_factor
)
15 raster_scale_factor_(raster_scale_factor
),
16 rect_(gfx::ScaleToEnclosedRect(
17 gfx::Rect(canvas_
->sk_canvas()->getBaseLayerSize().width(),
18 canvas_
->sk_canvas()->getBaseLayerSize().height()),
19 1.f
/ raster_scale_factor
)),
20 list_(cc::DisplayItemList::Create(rect_
, cc::DisplayItemListSettings())),
21 context_(list_
.get(), raster_scale_factor_
, rect_
) {
24 CanvasPainter::~CanvasPainter() {
26 list_
->Raster(canvas_
->sk_canvas(), nullptr, rect_
, raster_scale_factor_
);