OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/picture_pile_base.h" | 5 #include "cc/picture_pile_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/skia/include/core/SkColor.h" |
8 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
9 | 10 |
10 namespace { | 11 namespace { |
11 // Dimensions of the tiles in this picture pile as well as the dimensions of | 12 // Dimensions of the tiles in this picture pile as well as the dimensions of |
12 // the base picture in each tile. | 13 // the base picture in each tile. |
13 const int kBasePictureSize = 3000; | 14 const int kBasePictureSize = 3000; |
14 const int kTileGridBorderPixels = 1; | 15 const int kTileGridBorderPixels = 1; |
15 } | 16 } |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 PicturePileBase::PicturePileBase() | 20 PicturePileBase::PicturePileBase() |
20 : min_contents_scale_(0) { | 21 : min_contents_scale_(0) |
| 22 , background_color_(SkColorSetARGBInline(0, 0, 0, 0)) { |
21 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); | 23 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); |
22 tile_grid_info_.fTileInterval.setEmpty(); | 24 tile_grid_info_.fTileInterval.setEmpty(); |
23 tile_grid_info_.fMargin.setEmpty(); | 25 tile_grid_info_.fMargin.setEmpty(); |
24 tile_grid_info_.fOffset.setZero(); | 26 tile_grid_info_.fOffset.setZero(); |
25 } | 27 } |
26 | 28 |
27 PicturePileBase::~PicturePileBase() { | 29 PicturePileBase::~PicturePileBase() { |
28 } | 30 } |
29 | 31 |
30 void PicturePileBase::Resize(gfx::Size new_size) { | 32 void PicturePileBase::Resize(gfx::Size new_size) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void PicturePileBase::Clear() { | 100 void PicturePileBase::Clear() { |
99 picture_list_map_.clear(); | 101 picture_list_map_.clear(); |
100 } | 102 } |
101 | 103 |
102 void PicturePileBase::PushPropertiesTo(PicturePileBase* other) { | 104 void PicturePileBase::PushPropertiesTo(PicturePileBase* other) { |
103 other->picture_list_map_ = picture_list_map_; | 105 other->picture_list_map_ = picture_list_map_; |
104 other->tiling_ = tiling_; | 106 other->tiling_ = tiling_; |
105 other->recorded_region_ = recorded_region_; | 107 other->recorded_region_ = recorded_region_; |
106 other->min_contents_scale_ = min_contents_scale_; | 108 other->min_contents_scale_ = min_contents_scale_; |
107 other->tile_grid_info_ = tile_grid_info_; | 109 other->tile_grid_info_ = tile_grid_info_; |
| 110 other->background_color_ = background_color_; |
108 } | 111 } |
109 | 112 |
110 void PicturePileBase::UpdateRecordedRegion() { | 113 void PicturePileBase::UpdateRecordedRegion() { |
111 recorded_region_.Clear(); | 114 recorded_region_.Clear(); |
112 for (int x = 0; x < num_tiles_x(); ++x) { | 115 for (int x = 0; x < num_tiles_x(); ++x) { |
113 for (int y = 0; y < num_tiles_y(); ++y) { | 116 for (int y = 0; y < num_tiles_y(); ++y) { |
114 if (!HasRecordingAt(x, y)) | 117 if (!HasRecordingAt(x, y)) |
115 continue; | 118 continue; |
116 recorded_region_.Union(tile_bounds(x, y)); | 119 recorded_region_.Union(tile_bounds(x, y)); |
117 } | 120 } |
(...skipping 12 matching lines...) Expand all Loading... |
130 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { | 133 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { |
131 if (tiling_.total_size().IsEmpty()) | 134 if (tiling_.total_size().IsEmpty()) |
132 return false; | 135 return false; |
133 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 136 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
134 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 137 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
135 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | 138 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
136 return recorded_region_.Contains(layer_rect); | 139 return recorded_region_.Contains(layer_rect); |
137 } | 140 } |
138 | 141 |
139 } // namespace cc | 142 } // namespace cc |
OLD | NEW |