| 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/thread_proxy.h" | 5 #include "cc/thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/delay_based_time_source.h" | 10 #include "cc/delay_based_time_source.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 52 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 53 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 53 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 54 , m_beginFrameCompletionEventOnImplThread(0) | 54 , m_beginFrameCompletionEventOnImplThread(0) |
| 55 , m_readbackRequestOnImplThread(0) | 55 , m_readbackRequestOnImplThread(0) |
| 56 , m_commitCompletionEventOnImplThread(0) | 56 , m_commitCompletionEventOnImplThread(0) |
| 57 , m_completionEventForCommitHeldOnTreeActivation(0) | 57 , m_completionEventForCommitHeldOnTreeActivation(0) |
| 58 , m_textureAcquisitionCompletionEventOnImplThread(0) | 58 , m_textureAcquisitionCompletionEventOnImplThread(0) |
| 59 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 59 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
| 60 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 60 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
| 61 , m_insideDraw(false) | 61 , m_insideDraw(false) |
| 62 , m_renderVSyncNotificationEnabled(layerTreeHost->settings().renderVSyncNoti
ficationEnabled) |
| 63 , m_vsyncClient(0) |
| 62 , m_totalCommitCount(0) | 64 , m_totalCommitCount(0) |
| 63 , m_deferCommits(false) | 65 , m_deferCommits(false) |
| 64 , m_renewTreePriorityOnImplThreadPending(false) | 66 , m_renewTreePriorityOnImplThreadPending(false) |
| 65 { | 67 { |
| 66 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 68 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 67 DCHECK(isMainThread()); | 69 DCHECK(isMainThread()); |
| 68 } | 70 } |
| 69 | 71 |
| 70 ThreadProxy::~ThreadProxy() | 72 ThreadProxy::~ThreadProxy() |
| 71 { | 73 { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::didCompleteSwapBuffer
s, m_mainThreadWeakPtr)); | 327 Proxy::mainThread()->postTask(base::Bind(&ThreadProxy::didCompleteSwapBuffer
s, m_mainThreadWeakPtr)); |
| 326 } | 328 } |
| 327 | 329 |
| 328 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD
elta interval) | 330 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD
elta interval) |
| 329 { | 331 { |
| 330 DCHECK(isImplThread()); | 332 DCHECK(isImplThread()); |
| 331 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim
ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds
()); | 333 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim
ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds
()); |
| 332 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); | 334 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); |
| 333 } | 335 } |
| 334 | 336 |
| 337 void ThreadProxy::didVSync(base::TimeTicks frameTime) |
| 338 { |
| 339 DCHECK(isImplThread()); |
| 340 TRACE_EVENT0("cc", "ThreadProxy::didVSync"); |
| 341 if (m_vsyncClient) |
| 342 m_vsyncClient->DidVSync(frameTime); |
| 343 } |
| 344 |
| 335 void ThreadProxy::onCanDrawStateChanged(bool canDraw) | 345 void ThreadProxy::onCanDrawStateChanged(bool canDraw) |
| 336 { | 346 { |
| 337 DCHECK(isImplThread()); | 347 DCHECK(isImplThread()); |
| 338 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw)
; | 348 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw)
; |
| 339 m_schedulerOnImplThread->setCanDraw(canDraw); | 349 m_schedulerOnImplThread->setCanDraw(canDraw); |
| 340 } | 350 } |
| 341 | 351 |
| 342 void ThreadProxy::onHasPendingTreeStateChanged(bool hasPendingTree) | 352 void ThreadProxy::onHasPendingTreeStateChanged(bool hasPendingTree) |
| 343 { | 353 { |
| 344 DCHECK(isImplThread()); | 354 DCHECK(isImplThread()); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 m_outputSurfaceRecreationCallback.Cancel(); | 994 m_outputSurfaceRecreationCallback.Cancel(); |
| 985 } | 995 } |
| 986 | 996 |
| 987 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
andler* handler) | 997 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
andler* handler) |
| 988 { | 998 { |
| 989 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); | 999 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); |
| 990 DCHECK(isImplThread()); | 1000 DCHECK(isImplThread()); |
| 991 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); | 1001 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); |
| 992 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); | 1002 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); |
| 993 scoped_ptr<FrameRateController> frameRateController; | 1003 scoped_ptr<FrameRateController> frameRateController; |
| 994 if (m_renderVSyncEnabled) | 1004 if (m_renderVSyncEnabled) { |
| 995 frameRateController.reset(new FrameRateController(DelayBasedTimeSource::
create(displayRefreshInterval, Proxy::implThread()))); | 1005 if (m_renderVSyncNotificationEnabled) |
| 996 else | 1006 frameRateController.reset(new FrameRateController(VSyncTimeSource::c
reate(this))); |
| 1007 else |
| 1008 frameRateController.reset(new FrameRateController(DelayBasedTimeSour
ce::create(displayRefreshInterval, Proxy::implThread()))); |
| 1009 } else |
| 997 frameRateController.reset(new FrameRateController(Proxy::implThread())); | 1010 frameRateController.reset(new FrameRateController(Proxy::implThread())); |
| 998 SchedulerSettings schedulerSettings; | 1011 SchedulerSettings schedulerSettings; |
| 999 schedulerSettings.implSidePainting = m_layerTreeHost->settings().implSidePai
nting; | 1012 schedulerSettings.implSidePainting = m_layerTreeHost->settings().implSidePai
nting; |
| 1000 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass()
, | 1013 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass()
, |
| 1001 schedulerSettings); | 1014 schedulerSettings); |
| 1002 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 1015 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
| 1003 | 1016 |
| 1004 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); | 1017 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); |
| 1005 if (m_inputHandlerOnImplThread.get()) | 1018 if (m_inputHandlerOnImplThread.get()) |
| 1006 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); | 1019 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1036 completion->signal(); | 1049 completion->signal(); |
| 1037 } | 1050 } |
| 1038 | 1051 |
| 1039 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) | 1052 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) |
| 1040 { | 1053 { |
| 1041 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); | 1054 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); |
| 1042 DCHECK(isImplThread()); | 1055 DCHECK(isImplThread()); |
| 1043 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 1056 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
| 1044 m_inputHandlerOnImplThread.reset(); | 1057 m_inputHandlerOnImplThread.reset(); |
| 1045 m_layerTreeHostImpl.reset(); | 1058 m_layerTreeHostImpl.reset(); |
| 1059 m_vsyncClient = 0; |
| 1046 m_schedulerOnImplThread.reset(); | 1060 m_schedulerOnImplThread.reset(); |
| 1047 m_weakFactoryOnImplThread.InvalidateWeakPtrs(); | 1061 m_weakFactoryOnImplThread.InvalidateWeakPtrs(); |
| 1048 completion->signal(); | 1062 completion->signal(); |
| 1049 } | 1063 } |
| 1050 | 1064 |
| 1051 void ThreadProxy::setFullRootLayerDamageOnImplThread() | 1065 void ThreadProxy::setFullRootLayerDamageOnImplThread() |
| 1052 { | 1066 { |
| 1053 DCHECK(isImplThread()); | 1067 DCHECK(isImplThread()); |
| 1054 m_layerTreeHostImpl->setFullRootLayerDamage(); | 1068 m_layerTreeHostImpl->setFullRootLayerDamage(); |
| 1055 } | 1069 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1072 completion->signal(); | 1086 completion->signal(); |
| 1073 } | 1087 } |
| 1074 | 1088 |
| 1075 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) | 1089 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) |
| 1076 { | 1090 { |
| 1077 DCHECK(isImplThread()); | 1091 DCHECK(isImplThread()); |
| 1078 m_layerTreeHostImpl->renderingStats(stats); | 1092 m_layerTreeHostImpl->renderingStats(stats); |
| 1079 completion->signal(); | 1093 completion->signal(); |
| 1080 } | 1094 } |
| 1081 | 1095 |
| 1096 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) |
| 1097 { |
| 1098 DCHECK(isImplThread()); |
| 1099 m_vsyncClient = client; |
| 1100 m_layerTreeHostImpl->enableVSyncNotification(client); |
| 1101 } |
| 1102 |
| 1082 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 1103 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
| 1083 : memoryAllocationLimitBytes(0) | 1104 : memoryAllocationLimitBytes(0) |
| 1084 { | 1105 { |
| 1085 } | 1106 } |
| 1086 | 1107 |
| 1087 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 1108 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
| 1088 { | 1109 { |
| 1089 } | 1110 } |
| 1090 | 1111 |
| 1091 bool ThreadProxy::commitPendingForTesting() | 1112 bool ThreadProxy::commitPendingForTesting() |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 | 1209 |
| 1189 void ThreadProxy::renewTreePriorityOnImplThread() | 1210 void ThreadProxy::renewTreePriorityOnImplThread() |
| 1190 { | 1211 { |
| 1191 DCHECK(m_renewTreePriorityOnImplThreadPending); | 1212 DCHECK(m_renewTreePriorityOnImplThreadPending); |
| 1192 m_renewTreePriorityOnImplThreadPending = false; | 1213 m_renewTreePriorityOnImplThreadPending = false; |
| 1193 | 1214 |
| 1194 renewTreePriority(); | 1215 renewTreePriority(); |
| 1195 } | 1216 } |
| 1196 | 1217 |
| 1197 } // namespace cc | 1218 } // namespace cc |
| OLD | NEW |