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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 857 |
858 needs_post_commit_initialization_ = false; | 858 needs_post_commit_initialization_ = false; |
859 } | 859 } |
860 | 860 |
861 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 861 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
862 DCHECK(CanHaveTilingWithScale(contents_scale)) << | 862 DCHECK(CanHaveTilingWithScale(contents_scale)) << |
863 "contents_scale: " << contents_scale; | 863 "contents_scale: " << contents_scale; |
864 | 864 |
865 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); | 865 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); |
866 | 866 |
867 const Region& recorded = pile_->recorded_region(); | 867 DCHECK(pile_->HasRecordings()); |
868 DCHECK(!recorded.IsEmpty()); | |
869 | 868 |
870 if (twin_layer_ && | 869 if (twin_layer_ && |
871 twin_layer_->ShouldUseGpuRasterization() == ShouldUseGpuRasterization()) | 870 twin_layer_->ShouldUseGpuRasterization() == ShouldUseGpuRasterization()) |
872 twin_layer_->SyncTiling(tiling); | 871 twin_layer_->SyncTiling(tiling); |
873 | 872 |
874 return tiling; | 873 return tiling; |
875 } | 874 } |
876 | 875 |
877 void PictureLayerImpl::RemoveTiling(float contents_scale) { | 876 void PictureLayerImpl::RemoveTiling(float contents_scale) { |
878 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 877 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 low_res_raster_contents_scale_ = 0.f; | 1169 low_res_raster_contents_scale_ = 0.f; |
1171 | 1170 |
1172 // When raster scales aren't valid, don't update tile priorities until | 1171 // When raster scales aren't valid, don't update tile priorities until |
1173 // this layer has been updated via UpdateDrawProperties. | 1172 // this layer has been updated via UpdateDrawProperties. |
1174 should_update_tile_priorities_ = false; | 1173 should_update_tile_priorities_ = false; |
1175 } | 1174 } |
1176 | 1175 |
1177 bool PictureLayerImpl::CanHaveTilings() const { | 1176 bool PictureLayerImpl::CanHaveTilings() const { |
1178 if (!DrawsContent()) | 1177 if (!DrawsContent()) |
1179 return false; | 1178 return false; |
1180 if (pile_->recorded_region().IsEmpty()) | 1179 if (!pile_->HasRecordings()) |
1181 return false; | 1180 return false; |
1182 return true; | 1181 return true; |
1183 } | 1182 } |
1184 | 1183 |
1185 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1184 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
1186 if (!CanHaveTilings()) | 1185 if (!CanHaveTilings()) |
1187 return false; | 1186 return false; |
1188 if (contents_scale < MinimumContentsScale()) | 1187 if (contents_scale < MinimumContentsScale()) |
1189 return false; | 1188 return false; |
1190 return true; | 1189 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
1214 | 1213 |
1215 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1214 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
1216 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1215 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
1217 LayerImpl::AsValueInto(state); | 1216 LayerImpl::AsValueInto(state); |
1218 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1217 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
1219 state->SetDouble("geometry_contents_scale", contents_scale_x()); | 1218 state->SetDouble("geometry_contents_scale", contents_scale_x()); |
1220 state->Set("tilings", tilings_->AsValue().release()); | 1219 state->Set("tilings", tilings_->AsValue().release()); |
1221 state->Set("pictures", pile_->AsValue().release()); | 1220 state->Set("pictures", pile_->AsValue().release()); |
1222 state->Set("invalidation", invalidation_.AsValue().release()); | 1221 state->Set("invalidation", invalidation_.AsValue().release()); |
1223 | 1222 |
1224 Region unrecorded_region(gfx::Rect(pile_->size())); | |
1225 unrecorded_region.Subtract(pile_->recorded_region()); | |
1226 if (!unrecorded_region.IsEmpty()) | |
1227 state->Set("unrecorded_region", unrecorded_region.AsValue().release()); | |
1228 | |
1229 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); | 1223 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); |
1230 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1224 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
1231 contents_scale_x(), | 1225 contents_scale_x(), |
1232 gfx::Rect(content_bounds()), | 1226 gfx::Rect(content_bounds()), |
1233 ideal_contents_scale_); | 1227 ideal_contents_scale_); |
1234 iter; | 1228 iter; |
1235 ++iter) { | 1229 ++iter) { |
1236 scoped_ptr<base::DictionaryValue> tile_data(new base::DictionaryValue); | 1230 scoped_ptr<base::DictionaryValue> tile_data(new base::DictionaryValue); |
1237 tile_data->Set("geometry_rect", | 1231 tile_data->Set("geometry_rect", |
1238 MathUtil::AsValue(iter.geometry_rect()).release()); | 1232 MathUtil::AsValue(iter.geometry_rect()).release()); |
(...skipping 10 matching lines...) Expand all Loading... |
1249 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 1243 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
1250 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1244 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
1251 return tilings_->GPUMemoryUsageInBytes(); | 1245 return tilings_->GPUMemoryUsageInBytes(); |
1252 } | 1246 } |
1253 | 1247 |
1254 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1248 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1255 benchmark->RunOnLayer(this); | 1249 benchmark->RunOnLayer(this); |
1256 } | 1250 } |
1257 | 1251 |
1258 } // namespace cc | 1252 } // namespace cc |
OLD | NEW |