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/resources/picture_pile_base.h" | 5 #include "cc/resources/picture_pile_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 PicturePileBase::PicturePileBase() | 41 PicturePileBase::PicturePileBase() |
42 : min_contents_scale_(0), | 42 : min_contents_scale_(0), |
43 background_color_(SkColorSetARGBInline(0, 0, 0, 0)), | 43 background_color_(SkColorSetARGBInline(0, 0, 0, 0)), |
44 slow_down_raster_scale_factor_for_debug_(0), | 44 slow_down_raster_scale_factor_for_debug_(0), |
45 contents_opaque_(false), | 45 contents_opaque_(false), |
46 contents_fill_bounds_completely_(false), | 46 contents_fill_bounds_completely_(false), |
47 show_debug_picture_borders_(false), | 47 show_debug_picture_borders_(false), |
48 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 48 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
49 has_any_recordings_(false), | 49 has_any_recordings_(false), |
50 has_text_(false), | |
51 is_mask_(false), | 50 is_mask_(false), |
52 is_solid_color_(false), | 51 is_solid_color_(false), |
53 solid_color_(SK_ColorTRANSPARENT) { | 52 solid_color_(SK_ColorTRANSPARENT) { |
54 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); | 53 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); |
55 tile_grid_info_.fTileInterval.setEmpty(); | 54 tile_grid_info_.fTileInterval.setEmpty(); |
56 tile_grid_info_.fMargin.setEmpty(); | 55 tile_grid_info_.fMargin.setEmpty(); |
57 tile_grid_info_.fOffset.setZero(); | 56 tile_grid_info_.fOffset.setZero(); |
58 } | 57 } |
59 | 58 |
60 PicturePileBase::PicturePileBase(const PicturePileBase* other) | 59 PicturePileBase::PicturePileBase(const PicturePileBase* other) |
61 : picture_map_(other->picture_map_), | 60 : picture_map_(other->picture_map_), |
62 tiling_(other->tiling_), | 61 tiling_(other->tiling_), |
63 recorded_viewport_(other->recorded_viewport_), | 62 recorded_viewport_(other->recorded_viewport_), |
64 min_contents_scale_(other->min_contents_scale_), | 63 min_contents_scale_(other->min_contents_scale_), |
65 tile_grid_info_(other->tile_grid_info_), | 64 tile_grid_info_(other->tile_grid_info_), |
66 background_color_(other->background_color_), | 65 background_color_(other->background_color_), |
67 slow_down_raster_scale_factor_for_debug_( | 66 slow_down_raster_scale_factor_for_debug_( |
68 other->slow_down_raster_scale_factor_for_debug_), | 67 other->slow_down_raster_scale_factor_for_debug_), |
69 contents_opaque_(other->contents_opaque_), | 68 contents_opaque_(other->contents_opaque_), |
70 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_), | 69 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_), |
71 show_debug_picture_borders_(other->show_debug_picture_borders_), | 70 show_debug_picture_borders_(other->show_debug_picture_borders_), |
72 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 71 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
73 has_any_recordings_(other->has_any_recordings_), | 72 has_any_recordings_(other->has_any_recordings_), |
74 has_text_(other->has_text_), | |
75 is_mask_(other->is_mask_), | 73 is_mask_(other->is_mask_), |
76 is_solid_color_(other->is_solid_color_), | 74 is_solid_color_(other->is_solid_color_), |
77 solid_color_(other->solid_color_) { | 75 solid_color_(other->solid_color_) { |
78 } | 76 } |
79 | 77 |
80 PicturePileBase::~PicturePileBase() { | 78 PicturePileBase::~PicturePileBase() { |
81 } | 79 } |
82 | 80 |
83 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { | 81 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { |
84 DCHECK(min_contents_scale); | 82 DCHECK(min_contents_scale); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 133 } |
136 | 134 |
137 bool PicturePileBase::HasRecordingAt(int x, int y) { | 135 bool PicturePileBase::HasRecordingAt(int x, int y) { |
138 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); | 136 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); |
139 if (found == picture_map_.end()) | 137 if (found == picture_map_.end()) |
140 return false; | 138 return false; |
141 return !!found->second.GetPicture(); | 139 return !!found->second.GetPicture(); |
142 } | 140 } |
143 | 141 |
144 bool PicturePileBase::CanRaster(float contents_scale, | 142 bool PicturePileBase::CanRaster(float contents_scale, |
145 const gfx::Rect& content_rect) { | 143 const gfx::Rect& content_rect) const { |
146 if (tiling_.tiling_size().IsEmpty()) | 144 if (tiling_.tiling_size().IsEmpty()) |
147 return false; | 145 return false; |
148 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 146 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
149 content_rect, 1.f / contents_scale); | 147 content_rect, 1.f / contents_scale); |
150 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); | 148 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); |
151 | 149 |
152 // Common case inside of viewport to avoid the slower map lookups. | 150 // Common case inside of viewport to avoid the slower map lookups. |
153 if (recorded_viewport_.Contains(layer_rect)) { | 151 if (recorded_viewport_.Contains(layer_rect)) { |
154 // Sanity check that there are no false positives in recorded_viewport_. | 152 // Sanity check that there are no false positives in recorded_viewport_. |
155 DCHECK(CanRasterSlowTileCheck(layer_rect)); | 153 DCHECK(CanRasterSlowTileCheck(layer_rect)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 const Picture* PicturePileBase::PictureInfo::GetPicture() const { | 246 const Picture* PicturePileBase::PictureInfo::GetPicture() const { |
249 return picture_.get(); | 247 return picture_.get(); |
250 } | 248 } |
251 | 249 |
252 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 250 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
253 return invalidation_history_.count() / | 251 return invalidation_history_.count() / |
254 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 252 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
255 } | 253 } |
256 | 254 |
257 } // namespace cc | 255 } // namespace cc |
OLD | NEW |