| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/thread_proxy.h" | 7 #include "cc/thread_proxy.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return m_started; | 148 return m_started; |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool ThreadProxy::initializeContext() | 151 bool ThreadProxy::initializeContext() |
| 152 { | 152 { |
| 153 TRACE_EVENT0("cc", "ThreadProxy::initializeContext"); | 153 TRACE_EVENT0("cc", "ThreadProxy::initializeContext"); |
| 154 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); | 154 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); |
| 155 if (!context.get()) | 155 if (!context.get()) |
| 156 return false; | 156 return false; |
| 157 | 157 |
| 158 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeContextOnIm
plThread, base::Unretained(this), context.release())); | 158 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeContextOnIm
plThread, base::Unretained(this), base::Passed(context.Pass()))); |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ThreadProxy::setSurfaceReady() | 162 void ThreadProxy::setSurfaceReady() |
| 163 { | 163 { |
| 164 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); | 164 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); |
| 165 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setSurfaceReadyOnImpl
Thread, base::Unretained(this))); | 165 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setSurfaceReadyOnImpl
Thread, base::Unretained(this))); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ThreadProxy::setSurfaceReadyOnImplThread() | 168 void ThreadProxy::setSurfaceReadyOnImplThread() |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Make a blocking call to recreateContextOnImplThread. The results of that | 227 // Make a blocking call to recreateContextOnImplThread. The results of that |
| 228 // call are pushed into the recreateSucceeded and capabilities local | 228 // call are pushed into the recreateSucceeded and capabilities local |
| 229 // variables. | 229 // variables. |
| 230 CompletionEvent completion; | 230 CompletionEvent completion; |
| 231 bool recreateSucceeded = false; | 231 bool recreateSucceeded = false; |
| 232 RendererCapabilities capabilities; | 232 RendererCapabilities capabilities; |
| 233 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 233 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 234 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl
Thread, | 234 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl
Thread, |
| 235 base::Unretained(this), | 235 base::Unretained(this), |
| 236 &completion, | 236 &completion, |
| 237 context.release(), | 237 base::Passed(context.Pass()), |
| 238 &recreateSucceeded, | 238 &recreateSucceeded, |
| 239 &capabilities)); | 239 &capabilities)); |
| 240 completion.wait(); | 240 completion.wait(); |
| 241 | 241 |
| 242 if (recreateSucceeded) | 242 if (recreateSucceeded) |
| 243 m_RendererCapabilitiesMainThreadCopy = capabilities; | 243 m_RendererCapabilitiesMainThreadCopy = capabilities; |
| 244 return recreateSucceeded; | 244 return recreateSucceeded; |
| 245 } | 245 } |
| 246 | 246 |
| 247 void ThreadProxy::renderingStats(RenderingStats* stats) | 247 void ThreadProxy::renderingStats(RenderingStats* stats) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 DCHECK(isImplThread()); | 339 DCHECK(isImplThread()); |
| 340 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); | 340 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); |
| 341 m_schedulerOnImplThread->setNeedsCommit(); | 341 m_schedulerOnImplThread->setNeedsCommit(); |
| 342 m_schedulerOnImplThread->setNeedsForcedCommit(); | 342 m_schedulerOnImplThread->setNeedsForcedCommit(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati
onEventsVector> events, base::Time wallClockTime) | 345 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati
onEventsVector> events, base::Time wallClockTime) |
| 346 { | 346 { |
| 347 DCHECK(isImplThread()); | 347 DCHECK(isImplThread()); |
| 348 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread
"); | 348 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread
"); |
| 349 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimation
Events, base::Unretained(this), events.release(), wallClockTime)); | 349 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimation
Events, base::Unretained(this), base::Passed(events.Pass()), wallClockTime)); |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) | 352 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) |
| 353 { | 353 { |
| 354 DCHECK(isImplThread()); | 354 DCHECK(isImplThread()); |
| 355 | 355 |
| 356 if (!m_layerTreeHost->contentsTextureManager()) | 356 if (!m_layerTreeHost->contentsTextureManager()) |
| 357 return false; | 357 return false; |
| 358 | 358 |
| 359 ResourceProvider::debugNotifyEnterZone(0x1000000); | 359 ResourceProvider::debugNotifyEnterZone(0x1000000); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 } | 854 } |
| 855 | 855 |
| 856 void ThreadProxy::didCompleteSwapBuffers() | 856 void ThreadProxy::didCompleteSwapBuffers() |
| 857 { | 857 { |
| 858 DCHECK(isMainThread()); | 858 DCHECK(isMainThread()); |
| 859 if (!m_layerTreeHost) | 859 if (!m_layerTreeHost) |
| 860 return; | 860 return; |
| 861 m_layerTreeHost->didCompleteSwapBuffers(); | 861 m_layerTreeHost->didCompleteSwapBuffers(); |
| 862 } | 862 } |
| 863 | 863 |
| 864 void ThreadProxy::setAnimationEvents(AnimationEventsVector* passed_events, base:
:Time wallClockTime) | 864 void ThreadProxy::setAnimationEvents(scoped_ptr<AnimationEventsVector> events, b
ase::Time wallClockTime) |
| 865 { | 865 { |
| 866 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events)); | |
| 867 | |
| 868 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); | 866 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); |
| 869 DCHECK(isMainThread()); | 867 DCHECK(isMainThread()); |
| 870 if (!m_layerTreeHost) | 868 if (!m_layerTreeHost) |
| 871 return; | 869 return; |
| 872 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); | 870 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); |
| 873 } | 871 } |
| 874 | 872 |
| 875 void ThreadProxy::beginContextRecreation() | 873 void ThreadProxy::beginContextRecreation() |
| 876 { | 874 { |
| 877 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); | 875 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 906 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass()
); | 904 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass()
); |
| 907 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 905 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
| 908 | 906 |
| 909 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); | 907 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); |
| 910 if (m_inputHandlerOnImplThread.get()) | 908 if (m_inputHandlerOnImplThread.get()) |
| 911 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); | 909 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); |
| 912 | 910 |
| 913 completion->signal(); | 911 completion->signal(); |
| 914 } | 912 } |
| 915 | 913 |
| 916 void ThreadProxy::initializeContextOnImplThread(GraphicsContext* context) | 914 void ThreadProxy::initializeContextOnImplThread(scoped_ptr<GraphicsContext> cont
ext) |
| 917 { | 915 { |
| 918 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); | 916 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); |
| 919 DCHECK(isImplThread()); | 917 DCHECK(isImplThread()); |
| 920 m_contextBeforeInitializationOnImplThread = scoped_ptr<GraphicsContext>(cont
ext).Pass(); | 918 m_contextBeforeInitializationOnImplThread = context.Pass(); |
| 921 } | 919 } |
| 922 | 920 |
| 923 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo
ol* initializeSucceeded, RendererCapabilities* capabilities) | 921 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo
ol* initializeSucceeded, RendererCapabilities* capabilities) |
| 924 { | 922 { |
| 925 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); | 923 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); |
| 926 DCHECK(isImplThread()); | 924 DCHECK(isImplThread()); |
| 927 DCHECK(m_contextBeforeInitializationOnImplThread.get()); | 925 DCHECK(m_contextBeforeInitializationOnImplThread.get()); |
| 928 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); | 926 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); |
| 929 if (*initializeSucceeded) { | 927 if (*initializeSucceeded) { |
| 930 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 928 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 952 { | 950 { |
| 953 DCHECK(isImplThread()); | 951 DCHECK(isImplThread()); |
| 954 m_layerTreeHostImpl->setFullRootLayerDamage(); | 952 m_layerTreeHostImpl->setFullRootLayerDamage(); |
| 955 } | 953 } |
| 956 | 954 |
| 957 size_t ThreadProxy::maxPartialTextureUpdates() const | 955 size_t ThreadProxy::maxPartialTextureUpdates() const |
| 958 { | 956 { |
| 959 return ResourceUpdateController::maxPartialTextureUpdates(); | 957 return ResourceUpdateController::maxPartialTextureUpdates(); |
| 960 } | 958 } |
| 961 | 959 |
| 962 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, Graph
icsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* capabilit
ies) | 960 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, scope
d_ptr<GraphicsContext> context, bool* recreateSucceeded, RendererCapabilities* c
apabilities) |
| 963 { | 961 { |
| 964 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); | 962 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); |
| 965 DCHECK(isImplThread()); | 963 DCHECK(isImplThread()); |
| 966 ResourceProvider::debugNotifyEnterZone(0x7000000); | 964 ResourceProvider::debugNotifyEnterZone(0x7000000); |
| 967 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 965 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
| 968 ResourceProvider::debugNotifyLeaveZone(); | 966 ResourceProvider::debugNotifyLeaveZone(); |
| 969 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<Grap
hicsContext>(contextPtr).Pass()); | 967 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(context.Pass())
; |
| 970 if (*recreateSucceeded) { | 968 if (*recreateSucceeded) { |
| 971 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 969 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
| 972 m_schedulerOnImplThread->didRecreateContext(); | 970 m_schedulerOnImplThread->didRecreateContext(); |
| 973 } | 971 } |
| 974 completion->signal(); | 972 completion->signal(); |
| 975 } | 973 } |
| 976 | 974 |
| 977 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) | 975 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) |
| 978 { | 976 { |
| 979 DCHECK(isImplThread()); | 977 DCHECK(isImplThread()); |
| 980 m_layerTreeHostImpl->renderingStats(stats); | 978 m_layerTreeHostImpl->renderingStats(stats); |
| 981 completion->signal(); | 979 completion->signal(); |
| 982 } | 980 } |
| 983 | 981 |
| 984 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 982 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
| 985 { | 983 { |
| 986 } | 984 } |
| 987 | 985 |
| 988 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 986 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
| 989 { | 987 { |
| 990 } | 988 } |
| 991 | 989 |
| 992 } // namespace cc | 990 } // namespace cc |
| OLD | NEW |