OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 // Mark priorities as dirty and schedule a ManageTiles(). | 1216 // Mark priorities as dirty and schedule a ManageTiles(). |
1217 tile_priorities_dirty_ = true; | 1217 tile_priorities_dirty_ = true; |
1218 client_->SetNeedsManageTilesOnImplThread(); | 1218 client_->SetNeedsManageTilesOnImplThread(); |
1219 } | 1219 } |
1220 | 1220 |
1221 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 1221 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
1222 if (client_ && !client_->IsInsideDraw()) | 1222 if (client_ && !client_->IsInsideDraw()) |
1223 client_->DidInitializeVisibleTileOnImplThread(); | 1223 client_->DidInitializeVisibleTileOnImplThread(); |
1224 } | 1224 } |
1225 | 1225 |
1226 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() { | 1226 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1227 const { | |
1227 return picture_layers_; | 1228 return picture_layers_; |
1228 } | 1229 } |
1229 | 1230 |
1230 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1231 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1231 client_->NotifyReadyToActivate(); | 1232 client_->NotifyReadyToActivate(); |
1232 } | 1233 } |
1233 | 1234 |
1234 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1235 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
1235 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1236 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
1236 | 1237 |
1237 if (active_tree_) { | 1238 if (active_tree_) { |
1238 LayerImpl* layer_impl = | 1239 LayerImpl* layer_impl = |
1239 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1240 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
1240 if (layer_impl) | 1241 if (layer_impl) |
1241 layer_impl->NotifyTileStateChanged(tile); | 1242 layer_impl->NotifyTileStateChanged(tile); |
1242 } | 1243 } |
1243 | 1244 |
1244 if (pending_tree_) { | 1245 if (pending_tree_) { |
1245 LayerImpl* layer_impl = | 1246 LayerImpl* layer_impl = |
1246 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); | 1247 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); |
1247 if (layer_impl) | 1248 if (layer_impl) |
1248 layer_impl->NotifyTileStateChanged(tile); | 1249 layer_impl->NotifyTileStateChanged(tile); |
1249 } | 1250 } |
1250 } | 1251 } |
1251 | 1252 |
1253 RasterTileQueue* LayerTreeHostImpl::GetRasterQueue(TreePriority tree_priority) { | |
1254 // TODO(vmpstr): Investigate if we can skip preparation if nothing changed | |
1255 // (priorities, etc) | |
1256 std::vector<PairedPictureLayer> paired_layers; | |
1257 GetPairedPictureLayers(&paired_layers); | |
1258 raster_queue_.Prepare(paired_layers, tree_priority); | |
reveman
2014/07/09 02:21:09
I don't think we should use a client function to t
vmpstr
2014/07/09 18:35:38
Calling prepare in tile manager seems like a wrong
| |
1259 return &raster_queue_; | |
1260 } | |
1261 | |
1262 EvictionTileQueue* LayerTreeHostImpl::GetEvictionQueue( | |
1263 TreePriority tree_priority) { | |
1264 // TODO(vmpstr): Investigate if we can skip preparation if nothing changed | |
1265 // (priorities, etc) | |
1266 std::vector<PairedPictureLayer> paired_layers; | |
1267 GetPairedPictureLayers(&paired_layers); | |
1268 eviction_queue_.Prepare(paired_layers, tree_priority); | |
1269 return &eviction_queue_; | |
1270 } | |
1271 | |
1252 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1272 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
1253 SetManagedMemoryPolicy(policy, zero_budget_); | 1273 SetManagedMemoryPolicy(policy, zero_budget_); |
1254 } | 1274 } |
1255 | 1275 |
1256 void LayerTreeHostImpl::SetTreeActivationCallback( | 1276 void LayerTreeHostImpl::SetTreeActivationCallback( |
1257 const base::Closure& callback) { | 1277 const base::Closure& callback) { |
1258 DCHECK(proxy_->IsImplThread()); | 1278 DCHECK(proxy_->IsImplThread()); |
1259 DCHECK(settings_.impl_side_painting || callback.is_null()); | 1279 DCHECK(settings_.impl_side_painting || callback.is_null()); |
1260 tree_activation_callback_ = callback; | 1280 tree_activation_callback_ = callback; |
1261 } | 1281 } |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1967 bool LayerTreeHostImpl::UseOneCopyTextureUpload() const { | 1987 bool LayerTreeHostImpl::UseOneCopyTextureUpload() const { |
1968 // Sync query support is required by one-copy rasterizer. | 1988 // Sync query support is required by one-copy rasterizer. |
1969 return settings_.use_one_copy && GetRendererCapabilities().using_map_image && | 1989 return settings_.use_one_copy && GetRendererCapabilities().using_map_image && |
1970 resource_provider_->use_sync_query(); | 1990 resource_provider_->use_sync_query(); |
1971 } | 1991 } |
1972 | 1992 |
1973 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { | 1993 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { |
1974 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); | 1994 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); |
1975 } | 1995 } |
1976 | 1996 |
1997 void LayerTreeHostImpl::GetPairedPictureLayers( | |
1998 std::vector<PairedPictureLayer>* paired_layers) const { | |
1999 const std::vector<PictureLayerImpl*>& layers = GetPictureLayers(); | |
2000 | |
2001 paired_layers->clear(); | |
2002 // Reserve a maximum possible paired layers. | |
2003 paired_layers->reserve(layers.size()); | |
2004 | |
2005 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); | |
2006 it != layers.end(); | |
2007 ++it) { | |
2008 PictureLayerImpl* layer = *it; | |
2009 | |
2010 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | |
2011 if (!layer->HasValidTilePriorities()) | |
2012 continue; | |
2013 | |
2014 PictureLayerImpl* twin_layer = layer->GetTwinLayer(); | |
2015 | |
2016 // Ignore the twin layer when tile priorities are invalid. | |
2017 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 | |
2018 if (twin_layer && !twin_layer->HasValidTilePriorities()) | |
2019 twin_layer = NULL; | |
2020 | |
2021 PairedPictureLayer paired_layer; | |
2022 WhichTree tree = layer->GetTree(); | |
2023 | |
2024 // If the current tree is ACTIVE_TREE, then always generate a paired_layer. | |
2025 // If current tree is PENDING_TREE, then only generate a paired_layer if | |
2026 // there is no twin layer. | |
2027 if (tree == ACTIVE_TREE) { | |
2028 DCHECK(!twin_layer || twin_layer->GetTree() == PENDING_TREE); | |
2029 paired_layer.active_layer = layer; | |
2030 paired_layer.pending_layer = twin_layer; | |
2031 paired_layers->push_back(paired_layer); | |
2032 } else if (!twin_layer) { | |
2033 paired_layer.active_layer = NULL; | |
2034 paired_layer.pending_layer = layer; | |
2035 paired_layers->push_back(paired_layer); | |
2036 } | |
2037 } | |
2038 } | |
2039 | |
1977 bool LayerTreeHostImpl::InitializeRenderer( | 2040 bool LayerTreeHostImpl::InitializeRenderer( |
1978 scoped_ptr<OutputSurface> output_surface) { | 2041 scoped_ptr<OutputSurface> output_surface) { |
1979 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2042 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
1980 #if DCHECK_IS_ON | 2043 #if DCHECK_IS_ON |
1981 DCHECK(!renderer_ || did_lose_called_); | 2044 DCHECK(!renderer_ || did_lose_called_); |
1982 #endif | 2045 #endif |
1983 | 2046 |
1984 // Since we will create a new resource provider, we cannot continue to use | 2047 // Since we will create a new resource provider, we cannot continue to use |
1985 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2048 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
1986 // before we destroy the old resource provider. | 2049 // before we destroy the old resource provider. |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3152 } | 3215 } |
3153 | 3216 |
3154 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3217 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3155 std::vector<PictureLayerImpl*>::iterator it = | 3218 std::vector<PictureLayerImpl*>::iterator it = |
3156 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3219 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3157 DCHECK(it != picture_layers_.end()); | 3220 DCHECK(it != picture_layers_.end()); |
3158 picture_layers_.erase(it); | 3221 picture_layers_.erase(it); |
3159 } | 3222 } |
3160 | 3223 |
3161 } // namespace cc | 3224 } // namespace cc |
OLD | NEW |