| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 if (root_layer_.get()) | 177 if (root_layer_.get()) |
| 178 root_layer_->SetLayerTreeHost(NULL); | 178 root_layer_->SetLayerTreeHost(NULL); |
| 179 | 179 |
| 180 if (proxy_) { | 180 if (proxy_) { |
| 181 DCHECK(proxy_->IsMainThread()); | 181 DCHECK(proxy_->IsMainThread()); |
| 182 proxy_->Stop(); | 182 proxy_->Stop(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 s_num_layer_tree_instances--; | 185 s_num_layer_tree_instances--; |
| 186 RateLimiterMap::iterator it = rate_limiters_.begin(); | |
| 187 if (it != rate_limiters_.end()) | |
| 188 it->second->Stop(); | |
| 189 | 186 |
| 190 if (root_layer_.get()) { | 187 if (root_layer_.get()) { |
| 191 // The layer tree must be destroyed before the layer tree host. We've | 188 // The layer tree must be destroyed before the layer tree host. We've |
| 192 // made a contract with our animation controllers that the registrar | 189 // made a contract with our animation controllers that the registrar |
| 193 // will outlive them, and we must make good. | 190 // will outlive them, and we must make good. |
| 194 root_layer_ = NULL; | 191 root_layer_ = NULL; |
| 195 } | 192 } |
| 196 } | 193 } |
| 197 | 194 |
| 198 void LayerTreeHost::SetLayerTreeHostClientReady() { | 195 void LayerTreeHost::SetLayerTreeHostClientReady() { |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 // value, then the layer can early out without needing a full commit. | 1101 // value, then the layer can early out without needing a full commit. |
| 1105 if (root_scroll_layer) { | 1102 if (root_scroll_layer) { |
| 1106 root_scroll_layer->SetScrollOffsetFromImplSide( | 1103 root_scroll_layer->SetScrollOffsetFromImplSide( |
| 1107 root_scroll_layer->scroll_offset() + root_scroll_delta); | 1104 root_scroll_layer->scroll_offset() + root_scroll_delta); |
| 1108 } | 1105 } |
| 1109 ApplyPageScaleDeltaFromImplSide(info.page_scale_delta); | 1106 ApplyPageScaleDeltaFromImplSide(info.page_scale_delta); |
| 1110 client_->ApplyScrollAndScale(root_scroll_delta, info.page_scale_delta); | 1107 client_->ApplyScrollAndScale(root_scroll_delta, info.page_scale_delta); |
| 1111 } | 1108 } |
| 1112 } | 1109 } |
| 1113 | 1110 |
| 1114 void LayerTreeHost::StartRateLimiter(WebKit::WebGraphicsContext3D* context3d) { | 1111 void LayerTreeHost::StartRateLimiter() { |
| 1115 if (animating_) | 1112 if (animating_) |
| 1116 return; | 1113 return; |
| 1117 | 1114 |
| 1118 DCHECK(context3d); | 1115 if (!rate_limit_timer_.IsRunning()) { |
| 1119 RateLimiterMap::iterator it = rate_limiters_.find(context3d); | 1116 rate_limit_timer_.Start(FROM_HERE, |
| 1120 if (it != rate_limiters_.end()) { | 1117 base::TimeDelta(), |
| 1121 it->second->Start(); | 1118 this, |
| 1122 } else { | 1119 &LayerTreeHost::RateLimit); |
| 1123 scoped_refptr<RateLimiter> rate_limiter = | |
| 1124 RateLimiter::Create(context3d, this, proxy_->MainThreadTaskRunner()); | |
| 1125 rate_limiters_[context3d] = rate_limiter; | |
| 1126 rate_limiter->Start(); | |
| 1127 } | 1120 } |
| 1128 } | 1121 } |
| 1129 | 1122 |
| 1130 void LayerTreeHost::StopRateLimiter(WebKit::WebGraphicsContext3D* context3d) { | 1123 void LayerTreeHost::StopRateLimiter() { |
| 1131 RateLimiterMap::iterator it = rate_limiters_.find(context3d); | 1124 rate_limit_timer_.Stop(); |
| 1132 if (it != rate_limiters_.end()) { | |
| 1133 it->second->Stop(); | |
| 1134 rate_limiters_.erase(it); | |
| 1135 } | |
| 1136 } | 1125 } |
| 1137 | 1126 |
| 1138 void LayerTreeHost::RateLimit() { | 1127 void LayerTreeHost::RateLimit() { |
| 1139 // Force a no-op command on the compositor context, so that any ratelimiting | 1128 // Force a no-op command on the compositor context, so that any ratelimiting |
| 1140 // commands will wait for the compositing context, and therefore for the | 1129 // commands will wait for the compositing context, and therefore for the |
| 1141 // SwapBuffers. | 1130 // SwapBuffers. |
| 1142 proxy_->ForceSerializeOnSwapBuffers(); | 1131 proxy_->ForceSerializeOnSwapBuffers(); |
| 1132 client_->RateLimitSharedMainThreadContext(); |
| 1143 } | 1133 } |
| 1144 | 1134 |
| 1145 bool LayerTreeHost::AlwaysUsePartialTextureUpdates() { | 1135 bool LayerTreeHost::AlwaysUsePartialTextureUpdates() { |
| 1146 if (!proxy_->GetRendererCapabilities().allow_partial_texture_updates) | 1136 if (!proxy_->GetRendererCapabilities().allow_partial_texture_updates) |
| 1147 return false; | 1137 return false; |
| 1148 return !proxy_->HasImplThread(); | 1138 return !proxy_->HasImplThread(); |
| 1149 } | 1139 } |
| 1150 | 1140 |
| 1151 size_t LayerTreeHost::MaxPartialTextureUpdates() const { | 1141 size_t LayerTreeHost::MaxPartialTextureUpdates() const { |
| 1152 size_t max_partial_texture_updates = 0; | 1142 size_t max_partial_texture_updates = 0; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 | 1274 |
| 1285 bool LayerTreeHost::ScheduleMicroBenchmark( | 1275 bool LayerTreeHost::ScheduleMicroBenchmark( |
| 1286 const std::string& benchmark_name, | 1276 const std::string& benchmark_name, |
| 1287 scoped_ptr<base::Value> value, | 1277 scoped_ptr<base::Value> value, |
| 1288 const MicroBenchmark::DoneCallback& callback) { | 1278 const MicroBenchmark::DoneCallback& callback) { |
| 1289 return micro_benchmark_controller_.ScheduleRun( | 1279 return micro_benchmark_controller_.ScheduleRun( |
| 1290 benchmark_name, value.Pass(), callback); | 1280 benchmark_name, value.Pass(), callback); |
| 1291 } | 1281 } |
| 1292 | 1282 |
| 1293 } // namespace cc | 1283 } // namespace cc |
| OLD | NEW |