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 "CCThreadProxy.h" | 7 #include "CCThreadProxy.h" |
8 | 8 |
9 #include "CCDelayBasedTimeSource.h" | 9 #include "CCDelayBasedTimeSource.h" |
10 #include "CCDrawQuad.h" | 10 #include "CCDrawQuad.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Measured in seconds. | 26 // Measured in seconds. |
27 const double contextRecreationTickRate = 0.03; | 27 const double contextRecreationTickRate = 0.03; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 namespace cc { | 31 namespace cc { |
32 | 32 |
33 scoped_ptr<CCProxy> CCThreadProxy::create(CCLayerTreeHost* layerTreeHost) | 33 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost) |
34 { | 34 { |
35 return make_scoped_ptr(new CCThreadProxy(layerTreeHost)).PassAs<CCProxy>(); | 35 return make_scoped_ptr(new ThreadProxy(layerTreeHost)).PassAs<Proxy>(); |
36 } | 36 } |
37 | 37 |
38 CCThreadProxy::CCThreadProxy(CCLayerTreeHost* layerTreeHost) | 38 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost) |
39 : m_animateRequested(false) | 39 : m_animateRequested(false) |
40 , m_commitRequested(false) | 40 , m_commitRequested(false) |
41 , m_commitRequestSentToImplThread(false) | 41 , m_commitRequestSentToImplThread(false) |
42 , m_forcedCommitRequested(false) | 42 , m_forcedCommitRequested(false) |
43 , m_layerTreeHost(layerTreeHost) | 43 , m_layerTreeHost(layerTreeHost) |
44 , m_rendererInitialized(false) | 44 , m_rendererInitialized(false) |
45 , m_started(false) | 45 , m_started(false) |
46 , m_texturesAcquired(true) | 46 , m_texturesAcquired(true) |
47 , m_inCompositeAndReadback(false) | 47 , m_inCompositeAndReadback(false) |
48 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) | 48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) |
49 , m_beginFrameCompletionEventOnImplThread(0) | 49 , m_beginFrameCompletionEventOnImplThread(0) |
50 , m_readbackRequestOnImplThread(0) | 50 , m_readbackRequestOnImplThread(0) |
51 , m_commitCompletionEventOnImplThread(0) | 51 , m_commitCompletionEventOnImplThread(0) |
52 , m_textureAcquisitionCompletionEventOnImplThread(0) | 52 , m_textureAcquisitionCompletionEventOnImplThread(0) |
53 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 53 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
54 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 54 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
55 , m_totalCommitCount(0) | 55 , m_totalCommitCount(0) |
56 { | 56 { |
57 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); | 57 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
58 ASSERT(isMainThread()); | 58 ASSERT(isMainThread()); |
59 } | 59 } |
60 | 60 |
61 CCThreadProxy::~CCThreadProxy() | 61 ThreadProxy::~ThreadProxy() |
62 { | 62 { |
63 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); | 63 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
64 ASSERT(isMainThread()); | 64 ASSERT(isMainThread()); |
65 ASSERT(!m_started); | 65 ASSERT(!m_started); |
66 } | 66 } |
67 | 67 |
68 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) | 68 bool ThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) |
69 { | 69 { |
70 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); | 70 TRACE_EVENT0("cc", "ThreadPRoxy::compositeAndReadback"); |
71 ASSERT(isMainThread()); | 71 ASSERT(isMainThread()); |
72 ASSERT(m_layerTreeHost); | 72 ASSERT(m_layerTreeHost); |
73 | 73 |
74 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 74 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
75 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 75 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 // Perform a synchronous commit. | 80 // Perform a synchronous commit. |
81 { | 81 { |
82 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 82 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
83 CCCompletionEvent beginFrameCompletion; | 83 CompletionEvent beginFrameCompletion; |
84 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:forceBeginFrameOnImplThread, &beginFrameCompletion)); | 84 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::force
BeginFrameOnImplThread, &beginFrameCompletion)); |
85 beginFrameCompletion.wait(); | 85 beginFrameCompletion.wait(); |
86 } | 86 } |
87 m_inCompositeAndReadback = true; | 87 m_inCompositeAndReadback = true; |
88 beginFrame(); | 88 beginFrame(); |
89 m_inCompositeAndReadback = false; | 89 m_inCompositeAndReadback = false; |
90 | 90 |
91 // Perform a synchronous readback. | 91 // Perform a synchronous readback. |
92 ReadbackRequest request; | 92 ReadbackRequest request; |
93 request.rect = rect; | 93 request.rect = rect; |
94 request.pixels = pixels; | 94 request.pixels = pixels; |
95 { | 95 { |
96 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 96 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
97 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:requestReadbackOnImplThread, &request)); | 97 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::reque
stReadbackOnImplThread, &request)); |
98 request.completion.wait(); | 98 request.completion.wait(); |
99 } | 99 } |
100 return request.success; | 100 return request.success; |
101 } | 101 } |
102 | 102 |
103 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) | 103 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) |
104 { | 104 { |
105 ASSERT(CCProxy::isImplThread()); | 105 ASSERT(Proxy::isImplThread()); |
106 ASSERT(!m_readbackRequestOnImplThread); | 106 ASSERT(!m_readbackRequestOnImplThread); |
107 if (!m_layerTreeHostImpl.get()) { | 107 if (!m_layerTreeHostImpl.get()) { |
108 request->success = false; | 108 request->success = false; |
109 request->completion.signal(); | 109 request->completion.signal(); |
110 return; | 110 return; |
111 } | 111 } |
112 | 112 |
113 m_readbackRequestOnImplThread = request; | 113 m_readbackRequestOnImplThread = request; |
114 m_schedulerOnImplThread->setNeedsRedraw(); | 114 m_schedulerOnImplThread->setNeedsRedraw(); |
115 m_schedulerOnImplThread->setNeedsForcedRedraw(); | 115 m_schedulerOnImplThread->setNeedsForcedRedraw(); |
116 } | 116 } |
117 | 117 |
118 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool
useAnchor, float scale, double duration) | 118 void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool us
eAnchor, float scale, double duration) |
119 { | 119 { |
120 ASSERT(CCProxy::isMainThread()); | 120 ASSERT(Proxy::isMainThread()); |
121 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req
uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat
ion)); | 121 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::requestSt
artPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, duration)); |
122 } | 122 } |
123 | 123 |
124 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos
ition, bool useAnchor, float scale, double duration) | 124 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit
ion, bool useAnchor, float scale, double duration) |
125 { | 125 { |
126 ASSERT(CCProxy::isImplThread()); | 126 ASSERT(Proxy::isImplThread()); |
127 if (m_layerTreeHostImpl.get()) | 127 if (m_layerTreeHostImpl.get()) |
128 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); | 128 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); |
129 } | 129 } |
130 | 130 |
131 void CCThreadProxy::finishAllRendering() | 131 void ThreadProxy::finishAllRendering() |
132 { | 132 { |
133 ASSERT(CCProxy::isMainThread()); | 133 ASSERT(Proxy::isMainThread()); |
134 | 134 |
135 // Make sure all GL drawing is finished on the impl thread. | 135 // Make sure all GL drawing is finished on the impl thread. |
136 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 136 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
137 CCCompletionEvent completion; | 137 CompletionEvent completion; |
138 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin
ishAllRenderingOnImplThread, &completion)); | 138 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); |
139 completion.wait(); | 139 completion.wait(); |
140 } | 140 } |
141 | 141 |
142 bool CCThreadProxy::isStarted() const | 142 bool ThreadProxy::isStarted() const |
143 { | 143 { |
144 ASSERT(CCProxy::isMainThread()); | 144 ASSERT(Proxy::isMainThread()); |
145 return m_started; | 145 return m_started; |
146 } | 146 } |
147 | 147 |
148 bool CCThreadProxy::initializeContext() | 148 bool ThreadProxy::initializeContext() |
149 { | 149 { |
150 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext"); | 150 TRACE_EVENT0("cc", "ThreadProxy::initializeContext"); |
151 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); | 151 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); |
152 if (!context.get()) | 152 if (!context.get()) |
153 return false; | 153 return false; |
154 | 154 |
155 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini
tializeContextOnImplThread, | 155 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eContextOnImplThread, |
156 context.release())); | 156 context.release())); |
157 return true; | 157 return true; |
158 } | 158 } |
159 | 159 |
160 void CCThreadProxy::setSurfaceReady() | 160 void ThreadProxy::setSurfaceReady() |
161 { | 161 { |
162 TRACE_EVENT0("cc", "CCThreadProxy::setSurfaceReady"); | 162 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); |
163 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
SurfaceReadyOnImplThread)); | 163 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setSurfac
eReadyOnImplThread)); |
164 } | 164 } |
165 | 165 |
166 void CCThreadProxy::setSurfaceReadyOnImplThread() | 166 void ThreadProxy::setSurfaceReadyOnImplThread() |
167 { | 167 { |
168 TRACE_EVENT0("cc", "CCThreadProxy::setSurfaceReadyOnImplThread"); | 168 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); |
169 m_schedulerOnImplThread->setCanBeginFrame(true); | 169 m_schedulerOnImplThread->setCanBeginFrame(true); |
170 } | 170 } |
171 | 171 |
172 void CCThreadProxy::setVisible(bool visible) | 172 void ThreadProxy::setVisible(bool visible) |
173 { | 173 { |
174 TRACE_EVENT0("cc", "CCThreadProxy::setVisible"); | 174 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); |
175 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 175 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
176 CCCompletionEvent completion; | 176 CompletionEvent completion; |
177 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
VisibleOnImplThread, &completion, visible)); | 177 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setVisibl
eOnImplThread, &completion, visible)); |
178 completion.wait(); | 178 completion.wait(); |
179 } | 179 } |
180 | 180 |
181 void CCThreadProxy::setVisibleOnImplThread(CCCompletionEvent* completion, bool v
isible) | 181 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib
le) |
182 { | 182 { |
183 TRACE_EVENT0("cc", "CCThreadProxy::setVisibleOnImplThread"); | 183 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); |
184 m_layerTreeHostImpl->setVisible(visible); | 184 m_layerTreeHostImpl->setVisible(visible); |
185 m_schedulerOnImplThread->setVisible(visible); | 185 m_schedulerOnImplThread->setVisible(visible); |
186 completion->signal(); | 186 completion->signal(); |
187 } | 187 } |
188 | 188 |
189 bool CCThreadProxy::initializeRenderer() | 189 bool ThreadProxy::initializeRenderer() |
190 { | 190 { |
191 TRACE_EVENT0("cc", "CCThreadProxy::initializeRenderer"); | 191 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); |
192 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call | 192 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call |
193 // are pushed into the initializeSucceeded and capabilities local variables. | 193 // are pushed into the initializeSucceeded and capabilities local variables. |
194 CCCompletionEvent completion; | 194 CompletionEvent completion; |
195 bool initializeSucceeded = false; | 195 bool initializeSucceeded = false; |
196 RendererCapabilities capabilities; | 196 RendererCapabilities capabilities; |
197 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 197 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
198 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini
tializeRendererOnImplThread, | 198 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eRendererOnImplThread, |
199 &completion, | 199 &completion, |
200 &initializeSucceeded, | 200 &initializeSucceeded, |
201 &capabilities)); | 201 &capabilities)); |
202 completion.wait(); | 202 completion.wait(); |
203 | 203 |
204 if (initializeSucceeded) { | 204 if (initializeSucceeded) { |
205 m_rendererInitialized = true; | 205 m_rendererInitialized = true; |
206 m_RendererCapabilitiesMainThreadCopy = capabilities; | 206 m_RendererCapabilitiesMainThreadCopy = capabilities; |
207 } | 207 } |
208 return initializeSucceeded; | 208 return initializeSucceeded; |
209 } | 209 } |
210 | 210 |
211 bool CCThreadProxy::recreateContext() | 211 bool ThreadProxy::recreateContext() |
212 { | 212 { |
213 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext"); | 213 TRACE_EVENT0("cc", "ThreadProxy::recreateContext"); |
214 ASSERT(isMainThread()); | 214 ASSERT(isMainThread()); |
215 | 215 |
216 // Try to create the context. | 216 // Try to create the context. |
217 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); | 217 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); |
218 if (!context.get()) | 218 if (!context.get()) |
219 return false; | 219 return false; |
220 if (m_layerTreeHost->needsSharedContext()) | 220 if (m_layerTreeHost->needsSharedContext()) |
221 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) | 221 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) |
222 return false; | 222 return false; |
223 | 223 |
224 // Make a blocking call to recreateContextOnImplThread. The results of that | 224 // Make a blocking call to recreateContextOnImplThread. The results of that |
225 // call are pushed into the recreateSucceeded and capabilities local | 225 // call are pushed into the recreateSucceeded and capabilities local |
226 // variables. | 226 // variables. |
227 CCCompletionEvent completion; | 227 CompletionEvent completion; |
228 bool recreateSucceeded = false; | 228 bool recreateSucceeded = false; |
229 RendererCapabilities capabilities; | 229 RendererCapabilities capabilities; |
230 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 230 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
231 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::rec
reateContextOnImplThread, | 231 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::recreateC
ontextOnImplThread, |
232 &completion, | 232 &completion, |
233 context.release(), | 233 context.release(), |
234 &recreateSucceeded, | 234 &recreateSucceeded, |
235 &capabilities)); | 235 &capabilities)); |
236 completion.wait(); | 236 completion.wait(); |
237 | 237 |
238 if (recreateSucceeded) | 238 if (recreateSucceeded) |
239 m_RendererCapabilitiesMainThreadCopy = capabilities; | 239 m_RendererCapabilitiesMainThreadCopy = capabilities; |
240 return recreateSucceeded; | 240 return recreateSucceeded; |
241 } | 241 } |
242 | 242 |
243 void CCThreadProxy::renderingStats(CCRenderingStats* stats) | 243 void ThreadProxy::renderingStats(RenderingStats* stats) |
244 { | 244 { |
245 ASSERT(isMainThread()); | 245 ASSERT(isMainThread()); |
246 | 246 |
247 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 247 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
248 CCCompletionEvent completion; | 248 CompletionEvent completion; |
249 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren
deringStatsOnImplThread, | 249 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::rendering
StatsOnImplThread, |
250 &completion, | 250 &completion, |
251 stats)); | 251 stats)); |
252 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); | 252 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); |
253 stats->totalCommitCount = m_totalCommitCount; | 253 stats->totalCommitCount = m_totalCommitCount; |
254 | 254 |
255 completion.wait(); | 255 completion.wait(); |
256 } | 256 } |
257 | 257 |
258 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const | 258 const RendererCapabilities& ThreadProxy::rendererCapabilities() const |
259 { | 259 { |
260 ASSERT(m_rendererInitialized); | 260 ASSERT(m_rendererInitialized); |
261 return m_RendererCapabilitiesMainThreadCopy; | 261 return m_RendererCapabilitiesMainThreadCopy; |
262 } | 262 } |
263 | 263 |
264 void CCThreadProxy::loseContext() | 264 void ThreadProxy::loseContext() |
265 { | 265 { |
266 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did
LoseContextOnImplThread)); | 266 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::didLoseCo
ntextOnImplThread)); |
267 } | 267 } |
268 | 268 |
269 void CCThreadProxy::setNeedsAnimate() | 269 void ThreadProxy::setNeedsAnimate() |
270 { | 270 { |
271 ASSERT(isMainThread()); | 271 ASSERT(isMainThread()); |
272 if (m_animateRequested) | 272 if (m_animateRequested) |
273 return; | 273 return; |
274 | 274 |
275 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); | 275 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); |
276 m_animateRequested = true; | 276 m_animateRequested = true; |
277 | 277 |
278 if (m_commitRequestSentToImplThread) | 278 if (m_commitRequestSentToImplThread) |
279 return; | 279 return; |
280 m_commitRequestSentToImplThread = true; | 280 m_commitRequestSentToImplThread = true; |
281 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); | 281 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsC
ommitOnImplThread)); |
282 } | 282 } |
283 | 283 |
284 void CCThreadProxy::setNeedsCommit() | 284 void ThreadProxy::setNeedsCommit() |
285 { | 285 { |
286 ASSERT(isMainThread()); | 286 ASSERT(isMainThread()); |
287 if (m_commitRequested) | 287 if (m_commitRequested) |
288 return; | 288 return; |
289 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); | 289 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit"); |
290 m_commitRequested = true; | 290 m_commitRequested = true; |
291 | 291 |
292 if (m_commitRequestSentToImplThread) | 292 if (m_commitRequestSentToImplThread) |
293 return; | 293 return; |
294 m_commitRequestSentToImplThread = true; | 294 m_commitRequestSentToImplThread = true; |
295 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); | 295 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsC
ommitOnImplThread)); |
296 } | 296 } |
297 | 297 |
298 void CCThreadProxy::didLoseContextOnImplThread() | 298 void ThreadProxy::didLoseContextOnImplThread() |
299 { | 299 { |
300 ASSERT(isImplThread()); | 300 ASSERT(isImplThread()); |
301 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); | 301 TRACE_EVENT0("cc", "ThreadProxy::didLoseContextOnImplThread"); |
302 m_schedulerOnImplThread->didLoseContext(); | 302 m_schedulerOnImplThread->didLoseContext(); |
303 } | 303 } |
304 | 304 |
305 void CCThreadProxy::onSwapBuffersCompleteOnImplThread() | 305 void ThreadProxy::onSwapBuffersCompleteOnImplThread() |
306 { | 306 { |
307 ASSERT(isImplThread()); | 307 ASSERT(isImplThread()); |
308 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread"); | 308 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); |
309 m_schedulerOnImplThread->didSwapBuffersComplete(); | 309 m_schedulerOnImplThread->didSwapBuffersComplete(); |
310 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp
leteSwapBuffers)); | 310 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComplete
SwapBuffers)); |
311 } | 311 } |
312 | 312 |
313 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in
tervalInSeconds) | 313 void ThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double inte
rvalInSeconds) |
314 { | 314 { |
315 ASSERT(isImplThread()); | 315 ASSERT(isImplThread()); |
316 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime
base", monotonicTimebase, "intervalInSeconds", intervalInSeconds); | 316 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "monotonicTimeba
se", monotonicTimebase, "intervalInSeconds", intervalInSeconds); |
317 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); | 317 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); |
318 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); | 318 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); |
319 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); | 319 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); |
320 } | 320 } |
321 | 321 |
322 void CCThreadProxy::onCanDrawStateChanged(bool canDraw) | 322 void ThreadProxy::onCanDrawStateChanged(bool canDraw) |
323 { | 323 { |
324 ASSERT(isImplThread()); | 324 ASSERT(isImplThread()); |
325 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra
w); | 325 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw)
; |
326 m_schedulerOnImplThread->setCanDraw(canDraw); | 326 m_schedulerOnImplThread->setCanDraw(canDraw); |
327 } | 327 } |
328 | 328 |
329 void CCThreadProxy::setNeedsCommitOnImplThread() | 329 void ThreadProxy::setNeedsCommitOnImplThread() |
330 { | 330 { |
331 ASSERT(isImplThread()); | 331 ASSERT(isImplThread()); |
332 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread"); | 332 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread"); |
333 m_schedulerOnImplThread->setNeedsCommit(); | 333 m_schedulerOnImplThread->setNeedsCommit(); |
334 } | 334 } |
335 | 335 |
336 void CCThreadProxy::setNeedsForcedCommitOnImplThread() | 336 void ThreadProxy::setNeedsForcedCommitOnImplThread() |
337 { | 337 { |
338 ASSERT(isImplThread()); | 338 ASSERT(isImplThread()); |
339 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread"); | 339 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); |
340 m_schedulerOnImplThread->setNeedsCommit(); | 340 m_schedulerOnImplThread->setNeedsCommit(); |
341 m_schedulerOnImplThread->setNeedsForcedCommit(); | 341 m_schedulerOnImplThread->setNeedsForcedCommit(); |
342 } | 342 } |
343 | 343 |
344 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni
mationEventsVector> events, double wallClockTime) | 344 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati
onEventsVector> events, double wallClockTime) |
345 { | 345 { |
346 ASSERT(isImplThread()); | 346 ASSERT(isImplThread()); |
347 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre
ad"); | 347 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread
"); |
348 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim
ationEvents, events.release(), wallClockTime)); | 348 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::setAnimatio
nEvents, events.release(), wallClockTime)); |
349 } | 349 } |
350 | 350 |
351 bool CCThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes) | 351 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes) |
352 { | 352 { |
353 ASSERT(isImplThread()); | 353 ASSERT(isImplThread()); |
354 | 354 |
355 if (!m_layerTreeHost->contentsTextureManager()) | 355 if (!m_layerTreeHost->contentsTextureManager()) |
356 return false; | 356 return false; |
357 | 357 |
358 if (!m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(lim
itBytes, m_layerTreeHostImpl->resourceProvider())) | 358 if (!m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(lim
itBytes, m_layerTreeHostImpl->resourceProvider())) |
359 return false; | 359 return false; |
360 | 360 |
361 // The texture upload queue may reference textures that were just purged, cl
ear | 361 // The texture upload queue may reference textures that were just purged, cl
ear |
362 // them from the queue. | 362 // them from the queue. |
363 if (m_currentTextureUpdateControllerOnImplThread.get()) | 363 if (m_currentTextureUpdateControllerOnImplThread.get()) |
364 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); | 364 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); |
365 return true; | 365 return true; |
366 } | 366 } |
367 | 367 |
368 void CCThreadProxy::setNeedsRedraw() | 368 void ThreadProxy::setNeedsRedraw() |
369 { | 369 { |
370 ASSERT(isMainThread()); | 370 ASSERT(isMainThread()); |
371 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); | 371 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); |
372 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
FullRootLayerDamageOnImplThread)); | 372 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); |
373 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsRedrawOnImplThread)); | 373 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); |
374 } | 374 } |
375 | 375 |
376 bool CCThreadProxy::commitRequested() const | 376 bool ThreadProxy::commitRequested() const |
377 { | 377 { |
378 ASSERT(isMainThread()); | 378 ASSERT(isMainThread()); |
379 return m_commitRequested; | 379 return m_commitRequested; |
380 } | 380 } |
381 | 381 |
382 void CCThreadProxy::setNeedsRedrawOnImplThread() | 382 void ThreadProxy::setNeedsRedrawOnImplThread() |
383 { | 383 { |
384 ASSERT(isImplThread()); | 384 ASSERT(isImplThread()); |
385 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread"); | 385 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); |
386 m_schedulerOnImplThread->setNeedsRedraw(); | 386 m_schedulerOnImplThread->setNeedsRedraw(); |
387 } | 387 } |
388 | 388 |
389 void CCThreadProxy::start() | 389 void ThreadProxy::start() |
390 { | 390 { |
391 ASSERT(isMainThread()); | 391 ASSERT(isMainThread()); |
392 ASSERT(CCProxy::implThread()); | 392 ASSERT(Proxy::implThread()); |
393 // Create LayerTreeHostImpl. | 393 // Create LayerTreeHostImpl. |
394 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 394 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
395 CCCompletionEvent completion; | 395 CompletionEvent completion; |
396 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler(); | 396 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); |
397 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini
tializeImplOnImplThread, &completion, handler.release())); | 397 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eImplOnImplThread, &completion, handler.release())); |
398 completion.wait(); | 398 completion.wait(); |
399 | 399 |
400 m_started = true; | 400 m_started = true; |
401 } | 401 } |
402 | 402 |
403 void CCThreadProxy::stop() | 403 void ThreadProxy::stop() |
404 { | 404 { |
405 TRACE_EVENT0("cc", "CCThreadProxy::stop"); | 405 TRACE_EVENT0("cc", "ThreadProxy::stop"); |
406 ASSERT(isMainThread()); | 406 ASSERT(isMainThread()); |
407 ASSERT(m_started); | 407 ASSERT(m_started); |
408 | 408 |
409 // Synchronously deletes the impl. | 409 // Synchronously deletes the impl. |
410 { | 410 { |
411 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 411 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
412 | 412 |
413 CCCompletionEvent completion; | 413 CompletionEvent completion; |
414 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:layerTreeHostClosedOnImplThread, &completion)); | 414 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::layer
TreeHostClosedOnImplThread, &completion)); |
415 completion.wait(); | 415 completion.wait(); |
416 } | 416 } |
417 | 417 |
418 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. | 418 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. |
419 | 419 |
420 ASSERT(!m_layerTreeHostImpl.get()); // verify that the impl deleted. | 420 ASSERT(!m_layerTreeHostImpl.get()); // verify that the impl deleted. |
421 m_layerTreeHost = 0; | 421 m_layerTreeHost = 0; |
422 m_started = false; | 422 m_started = false; |
423 } | 423 } |
424 | 424 |
425 void CCThreadProxy::forceSerializeOnSwapBuffers() | 425 void ThreadProxy::forceSerializeOnSwapBuffers() |
426 { | 426 { |
427 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 427 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
428 CCCompletionEvent completion; | 428 CompletionEvent completion; |
429 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for
ceSerializeOnSwapBuffersOnImplThread, &completion)); | 429 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::forceSeri
alizeOnSwapBuffersOnImplThread, &completion)); |
430 completion.wait(); | 430 completion.wait(); |
431 } | 431 } |
432 | 432 |
433 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c
ompletion) | 433 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl
etion) |
434 { | 434 { |
435 if (m_rendererInitialized) | 435 if (m_rendererInitialized) |
436 m_layerTreeHostImpl->renderer()->doNoOp(); | 436 m_layerTreeHostImpl->renderer()->doNoOp(); |
437 completion->signal(); | 437 completion->signal(); |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion
) | 441 void ThreadProxy::finishAllRenderingOnImplThread(CompletionEvent* completion) |
442 { | 442 { |
443 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread"); | 443 TRACE_EVENT0("cc", "ThreadProxy::finishAllRenderingOnImplThread"); |
444 ASSERT(isImplThread()); | 444 ASSERT(isImplThread()); |
445 m_layerTreeHostImpl->finishAllRendering(); | 445 m_layerTreeHostImpl->finishAllRendering(); |
446 completion->signal(); | 446 completion->signal(); |
447 } | 447 } |
448 | 448 |
449 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion) | 449 void ThreadProxy::forceBeginFrameOnImplThread(CompletionEvent* completion) |
450 { | 450 { |
451 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread"); | 451 TRACE_EVENT0("cc", "ThreadProxy::forceBeginFrameOnImplThread"); |
452 ASSERT(!m_beginFrameCompletionEventOnImplThread); | 452 ASSERT(!m_beginFrameCompletionEventOnImplThread); |
453 | 453 |
454 if (m_schedulerOnImplThread->commitPending()) { | 454 if (m_schedulerOnImplThread->commitPending()) { |
455 completion->signal(); | 455 completion->signal(); |
456 return; | 456 return; |
457 } | 457 } |
458 | 458 |
459 m_beginFrameCompletionEventOnImplThread = completion; | 459 m_beginFrameCompletionEventOnImplThread = completion; |
460 setNeedsForcedCommitOnImplThread(); | 460 setNeedsForcedCommitOnImplThread(); |
461 } | 461 } |
462 | 462 |
463 void CCThreadProxy::scheduledActionBeginFrame() | 463 void ThreadProxy::scheduledActionBeginFrame() |
464 { | 464 { |
465 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); | 465 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); |
466 ASSERT(!m_pendingBeginFrameRequest); | 466 ASSERT(!m_pendingBeginFrameRequest); |
467 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; | 467 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; |
468 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); | 468 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); |
469 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); | 469 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); |
470 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); | 470 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); |
471 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); | 471 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); |
472 if (m_layerTreeHost->contentsTextureManager()) | 472 if (m_layerTreeHost->contentsTextureManager()) |
473 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); | 473 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); |
474 | 474 |
475 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); | 475 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFrame)
); |
476 | 476 |
477 if (m_beginFrameCompletionEventOnImplThread) { | 477 if (m_beginFrameCompletionEventOnImplThread) { |
478 m_beginFrameCompletionEventOnImplThread->signal(); | 478 m_beginFrameCompletionEventOnImplThread->signal(); |
479 m_beginFrameCompletionEventOnImplThread = 0; | 479 m_beginFrameCompletionEventOnImplThread = 0; |
480 } | 480 } |
481 } | 481 } |
482 | 482 |
483 void CCThreadProxy::beginFrame() | 483 void ThreadProxy::beginFrame() |
484 { | 484 { |
485 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); | 485 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); |
486 ASSERT(isMainThread()); | 486 ASSERT(isMainThread()); |
487 if (!m_layerTreeHost) | 487 if (!m_layerTreeHost) |
488 return; | 488 return; |
489 | 489 |
490 if (!m_pendingBeginFrameRequest) { | 490 if (!m_pendingBeginFrameRequest) { |
491 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); | 491 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
492 return; | 492 return; |
493 } | 493 } |
494 | 494 |
495 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) | 495 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) |
(...skipping 18 matching lines...) Expand all Loading... |
514 // Re-do the commit flow so that we don't send the scrollInfo on the BFAC me
ssage. | 514 // Re-do the commit flow so that we don't send the scrollInfo on the BFAC me
ssage. |
515 m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); | 515 m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); |
516 m_layerTreeHost->setImplTransform(request->implTransform); | 516 m_layerTreeHost->setImplTransform(request->implTransform); |
517 | 517 |
518 if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { | 518 if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { |
519 m_commitRequested = false; | 519 m_commitRequested = false; |
520 m_commitRequestSentToImplThread = false; | 520 m_commitRequestSentToImplThread = false; |
521 m_forcedCommitRequested = false; | 521 m_forcedCommitRequested = false; |
522 | 522 |
523 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); | 523 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
524 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameAbortedOnImplThread)); | 524 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameAbortedOnImplThread)); |
525 return; | 525 return; |
526 } | 526 } |
527 | 527 |
528 m_layerTreeHost->willBeginFrame(); | 528 m_layerTreeHost->willBeginFrame(); |
529 | 529 |
530 m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); | 530 m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); |
531 m_layerTreeHost->layout(); | 531 m_layerTreeHost->layout(); |
532 | 532 |
533 // Clear the commit flag after updating animations and layout here --- objec
ts that only | 533 // Clear the commit flag after updating animations and layout here --- objec
ts that only |
534 // layout when painted will trigger another setNeedsCommit inside | 534 // layout when painted will trigger another setNeedsCommit inside |
535 // updateLayers. | 535 // updateLayers. |
536 m_commitRequested = false; | 536 m_commitRequested = false; |
537 m_commitRequestSentToImplThread = false; | 537 m_commitRequestSentToImplThread = false; |
538 m_forcedCommitRequested = false; | 538 m_forcedCommitRequested = false; |
539 | 539 |
540 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 540 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
541 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); | 541 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
542 return; | 542 return; |
543 } | 543 } |
544 | 544 |
545 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->ev
ictedContentsTexturesBackings); | 545 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->ev
ictedContentsTexturesBackings); |
546 | 546 |
547 scoped_ptr<CCTextureUpdateQueue> queue = make_scoped_ptr(new CCTextureUpdate
Queue); | 547 scoped_ptr<TextureUpdateQueue> queue = make_scoped_ptr(new TextureUpdateQueu
e); |
548 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); | 548 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); |
549 | 549 |
550 // Once single buffered layers are committed, they cannot be modified until | 550 // Once single buffered layers are committed, they cannot be modified until |
551 // they are drawn by the impl thread. | 551 // they are drawn by the impl thread. |
552 m_texturesAcquired = false; | 552 m_texturesAcquired = false; |
553 | 553 |
554 m_layerTreeHost->willCommit(); | 554 m_layerTreeHost->willCommit(); |
555 // Before applying scrolls and calling animate, we set m_animateRequested to | 555 // Before applying scrolls and calling animate, we set m_animateRequested to |
556 // false. If it is true now, it means setNeedAnimate was called again, but | 556 // false. If it is true now, it means setNeedAnimate was called again, but |
557 // during a state when m_commitRequestSentToImplThread = true. We need to | 557 // during a state when m_commitRequestSentToImplThread = true. We need to |
558 // force that call to happen again now so that the commit request is sent to | 558 // force that call to happen again now so that the commit request is sent to |
559 // the impl thread. | 559 // the impl thread. |
560 if (m_animateRequested) { | 560 if (m_animateRequested) { |
561 // Forces setNeedsAnimate to consider posting a commit task. | 561 // Forces setNeedsAnimate to consider posting a commit task. |
562 m_animateRequested = false; | 562 m_animateRequested = false; |
563 setNeedsAnimate(); | 563 setNeedsAnimate(); |
564 } | 564 } |
565 | 565 |
566 // Notify the impl thread that the beginFrame has completed. This will | 566 // Notify the impl thread that the beginFrame has completed. This will |
567 // begin the commit process, which is blocking from the main thread's | 567 // begin the commit process, which is blocking from the main thread's |
568 // point of view, but asynchronously performed on the impl thread, | 568 // point of view, but asynchronously performed on the impl thread, |
569 // coordinated by the CCScheduler. | 569 // coordinated by the Scheduler. |
570 { | 570 { |
571 TRACE_EVENT0("cc", "commit"); | 571 TRACE_EVENT0("cc", "commit"); |
572 | 572 |
573 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 573 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
574 | 574 |
575 base::TimeTicks startTime = base::TimeTicks::HighResNow(); | 575 base::TimeTicks startTime = base::TimeTicks::HighResNow(); |
576 CCCompletionEvent completion; | 576 CompletionEvent completion; |
577 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameCompleteOnImplThread, &completion, queue.release())); | 577 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameCompleteOnImplThread, &completion, queue.release())); |
578 completion.wait(); | 578 completion.wait(); |
579 base::TimeTicks endTime = base::TimeTicks::HighResNow(); | 579 base::TimeTicks endTime = base::TimeTicks::HighResNow(); |
580 | 580 |
581 m_totalCommitTime += endTime - startTime; | 581 m_totalCommitTime += endTime - startTime; |
582 m_totalCommitCount++; | 582 m_totalCommitCount++; |
583 } | 583 } |
584 | 584 |
585 m_layerTreeHost->commitComplete(); | 585 m_layerTreeHost->commitComplete(); |
586 m_layerTreeHost->didBeginFrame(); | 586 m_layerTreeHost->didBeginFrame(); |
587 } | 587 } |
588 | 588 |
589 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, CCTextureUpdateQueue* rawQueue) | 589 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Te
xtureUpdateQueue* rawQueue) |
590 { | 590 { |
591 scoped_ptr<CCTextureUpdateQueue> queue(rawQueue); | 591 scoped_ptr<TextureUpdateQueue> queue(rawQueue); |
592 | 592 |
593 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); | 593 TRACE_EVENT0("cc", "ThreadProxy::beginFrameCompleteOnImplThread"); |
594 ASSERT(!m_commitCompletionEventOnImplThread); | 594 ASSERT(!m_commitCompletionEventOnImplThread); |
595 ASSERT(isImplThread() && isMainThreadBlocked()); | 595 ASSERT(isImplThread() && isMainThreadBlocked()); |
596 ASSERT(m_schedulerOnImplThread); | 596 ASSERT(m_schedulerOnImplThread); |
597 ASSERT(m_schedulerOnImplThread->commitPending()); | 597 ASSERT(m_schedulerOnImplThread->commitPending()); |
598 | 598 |
599 if (!m_layerTreeHostImpl.get()) { | 599 if (!m_layerTreeHostImpl.get()) { |
600 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 600 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
601 completion->signal(); | 601 completion->signal(); |
602 return; | 602 return; |
603 } | 603 } |
604 | 604 |
605 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ | 605 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ |
606 // Clear any uploads we were making to textures linked to evicted | 606 // Clear any uploads we were making to textures linked to evicted |
607 // resources | 607 // resources |
608 queue->clearUploadsToEvictedResources(); | 608 queue->clearUploadsToEvictedResources(); |
609 // Some textures in the layer tree are invalid. Kick off another commit | 609 // Some textures in the layer tree are invalid. Kick off another commit |
610 // to fill them again. | 610 // to fill them again. |
611 setNeedsCommitOnImplThread(); | 611 setNeedsCommitOnImplThread(); |
612 } | 612 } |
613 | 613 |
614 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; | 614 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
615 | 615 |
616 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourcePro
vider(), m_layerTreeHostImpl->resourceProvider()->textureUploader()); | 616 m_currentTextureUpdateControllerOnImplThread = TextureUpdateController::crea
te(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvide
r(), m_layerTreeHostImpl->resourceProvider()->textureUploader()); |
617 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( | 617 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( |
618 m_schedulerOnImplThread->anticipatedDrawTime()); | 618 m_schedulerOnImplThread->anticipatedDrawTime()); |
619 | 619 |
620 m_commitCompletionEventOnImplThread = completion; | 620 m_commitCompletionEventOnImplThread = completion; |
621 } | 621 } |
622 | 622 |
623 void CCThreadProxy::beginFrameAbortedOnImplThread() | 623 void ThreadProxy::beginFrameAbortedOnImplThread() |
624 { | 624 { |
625 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); | 625 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); |
626 ASSERT(isImplThread()); | 626 ASSERT(isImplThread()); |
627 ASSERT(m_schedulerOnImplThread); | 627 ASSERT(m_schedulerOnImplThread); |
628 ASSERT(m_schedulerOnImplThread->commitPending()); | 628 ASSERT(m_schedulerOnImplThread->commitPending()); |
629 | 629 |
630 m_schedulerOnImplThread->beginFrameAborted(); | 630 m_schedulerOnImplThread->beginFrameAborted(); |
631 } | 631 } |
632 | 632 |
633 void CCThreadProxy::scheduledActionCommit() | 633 void ThreadProxy::scheduledActionCommit() |
634 { | 634 { |
635 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); | 635 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); |
636 ASSERT(isImplThread()); | 636 ASSERT(isImplThread()); |
637 ASSERT(m_commitCompletionEventOnImplThread); | 637 ASSERT(m_commitCompletionEventOnImplThread); |
638 ASSERT(m_currentTextureUpdateControllerOnImplThread); | 638 ASSERT(m_currentTextureUpdateControllerOnImplThread); |
639 | 639 |
640 // Complete all remaining texture updates. | 640 // Complete all remaining texture updates. |
641 m_currentTextureUpdateControllerOnImplThread->finalize(); | 641 m_currentTextureUpdateControllerOnImplThread->finalize(); |
642 m_currentTextureUpdateControllerOnImplThread.reset(); | 642 m_currentTextureUpdateControllerOnImplThread.reset(); |
643 | 643 |
644 // If there are linked evicted backings, these backings' resources may be pu
t into the | 644 // If there are linked evicted backings, these backings' resources may be pu
t into the |
645 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. | 645 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. |
(...skipping 12 matching lines...) Expand all Loading... |
658 | 658 |
659 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; | 659 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; |
660 | 660 |
661 m_commitCompletionEventOnImplThread->signal(); | 661 m_commitCompletionEventOnImplThread->signal(); |
662 m_commitCompletionEventOnImplThread = 0; | 662 m_commitCompletionEventOnImplThread = 0; |
663 | 663 |
664 // SetVisible kicks off the next scheduler action, so this must be last. | 664 // SetVisible kicks off the next scheduler action, so this must be last. |
665 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 665 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
666 } | 666 } |
667 | 667 |
668 void CCThreadProxy::scheduledActionBeginContextRecreation() | 668 void ThreadProxy::scheduledActionBeginContextRecreation() |
669 { | 669 { |
670 ASSERT(isImplThread()); | 670 ASSERT(isImplThread()); |
671 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo
ntextRecreation)); | 671 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginContex
tRecreation)); |
672 } | 672 } |
673 | 673 |
674 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte
rnal(bool forcedDraw) | 674 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal
(bool forcedDraw) |
675 { | 675 { |
676 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap"); | 676 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionDrawAndSwap"); |
677 CCScheduledActionDrawAndSwapResult result; | 677 ScheduledActionDrawAndSwapResult result; |
678 result.didDraw = false; | 678 result.didDraw = false; |
679 result.didSwap = false; | 679 result.didSwap = false; |
680 ASSERT(isImplThread()); | 680 ASSERT(isImplThread()); |
681 ASSERT(m_layerTreeHostImpl.get()); | 681 ASSERT(m_layerTreeHostImpl.get()); |
682 if (!m_layerTreeHostImpl.get()) | 682 if (!m_layerTreeHostImpl.get()) |
683 return result; | 683 return result; |
684 | 684 |
685 ASSERT(m_layerTreeHostImpl->renderer()); | 685 ASSERT(m_layerTreeHostImpl->renderer()); |
686 if (!m_layerTreeHostImpl->renderer()) | 686 if (!m_layerTreeHostImpl->renderer()) |
687 return result; | 687 return result; |
688 | 688 |
689 // FIXME: compute the frame display time more intelligently | 689 // FIXME: compute the frame display time more intelligently |
690 double monotonicTime = monotonicallyIncreasingTime(); | 690 double monotonicTime = monotonicallyIncreasingTime(); |
691 double wallClockTime = currentTime(); | 691 double wallClockTime = currentTime(); |
692 | 692 |
693 if (m_inputHandlerOnImplThread.get()) | 693 if (m_inputHandlerOnImplThread.get()) |
694 m_inputHandlerOnImplThread->animate(monotonicTime); | 694 m_inputHandlerOnImplThread->animate(monotonicTime); |
695 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); | 695 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); |
696 | 696 |
697 // This method is called on a forced draw, regardless of whether we are able
to produce a frame, | 697 // This method is called on a forced draw, regardless of whether we are able
to produce a frame, |
698 // as the calling site on main thread is blocked until its request completes
, and we signal | 698 // as the calling site on main thread is blocked until its request completes
, and we signal |
699 // completion here. If canDraw() is false, we will indicate success=false to
the caller, but we | 699 // completion here. If canDraw() is false, we will indicate success=false to
the caller, but we |
700 // must still signal completion to avoid deadlock. | 700 // must still signal completion to avoid deadlock. |
701 | 701 |
702 // We guard prepareToDraw() with canDraw() because it always returns a valid
frame, so can only | 702 // We guard prepareToDraw() with canDraw() because it always returns a valid
frame, so can only |
703 // be used when such a frame is possible. Since drawLayers() depends on the
result of | 703 // be used when such a frame is possible. Since drawLayers() depends on the
result of |
704 // prepareToDraw(), it is guarded on canDraw() as well. | 704 // prepareToDraw(), it is guarded on canDraw() as well. |
705 | 705 |
706 CCLayerTreeHostImpl::FrameData frame; | 706 LayerTreeHostImpl::FrameData frame; |
707 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre
pareToDraw(frame) || forcedDraw); | 707 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre
pareToDraw(frame) || forcedDraw); |
708 if (drawFrame) { | 708 if (drawFrame) { |
709 m_layerTreeHostImpl->drawLayers(frame); | 709 m_layerTreeHostImpl->drawLayers(frame); |
710 result.didDraw = true; | 710 result.didDraw = true; |
711 } | 711 } |
712 m_layerTreeHostImpl->didDrawAllLayers(frame); | 712 m_layerTreeHostImpl->didDrawAllLayers(frame); |
713 | 713 |
714 // Check for a pending compositeAndReadback. | 714 // Check for a pending compositeAndReadback. |
715 if (m_readbackRequestOnImplThread) { | 715 if (m_readbackRequestOnImplThread) { |
716 m_readbackRequestOnImplThread->success = false; | 716 m_readbackRequestOnImplThread->success = false; |
717 if (drawFrame) { | 717 if (drawFrame) { |
718 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels,
m_readbackRequestOnImplThread->rect); | 718 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels,
m_readbackRequestOnImplThread->rect); |
719 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon
textLost(); | 719 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon
textLost(); |
720 } | 720 } |
721 m_readbackRequestOnImplThread->completion.signal(); | 721 m_readbackRequestOnImplThread->completion.signal(); |
722 m_readbackRequestOnImplThread = 0; | 722 m_readbackRequestOnImplThread = 0; |
723 } else if (drawFrame) | 723 } else if (drawFrame) |
724 result.didSwap = m_layerTreeHostImpl->swapBuffers(); | 724 result.didSwap = m_layerTreeHostImpl->swapBuffers(); |
725 | 725 |
726 // Tell the main thread that the the newly-commited frame was drawn. | 726 // Tell the main thread that the the newly-commited frame was drawn. |
727 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { | 727 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { |
728 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; | 728 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; |
729 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::did
CommitAndDrawFrame)); | 729 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComm
itAndDrawFrame)); |
730 } | 730 } |
731 | 731 |
732 return result; | 732 return result; |
733 } | 733 } |
734 | 734 |
735 void CCThreadProxy::acquireLayerTextures() | 735 void ThreadProxy::acquireLayerTextures() |
736 { | 736 { |
737 // Called when the main thread needs to modify a layer texture that is used | 737 // Called when the main thread needs to modify a layer texture that is used |
738 // directly by the compositor. | 738 // directly by the compositor. |
739 // This method will block until the next compositor draw if there is a | 739 // This method will block until the next compositor draw if there is a |
740 // previously committed frame that is still undrawn. This is necessary to | 740 // previously committed frame that is still undrawn. This is necessary to |
741 // ensure that the main thread does not monopolize access to the textures. | 741 // ensure that the main thread does not monopolize access to the textures. |
742 ASSERT(isMainThread()); | 742 ASSERT(isMainThread()); |
743 | 743 |
744 if (m_texturesAcquired) | 744 if (m_texturesAcquired) |
745 return; | 745 return; |
746 | 746 |
747 TRACE_EVENT0("cc", "CCThreadProxy::acquireLayerTextures"); | 747 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); |
748 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 748 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
749 CCCompletionEvent completion; | 749 CompletionEvent completion; |
750 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq
uireLayerTexturesForMainThreadOnImplThread, &completion)); | 750 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::acquireLa
yerTexturesForMainThreadOnImplThread, &completion)); |
751 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. | 751 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. |
752 | 752 |
753 m_texturesAcquired = true; | 753 m_texturesAcquired = true; |
754 } | 754 } |
755 | 755 |
756 void CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv
ent* completion) | 756 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*
completion) |
757 { | 757 { |
758 ASSERT(isImplThread()); | 758 ASSERT(isImplThread()); |
759 ASSERT(!m_textureAcquisitionCompletionEventOnImplThread); | 759 ASSERT(!m_textureAcquisitionCompletionEventOnImplThread); |
760 | 760 |
761 m_textureAcquisitionCompletionEventOnImplThread = completion; | 761 m_textureAcquisitionCompletionEventOnImplThread = completion; |
762 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures(); | 762 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures(); |
763 } | 763 } |
764 | 764 |
765 void CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread() | 765 void ThreadProxy::scheduledActionAcquireLayerTexturesForMainThread() |
766 { | 766 { |
767 ASSERT(m_textureAcquisitionCompletionEventOnImplThread); | 767 ASSERT(m_textureAcquisitionCompletionEventOnImplThread); |
768 m_textureAcquisitionCompletionEventOnImplThread->signal(); | 768 m_textureAcquisitionCompletionEventOnImplThread->signal(); |
769 m_textureAcquisitionCompletionEventOnImplThread = 0; | 769 m_textureAcquisitionCompletionEventOnImplThread = 0; |
770 } | 770 } |
771 | 771 |
772 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo
ssible() | 772 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapIfPossib
le() |
773 { | 773 { |
774 return scheduledActionDrawAndSwapInternal(false); | 774 return scheduledActionDrawAndSwapInternal(false); |
775 } | 775 } |
776 | 776 |
777 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc
ed() | 777 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapForced() |
778 { | 778 { |
779 return scheduledActionDrawAndSwapInternal(true); | 779 return scheduledActionDrawAndSwapInternal(true); |
780 } | 780 } |
781 | 781 |
782 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) | 782 void ThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) |
783 { | 783 { |
784 if (!m_currentTextureUpdateControllerOnImplThread) | 784 if (!m_currentTextureUpdateControllerOnImplThread) |
785 return; | 785 return; |
786 | 786 |
787 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); | 787 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); |
788 } | 788 } |
789 | 789 |
790 void CCThreadProxy::readyToFinalizeTextureUpdates() | 790 void ThreadProxy::readyToFinalizeTextureUpdates() |
791 { | 791 { |
792 ASSERT(isImplThread()); | 792 ASSERT(isImplThread()); |
793 m_schedulerOnImplThread->beginFrameComplete(); | 793 m_schedulerOnImplThread->beginFrameComplete(); |
794 } | 794 } |
795 | 795 |
796 void CCThreadProxy::didCommitAndDrawFrame() | 796 void ThreadProxy::didCommitAndDrawFrame() |
797 { | 797 { |
798 ASSERT(isMainThread()); | 798 ASSERT(isMainThread()); |
799 if (!m_layerTreeHost) | 799 if (!m_layerTreeHost) |
800 return; | 800 return; |
801 m_layerTreeHost->didCommitAndDrawFrame(); | 801 m_layerTreeHost->didCommitAndDrawFrame(); |
802 } | 802 } |
803 | 803 |
804 void CCThreadProxy::didCompleteSwapBuffers() | 804 void ThreadProxy::didCompleteSwapBuffers() |
805 { | 805 { |
806 ASSERT(isMainThread()); | 806 ASSERT(isMainThread()); |
807 if (!m_layerTreeHost) | 807 if (!m_layerTreeHost) |
808 return; | 808 return; |
809 m_layerTreeHost->didCompleteSwapBuffers(); | 809 m_layerTreeHost->didCompleteSwapBuffers(); |
810 } | 810 } |
811 | 811 |
812 void CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d
ouble wallClockTime) | 812 void ThreadProxy::setAnimationEvents(AnimationEventsVector* passed_events, doubl
e wallClockTime) |
813 { | 813 { |
814 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events)); | 814 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events)); |
815 | 815 |
816 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents"); | 816 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); |
817 ASSERT(isMainThread()); | 817 ASSERT(isMainThread()); |
818 if (!m_layerTreeHost) | 818 if (!m_layerTreeHost) |
819 return; | 819 return; |
820 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); | 820 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); |
821 } | 821 } |
822 | 822 |
823 class CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient { | 823 class ThreadProxyContextRecreationTimer : public Timer, TimerClient { |
824 public: | 824 public: |
825 static scoped_ptr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy*
proxy) { return make_scoped_ptr(new CCThreadProxyContextRecreationTimer(proxy))
; } | 825 static scoped_ptr<ThreadProxyContextRecreationTimer> create(ThreadProxy* pro
xy) { return make_scoped_ptr(new ThreadProxyContextRecreationTimer(proxy)); } |
826 | 826 |
827 virtual void onTimerFired() OVERRIDE | 827 virtual void onTimerFired() OVERRIDE |
828 { | 828 { |
829 m_proxy->tryToRecreateContext(); | 829 m_proxy->tryToRecreateContext(); |
830 } | 830 } |
831 | 831 |
832 private: | 832 private: |
833 explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy) | 833 explicit ThreadProxyContextRecreationTimer(ThreadProxy* proxy) |
834 : CCTimer(CCProxy::mainThread(), this) | 834 : Timer(Proxy::mainThread(), this) |
835 , m_proxy(proxy) | 835 , m_proxy(proxy) |
836 { | 836 { |
837 } | 837 } |
838 | 838 |
839 CCThreadProxy* m_proxy; | 839 ThreadProxy* m_proxy; |
840 }; | 840 }; |
841 | 841 |
842 void CCThreadProxy::beginContextRecreation() | 842 void ThreadProxy::beginContextRecreation() |
843 { | 843 { |
844 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation"); | 844 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); |
845 ASSERT(isMainThread()); | 845 ASSERT(isMainThread()); |
846 ASSERT(!m_contextRecreationTimer); | 846 ASSERT(!m_contextRecreationTimer); |
847 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this)
; | 847 m_contextRecreationTimer = ThreadProxyContextRecreationTimer::create(this); |
848 m_layerTreeHost->didLoseContext(); | 848 m_layerTreeHost->didLoseContext(); |
849 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 849 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); |
850 } | 850 } |
851 | 851 |
852 void CCThreadProxy::tryToRecreateContext() | 852 void ThreadProxy::tryToRecreateContext() |
853 { | 853 { |
854 ASSERT(isMainThread()); | 854 ASSERT(isMainThread()); |
855 ASSERT(m_layerTreeHost); | 855 ASSERT(m_layerTreeHost); |
856 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); | 856 LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); |
857 if (result == CCLayerTreeHost::RecreateFailedButTryAgain) | 857 if (result == LayerTreeHost::RecreateFailedButTryAgain) |
858 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 858 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); |
859 else if (result == CCLayerTreeHost::RecreateSucceeded) | 859 else if (result == LayerTreeHost::RecreateSucceeded) |
860 m_contextRecreationTimer.reset(); | 860 m_contextRecreationTimer.reset(); |
861 } | 861 } |
862 | 862 |
863 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC
InputHandler* handler) | 863 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
andler* handler) |
864 { | 864 { |
865 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread"); | 865 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); |
866 ASSERT(isImplThread()); | 866 ASSERT(isImplThread()); |
867 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); | 867 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); |
868 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); | 868 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); |
869 scoped_ptr<CCFrameRateController> frameRateController; | 869 scoped_ptr<FrameRateController> frameRateController; |
870 if (m_renderVSyncEnabled) | 870 if (m_renderVSyncEnabled) |
871 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour
ce::create(displayRefreshInterval, CCProxy::implThread()))); | 871 frameRateController.reset(new FrameRateController(DelayBasedTimeSource::
create(displayRefreshInterval, Proxy::implThread()))); |
872 else | 872 else |
873 frameRateController.reset(new CCFrameRateController(CCProxy::implThread(
))); | 873 frameRateController.reset(new FrameRateController(Proxy::implThread())); |
874 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass
()); | 874 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass()
); |
875 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 875 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
876 | 876 |
877 m_inputHandlerOnImplThread = scoped_ptr<CCInputHandler>(handler); | 877 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); |
878 if (m_inputHandlerOnImplThread.get()) | 878 if (m_inputHandlerOnImplThread.get()) |
879 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); | 879 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); |
880 | 880 |
881 completion->signal(); | 881 completion->signal(); |
882 } | 882 } |
883 | 883 |
884 void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context) | 884 void ThreadProxy::initializeContextOnImplThread(GraphicsContext* context) |
885 { | 885 { |
886 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread"); | 886 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); |
887 ASSERT(isImplThread()); | 887 ASSERT(isImplThread()); |
888 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co
ntext).Pass(); | 888 m_contextBeforeInitializationOnImplThread = scoped_ptr<GraphicsContext>(cont
ext).Pass(); |
889 } | 889 } |
890 | 890 |
891 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion
, bool* initializeSucceeded, RendererCapabilities* capabilities) | 891 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo
ol* initializeSucceeded, RendererCapabilities* capabilities) |
892 { | 892 { |
893 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread"); | 893 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); |
894 ASSERT(isImplThread()); | 894 ASSERT(isImplThread()); |
895 ASSERT(m_contextBeforeInitializationOnImplThread.get()); | 895 ASSERT(m_contextBeforeInitializationOnImplThread.get()); |
896 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); | 896 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); |
897 if (*initializeSucceeded) { | 897 if (*initializeSucceeded) { |
898 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 898 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
899 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( | 899 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( |
900 capabilities->usingSwapCompleteCallback); | 900 capabilities->usingSwapCompleteCallback); |
901 } | 901 } |
902 | 902 |
903 completion->signal(); | 903 completion->signal(); |
904 } | 904 } |
905 | 905 |
906 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio
n) | 906 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) |
907 { | 907 { |
908 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); | 908 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); |
909 ASSERT(isImplThread()); | 909 ASSERT(isImplThread()); |
910 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 910 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
911 m_inputHandlerOnImplThread.reset(); | 911 m_inputHandlerOnImplThread.reset(); |
912 m_layerTreeHostImpl.reset(); | 912 m_layerTreeHostImpl.reset(); |
913 m_schedulerOnImplThread.reset(); | 913 m_schedulerOnImplThread.reset(); |
914 completion->signal(); | 914 completion->signal(); |
915 } | 915 } |
916 | 916 |
917 void CCThreadProxy::setFullRootLayerDamageOnImplThread() | 917 void ThreadProxy::setFullRootLayerDamageOnImplThread() |
918 { | 918 { |
919 ASSERT(isImplThread()); | 919 ASSERT(isImplThread()); |
920 m_layerTreeHostImpl->setFullRootLayerDamage(); | 920 m_layerTreeHostImpl->setFullRootLayerDamage(); |
921 } | 921 } |
922 | 922 |
923 size_t CCThreadProxy::maxPartialTextureUpdates() const | 923 size_t ThreadProxy::maxPartialTextureUpdates() const |
924 { | 924 { |
925 return CCTextureUpdateController::maxPartialTextureUpdates(); | 925 return TextureUpdateController::maxPartialTextureUpdates(); |
926 } | 926 } |
927 | 927 |
928 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap
abilities) | 928 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, Graph
icsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* capabilit
ies) |
929 { | 929 { |
930 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); | 930 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); |
931 ASSERT(isImplThread()); | 931 ASSERT(isImplThread()); |
932 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 932 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
933 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<CCGr
aphicsContext>(contextPtr).Pass()); | 933 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<Grap
hicsContext>(contextPtr).Pass()); |
934 if (*recreateSucceeded) { | 934 if (*recreateSucceeded) { |
935 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 935 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
936 m_schedulerOnImplThread->didRecreateContext(); | 936 m_schedulerOnImplThread->didRecreateContext(); |
937 } | 937 } |
938 completion->signal(); | 938 completion->signal(); |
939 } | 939 } |
940 | 940 |
941 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC
RenderingStats* stats) | 941 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) |
942 { | 942 { |
943 ASSERT(isImplThread()); | 943 ASSERT(isImplThread()); |
944 m_layerTreeHostImpl->renderingStats(stats); | 944 m_layerTreeHostImpl->renderingStats(stats); |
945 completion->signal(); | 945 completion->signal(); |
946 } | 946 } |
947 | 947 |
948 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 948 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
949 : monotonicFrameBeginTime(0) | 949 : monotonicFrameBeginTime(0) |
950 { | 950 { |
951 } | 951 } |
952 | 952 |
953 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 953 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
954 { | 954 { |
955 } | 955 } |
956 | 956 |
957 } // namespace cc | 957 } // namespace cc |
OLD | NEW |