forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas_painter.cc
29 lines (23 loc) · 1012 Bytes
/
canvas_painter.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/compositor/canvas_painter.h"
#include "cc/playback/display_item_list.h"
#include "cc/playback/display_item_list_settings.h"
#include "ui/gfx/canvas.h"
namespace ui {
CanvasPainter::CanvasPainter(gfx::Canvas* canvas, float raster_scale_factor)
: canvas_(canvas),
raster_scale_factor_(raster_scale_factor),
rect_(gfx::ScaleToEnclosedRect(
gfx::Rect(canvas_->sk_canvas()->getBaseLayerSize().width(),
canvas_->sk_canvas()->getBaseLayerSize().height()),
1.f / raster_scale_factor)),
list_(cc::DisplayItemList::Create(rect_, cc::DisplayItemListSettings())),
context_(list_.get(), raster_scale_factor_, rect_) {
}
CanvasPainter::~CanvasPainter() {
list_->Finalize();
list_->Raster(canvas_->sk_canvas(), nullptr, rect_, raster_scale_factor_);
}
} // namespace ui