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/paint_context.h"
7 #include "third_party/skia/include/core/SkPictureRecorder.h"
8 #include "ui/gfx/canvas.h"
12 PaintContext::PaintContext(gfx::Canvas
* canvas
, const gfx::Rect
& invalidation
)
15 device_scale_factor_(canvas
->image_scale()),
16 bounds_(invalidation
),
17 invalidation_(invalidation
) {
19 root_visited_
= nullptr;
20 inside_paint_recorder_
= false;
24 PaintContext::PaintContext(cc::DisplayItemList
* list
,
25 float device_scale_factor
,
26 const gfx::Rect
& bounds
,
27 const gfx::Rect
& invalidation
)
30 recorder_(new SkPictureRecorder
),
31 device_scale_factor_(device_scale_factor
),
33 invalidation_(invalidation
) {
35 root_visited_
= nullptr;
36 inside_paint_recorder_
= false;
40 PaintContext::PaintContext(gfx::Canvas
* canvas
)
41 : PaintContext(canvas
, gfx::Rect()) {
44 PaintContext::PaintContext(const PaintContext
& other
)
45 : canvas_(other
.canvas_
),
47 // The SkPictureRecorder doesn't hold state, it is only held on the
48 // PaintContext as an optimization for fewer allocations. So we can just
49 // make a new one here.
50 recorder_(new SkPictureRecorder
),
51 device_scale_factor_(other
.device_scale_factor_
),
52 bounds_(other
.bounds_
),
53 invalidation_(other
.invalidation_
),
54 offset_(other
.offset_
) {
56 root_visited_
= other
.root_visited_
;
57 inside_paint_recorder_
= other
.inside_paint_recorder_
;
61 PaintContext::PaintContext(const PaintContext
& other
,
62 const gfx::Vector2d
& offset
)
63 : PaintContext(other
) {
67 PaintContext::~PaintContext() {