OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/compositor/paint_context.h" | 5 #include "ui/compositor/paint_context.h" |
6 | 6 |
7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
11 PaintContext::PaintContext(cc::DisplayItemList* list, | 11 PaintContext::PaintContext(cc::DisplayItemList* list, |
12 float device_scale_factor, | 12 float device_scale_factor, |
13 const gfx::Rect& invalidation) | 13 const gfx::Rect& invalidation, |
| 14 bool is_pixel_canvas) |
14 : list_(list), | 15 : list_(list), |
15 device_scale_factor_(device_scale_factor), | 16 device_scale_factor_(device_scale_factor), |
16 invalidation_(invalidation) { | 17 invalidation_(gfx::ScaleToRoundedRect( |
| 18 invalidation, |
| 19 is_pixel_canvas ? device_scale_factor_ : 1.f)), |
| 20 is_pixel_canvas_(is_pixel_canvas) { |
17 #if DCHECK_IS_ON() | 21 #if DCHECK_IS_ON() |
18 root_visited_ = nullptr; | 22 root_visited_ = nullptr; |
19 inside_paint_recorder_ = false; | 23 inside_paint_recorder_ = false; |
20 #endif | 24 #endif |
21 } | 25 } |
22 | 26 |
23 PaintContext::PaintContext(const PaintContext& other, | 27 PaintContext::PaintContext(const PaintContext& other, |
24 const gfx::Vector2d& offset) | 28 const gfx::Vector2d& offset) |
25 : list_(other.list_), | 29 : list_(other.list_), |
26 device_scale_factor_(other.device_scale_factor_), | 30 device_scale_factor_(other.device_scale_factor_), |
27 invalidation_(other.invalidation_), | 31 invalidation_(other.invalidation_), |
28 offset_(other.offset_ + offset) { | 32 offset_(other.offset_ + offset), |
| 33 is_pixel_canvas_(other.is_pixel_canvas_) { |
29 #if DCHECK_IS_ON() | 34 #if DCHECK_IS_ON() |
30 root_visited_ = other.root_visited_; | 35 root_visited_ = other.root_visited_; |
31 inside_paint_recorder_ = other.inside_paint_recorder_; | 36 inside_paint_recorder_ = other.inside_paint_recorder_; |
32 #endif | 37 #endif |
33 } | 38 } |
34 | 39 |
35 PaintContext::PaintContext(const PaintContext& other, | 40 PaintContext::PaintContext(const PaintContext& other, |
36 CloneWithoutInvalidation c) | 41 CloneWithoutInvalidation c) |
37 : list_(other.list_), | 42 : list_(other.list_), |
38 device_scale_factor_(other.device_scale_factor_), | 43 device_scale_factor_(other.device_scale_factor_), |
39 invalidation_(), | 44 invalidation_(), |
40 offset_(other.offset_) { | 45 offset_(other.offset_), |
| 46 is_pixel_canvas_(other.is_pixel_canvas_) { |
41 #if DCHECK_IS_ON() | 47 #if DCHECK_IS_ON() |
42 root_visited_ = other.root_visited_; | 48 root_visited_ = other.root_visited_; |
43 inside_paint_recorder_ = other.inside_paint_recorder_; | 49 inside_paint_recorder_ = other.inside_paint_recorder_; |
44 #endif | 50 #endif |
45 } | 51 } |
46 | 52 |
47 PaintContext::~PaintContext() { | 53 PaintContext::~PaintContext() { |
48 } | 54 } |
49 | 55 |
50 gfx::Rect PaintContext::ToLayerSpaceBounds( | 56 gfx::Rect PaintContext::ToLayerSpaceBounds( |
51 const gfx::Size& size_in_context) const { | 57 const gfx::Size& size_in_context) const { |
52 return gfx::Rect(size_in_context) + offset_; | 58 return gfx::Rect(size_in_context) + offset_; |
53 } | 59 } |
54 | 60 |
55 gfx::Rect PaintContext::ToLayerSpaceRect(const gfx::Rect& rect) const { | 61 gfx::Rect PaintContext::ToLayerSpaceRect(const gfx::Rect& rect) const { |
56 return rect + offset_; | 62 return rect + offset_; |
57 } | 63 } |
58 | 64 |
59 } // namespace ui | 65 } // namespace ui |
OLD | NEW |