| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 | 848 |
| 849 needs_post_commit_initialization_ = false; | 849 needs_post_commit_initialization_ = false; |
| 850 } | 850 } |
| 851 | 851 |
| 852 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 852 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 853 DCHECK(CanHaveTilingWithScale(contents_scale)) << | 853 DCHECK(CanHaveTilingWithScale(contents_scale)) << |
| 854 "contents_scale: " << contents_scale; | 854 "contents_scale: " << contents_scale; |
| 855 | 855 |
| 856 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); | 856 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); |
| 857 | 857 |
| 858 DCHECK(pile_->HasRecordings()); | 858 const Region& recorded = pile_->recorded_region(); |
| 859 DCHECK(!recorded.IsEmpty()); |
| 859 | 860 |
| 860 if (twin_layer_ && twin_layer_->should_use_gpu_rasterization() == | 861 if (twin_layer_ && twin_layer_->should_use_gpu_rasterization() == |
| 861 should_use_gpu_rasterization()) | 862 should_use_gpu_rasterization()) |
| 862 twin_layer_->SyncTiling(tiling); | 863 twin_layer_->SyncTiling(tiling); |
| 863 | 864 |
| 864 return tiling; | 865 return tiling; |
| 865 } | 866 } |
| 866 | 867 |
| 867 void PictureLayerImpl::RemoveTiling(float contents_scale) { | 868 void PictureLayerImpl::RemoveTiling(float contents_scale) { |
| 868 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 869 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 low_res_raster_contents_scale_ = 0.f; | 1160 low_res_raster_contents_scale_ = 0.f; |
| 1160 | 1161 |
| 1161 // When raster scales aren't valid, don't update tile priorities until | 1162 // When raster scales aren't valid, don't update tile priorities until |
| 1162 // this layer has been updated via UpdateDrawProperties. | 1163 // this layer has been updated via UpdateDrawProperties. |
| 1163 should_update_tile_priorities_ = false; | 1164 should_update_tile_priorities_ = false; |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 bool PictureLayerImpl::CanHaveTilings() const { | 1167 bool PictureLayerImpl::CanHaveTilings() const { |
| 1167 if (!DrawsContent()) | 1168 if (!DrawsContent()) |
| 1168 return false; | 1169 return false; |
| 1169 if (!pile_->HasRecordings()) | 1170 if (pile_->recorded_region().IsEmpty()) |
| 1170 return false; | 1171 return false; |
| 1171 return true; | 1172 return true; |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1174 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1175 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
| 1175 if (!CanHaveTilings()) | 1176 if (!CanHaveTilings()) |
| 1176 return false; | 1177 return false; |
| 1177 if (contents_scale < MinimumContentsScale()) | 1178 if (contents_scale < MinimumContentsScale()) |
| 1178 return false; | 1179 return false; |
| 1179 return true; | 1180 return true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1204 | 1205 |
| 1205 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1206 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 1206 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1207 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1207 LayerImpl::AsValueInto(state); | 1208 LayerImpl::AsValueInto(state); |
| 1208 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1209 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 1209 state->SetDouble("geometry_contents_scale", contents_scale_x()); | 1210 state->SetDouble("geometry_contents_scale", contents_scale_x()); |
| 1210 state->Set("tilings", tilings_->AsValue().release()); | 1211 state->Set("tilings", tilings_->AsValue().release()); |
| 1211 state->Set("pictures", pile_->AsValue().release()); | 1212 state->Set("pictures", pile_->AsValue().release()); |
| 1212 state->Set("invalidation", invalidation_.AsValue().release()); | 1213 state->Set("invalidation", invalidation_.AsValue().release()); |
| 1213 | 1214 |
| 1215 Region unrecorded_region(gfx::Rect(pile_->size())); |
| 1216 unrecorded_region.Subtract(pile_->recorded_region()); |
| 1217 if (!unrecorded_region.IsEmpty()) |
| 1218 state->Set("unrecorded_region", unrecorded_region.AsValue().release()); |
| 1219 |
| 1214 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); | 1220 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); |
| 1215 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1221 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
| 1216 contents_scale_x(), | 1222 contents_scale_x(), |
| 1217 gfx::Rect(content_bounds()), | 1223 gfx::Rect(content_bounds()), |
| 1218 ideal_contents_scale_); | 1224 ideal_contents_scale_); |
| 1219 iter; | 1225 iter; |
| 1220 ++iter) { | 1226 ++iter) { |
| 1221 scoped_ptr<base::DictionaryValue> tile_data(new base::DictionaryValue); | 1227 scoped_ptr<base::DictionaryValue> tile_data(new base::DictionaryValue); |
| 1222 tile_data->Set("geometry_rect", | 1228 tile_data->Set("geometry_rect", |
| 1223 MathUtil::AsValue(iter.geometry_rect()).release()); | 1229 MathUtil::AsValue(iter.geometry_rect()).release()); |
| 1224 if (*iter) | 1230 if (*iter) |
| 1225 tile_data->Set("tile", TracedValue::CreateIDRef(*iter).release()); | 1231 tile_data->Set("tile", TracedValue::CreateIDRef(*iter).release()); |
| 1226 | 1232 |
| 1227 coverage_tiles->Append(tile_data.release()); | 1233 coverage_tiles->Append(tile_data.release()); |
| 1228 } | 1234 } |
| 1229 state->Set("coverage_tiles", coverage_tiles.release()); | 1235 state->Set("coverage_tiles", coverage_tiles.release()); |
| 1230 state->SetBoolean("is_using_lcd_text", is_using_lcd_text_); | 1236 state->SetBoolean("is_using_lcd_text", is_using_lcd_text_); |
| 1231 } | 1237 } |
| 1232 | 1238 |
| 1233 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 1239 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
| 1234 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1240 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1235 return tilings_->GPUMemoryUsageInBytes(); | 1241 return tilings_->GPUMemoryUsageInBytes(); |
| 1236 } | 1242 } |
| 1237 | 1243 |
| 1238 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1244 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
| 1239 benchmark->RunOnLayer(this); | 1245 benchmark->RunOnLayer(this); |
| 1240 } | 1246 } |
| 1241 | 1247 |
| 1242 } // namespace cc | 1248 } // namespace cc |
| OLD | NEW |