| 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/single_thread_proxy.h" | 5 #include "cc/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/context_provider.h" | 9 #include "cc/context_provider.h" |
| 10 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 offscreen_context_provider->VerifyContexts(); | 164 offscreen_context_provider->VerifyContexts(); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 if (initialized) | 168 if (initialized) |
| 169 output_surface_lost_ = false; | 169 output_surface_lost_ = false; |
| 170 | 170 |
| 171 return initialized; | 171 return initialized; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void SingleThreadProxy::GetRenderingStats(RenderingStats* stats) { | |
| 175 stats->totalCommitTime = total_commit_time_; | |
| 176 stats->totalCommitCount = total_commit_count_; | |
| 177 layer_tree_host_impl_->renderingStats(stats); | |
| 178 } | |
| 179 | |
| 180 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 174 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 181 DCHECK(renderer_initialized_); | 175 DCHECK(renderer_initialized_); |
| 182 // Note: this gets called during the commit by the "impl" thread. | 176 // Note: this gets called during the commit by the "impl" thread. |
| 183 return renderer_capabilities_for_main_thread_; | 177 return renderer_capabilities_for_main_thread_; |
| 184 } | 178 } |
| 185 | 179 |
| 186 void SingleThreadProxy::SetNeedsAnimate() { | 180 void SingleThreadProxy::SetNeedsAnimate() { |
| 187 // Thread-only feature. | 181 // Thread-only feature. |
| 188 NOTREACHED(); | 182 NOTREACHED(); |
| 189 } | 183 } |
| 190 | 184 |
| 191 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { | 185 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { |
| 192 DCHECK(Proxy::IsMainThread()); | 186 DCHECK(Proxy::IsMainThread()); |
| 193 // Commit immediately. | 187 // Commit immediately. |
| 194 { | 188 { |
| 195 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 189 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
| 196 DebugScopedSetImplThread impl(this); | 190 DebugScopedSetImplThread impl(this); |
| 197 | 191 |
| 198 base::TimeTicks startTime = base::TimeTicks::HighResNow(); | 192 RenderingStatsRecorder* stats_recorder = layer_tree_host_->renderingStatsRec
order(); |
| 193 base::TimeTicks startTime = stats_recorder->StartRecording(); |
| 199 layer_tree_host_impl_->beginCommit(); | 194 layer_tree_host_impl_->beginCommit(); |
| 200 | 195 |
| 201 layer_tree_host_->contentsTextureManager()-> | 196 layer_tree_host_->contentsTextureManager()-> |
| 202 pushTexturePrioritiesToBackings(); | 197 pushTexturePrioritiesToBackings(); |
| 203 layer_tree_host_->beginCommitOnImplThread(layer_tree_host_impl_.get()); | 198 layer_tree_host_->beginCommitOnImplThread(layer_tree_host_impl_.get()); |
| 204 | 199 |
| 205 scoped_ptr<ResourceUpdateController> updateController = | 200 scoped_ptr<ResourceUpdateController> updateController = |
| 206 ResourceUpdateController::Create( | 201 ResourceUpdateController::Create( |
| 207 NULL, | 202 NULL, |
| 208 Proxy::MainThread(), | 203 Proxy::MainThread(), |
| 209 queue.Pass(), | 204 queue.Pass(), |
| 210 layer_tree_host_impl_->resourceProvider()); | 205 layer_tree_host_impl_->resourceProvider()); |
| 211 updateController->Finalize(); | 206 updateController->Finalize(); |
| 212 | 207 |
| 213 layer_tree_host_->finishCommitOnImplThread(layer_tree_host_impl_.get()); | 208 layer_tree_host_->finishCommitOnImplThread(layer_tree_host_impl_.get()); |
| 214 | 209 |
| 215 layer_tree_host_impl_->commitComplete(); | 210 layer_tree_host_impl_->commitComplete(); |
| 216 | 211 |
| 217 #ifndef NDEBUG | 212 #ifndef NDEBUG |
| 218 // In the single-threaded case, the scroll deltas should never be | 213 // In the single-threaded case, the scroll deltas should never be |
| 219 // touched on the impl layer tree. | 214 // touched on the impl layer tree. |
| 220 scoped_ptr<ScrollAndScaleSet> scrollInfo = | 215 scoped_ptr<ScrollAndScaleSet> scrollInfo = |
| 221 layer_tree_host_impl_->processScrollDeltas(); | 216 layer_tree_host_impl_->processScrollDeltas(); |
| 222 DCHECK(!scrollInfo->scrolls.size()); | 217 DCHECK(!scrollInfo->scrolls.size()); |
| 223 #endif | 218 #endif |
| 224 | 219 |
| 225 base::TimeTicks endTime = base::TimeTicks::HighResNow(); | 220 base::TimeDelta duration = stats_recorder->EndRecording(startTime); |
| 226 total_commit_time_ += endTime - startTime; | 221 stats_recorder->AddCommit(duration); |
| 227 total_commit_count_++; | |
| 228 } | 222 } |
| 229 layer_tree_host_->commitComplete(); | 223 layer_tree_host_->commitComplete(); |
| 230 next_frame_is_newly_committed_frame_ = true; | 224 next_frame_is_newly_committed_frame_ = true; |
| 231 } | 225 } |
| 232 | 226 |
| 233 void SingleThreadProxy::SetNeedsCommit() { | 227 void SingleThreadProxy::SetNeedsCommit() { |
| 234 DCHECK(Proxy::IsMainThread()); | 228 DCHECK(Proxy::IsMainThread()); |
| 235 layer_tree_host_->scheduleComposite(); | 229 layer_tree_host_->scheduleComposite(); |
| 236 } | 230 } |
| 237 | 231 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 443 |
| 450 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 444 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 451 | 445 |
| 452 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { | 446 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { |
| 453 // Impl-side painting only. | 447 // Impl-side painting only. |
| 454 NOTREACHED(); | 448 NOTREACHED(); |
| 455 return skia::RefPtr<SkPicture>(); | 449 return skia::RefPtr<SkPicture>(); |
| 456 } | 450 } |
| 457 | 451 |
| 458 } // namespace cc | 452 } // namespace cc |
| OLD | NEW |