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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
10 #include "cc/delay_based_time_source.h" | 11 #include "cc/delay_based_time_source.h" |
11 #include "cc/draw_quad.h" | 12 #include "cc/draw_quad.h" |
12 #include "cc/frame_rate_controller.h" | 13 #include "cc/frame_rate_controller.h" |
13 #include "cc/graphics_context.h" | 14 #include "cc/graphics_context.h" |
14 #include "cc/input_handler.h" | 15 #include "cc/input_handler.h" |
15 #include "cc/layer_tree_host.h" | 16 #include "cc/layer_tree_host.h" |
16 #include "cc/scheduler.h" | 17 #include "cc/scheduler.h" |
17 #include "cc/scoped_thread_proxy.h" | 18 #include "cc/scoped_thread_proxy.h" |
18 #include "cc/thread_task.h" | |
19 #include <public/WebSharedGraphicsContext3D.h> | 19 #include <public/WebSharedGraphicsContext3D.h> |
20 | 20 |
21 using WebKit::WebSharedGraphicsContext3D; | 21 using WebKit::WebSharedGraphicsContext3D; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Measured in seconds. | 25 // Measured in seconds. |
26 const double contextRecreationTickRate = 0.03; | 26 const double contextRecreationTickRate = 0.03; |
27 | 27 |
28 } // namespace | 28 } // namespace |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 76 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
77 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 77 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
78 return false; | 78 return false; |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 // Perform a synchronous commit. | 82 // Perform a synchronous commit. |
83 { | 83 { |
84 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 84 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
85 CompletionEvent beginFrameCompletion; | 85 CompletionEvent beginFrameCompletion; |
86 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::force
BeginFrameOnImplThread, &beginFrameCompletion)); | 86 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceBeginFrameOn
ImplThread, base::Unretained(this), &beginFrameCompletion)); |
87 beginFrameCompletion.wait(); | 87 beginFrameCompletion.wait(); |
88 } | 88 } |
89 m_inCompositeAndReadback = true; | 89 m_inCompositeAndReadback = true; |
90 beginFrame(); | 90 beginFrame(); |
91 m_inCompositeAndReadback = false; | 91 m_inCompositeAndReadback = false; |
92 | 92 |
93 // Perform a synchronous readback. | 93 // Perform a synchronous readback. |
94 ReadbackRequest request; | 94 ReadbackRequest request; |
95 request.rect = rect; | 95 request.rect = rect; |
96 request.pixels = pixels; | 96 request.pixels = pixels; |
97 { | 97 { |
98 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 98 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
99 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::reque
stReadbackOnImplThread, &request)); | 99 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestReadbackOn
ImplThread, base::Unretained(this), &request)); |
100 request.completion.wait(); | 100 request.completion.wait(); |
101 } | 101 } |
102 return request.success; | 102 return request.success; |
103 } | 103 } |
104 | 104 |
105 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) | 105 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) |
106 { | 106 { |
107 DCHECK(Proxy::isImplThread()); | 107 DCHECK(Proxy::isImplThread()); |
108 DCHECK(!m_readbackRequestOnImplThread); | 108 DCHECK(!m_readbackRequestOnImplThread); |
109 if (!m_layerTreeHostImpl.get()) { | 109 if (!m_layerTreeHostImpl.get()) { |
110 request->success = false; | 110 request->success = false; |
111 request->completion.signal(); | 111 request->completion.signal(); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 m_readbackRequestOnImplThread = request; | 115 m_readbackRequestOnImplThread = request; |
116 m_schedulerOnImplThread->setNeedsRedraw(); | 116 m_schedulerOnImplThread->setNeedsRedraw(); |
117 m_schedulerOnImplThread->setNeedsForcedRedraw(); | 117 m_schedulerOnImplThread->setNeedsForcedRedraw(); |
118 } | 118 } |
119 | 119 |
120 void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool us
eAnchor, float scale, base::TimeDelta duration) | 120 void ThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool us
eAnchor, float scale, base::TimeDelta duration) |
121 { | 121 { |
122 DCHECK(Proxy::isMainThread()); | 122 DCHECK(Proxy::isMainThread()); |
123 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::requestSt
artPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, duration)); | 123 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScale
AnimationOnImplThread, base::Unretained(this), targetPosition, useAnchor, scale,
duration)); |
124 } | 124 } |
125 | 125 |
126 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit
ion, bool useAnchor, float scale, base::TimeDelta duration) | 126 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit
ion, bool useAnchor, float scale, base::TimeDelta duration) |
127 { | 127 { |
128 DCHECK(Proxy::isImplThread()); | 128 DCHECK(Proxy::isImplThread()); |
129 if (m_layerTreeHostImpl.get()) | 129 if (m_layerTreeHostImpl.get()) |
130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, base::TimeTicks::Now(), duration); | 130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, base::TimeTicks::Now(), duration); |
131 } | 131 } |
132 | 132 |
133 void ThreadProxy::finishAllRendering() | 133 void ThreadProxy::finishAllRendering() |
134 { | 134 { |
135 DCHECK(Proxy::isMainThread()); | 135 DCHECK(Proxy::isMainThread()); |
136 DCHECK(!m_deferCommits); | 136 DCHECK(!m_deferCommits); |
137 | 137 |
138 // Make sure all GL drawing is finished on the impl thread. | 138 // Make sure all GL drawing is finished on the impl thread. |
139 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 139 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
140 CompletionEvent completion; | 140 CompletionEvent completion; |
141 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); | 141 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnI
mplThread, base::Unretained(this), &completion)); |
142 completion.wait(); | 142 completion.wait(); |
143 } | 143 } |
144 | 144 |
145 bool ThreadProxy::isStarted() const | 145 bool ThreadProxy::isStarted() const |
146 { | 146 { |
147 DCHECK(Proxy::isMainThread()); | 147 DCHECK(Proxy::isMainThread()); |
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(createThreadTask(this, &ThreadProxy::initializ
eContextOnImplThread, | 158 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeContextOnIm
plThread, base::Unretained(this), context.release())); |
159 context.release())); | |
160 return true; | 159 return true; |
161 } | 160 } |
162 | 161 |
163 void ThreadProxy::setSurfaceReady() | 162 void ThreadProxy::setSurfaceReady() |
164 { | 163 { |
165 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); | 164 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); |
166 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setSurfac
eReadyOnImplThread)); | 165 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setSurfaceReadyOnImpl
Thread, base::Unretained(this))); |
167 } | 166 } |
168 | 167 |
169 void ThreadProxy::setSurfaceReadyOnImplThread() | 168 void ThreadProxy::setSurfaceReadyOnImplThread() |
170 { | 169 { |
171 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); | 170 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); |
172 m_schedulerOnImplThread->setCanBeginFrame(true); | 171 m_schedulerOnImplThread->setCanBeginFrame(true); |
173 } | 172 } |
174 | 173 |
175 void ThreadProxy::setVisible(bool visible) | 174 void ThreadProxy::setVisible(bool visible) |
176 { | 175 { |
177 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); | 176 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); |
178 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 177 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
179 CompletionEvent completion; | 178 CompletionEvent completion; |
180 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setVisibl
eOnImplThread, &completion, visible)); | 179 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThrea
d, base::Unretained(this), &completion, visible)); |
181 completion.wait(); | 180 completion.wait(); |
182 } | 181 } |
183 | 182 |
184 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib
le) | 183 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib
le) |
185 { | 184 { |
186 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); | 185 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); |
187 m_layerTreeHostImpl->setVisible(visible); | 186 m_layerTreeHostImpl->setVisible(visible); |
188 m_schedulerOnImplThread->setVisible(visible); | 187 m_schedulerOnImplThread->setVisible(visible); |
189 completion->signal(); | 188 completion->signal(); |
190 } | 189 } |
191 | 190 |
192 bool ThreadProxy::initializeRenderer() | 191 bool ThreadProxy::initializeRenderer() |
193 { | 192 { |
194 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); | 193 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); |
195 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call | 194 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call |
196 // are pushed into the initializeSucceeded and capabilities local variables. | 195 // are pushed into the initializeSucceeded and capabilities local variables. |
197 CompletionEvent completion; | 196 CompletionEvent completion; |
198 bool initializeSucceeded = false; | 197 bool initializeSucceeded = false; |
199 RendererCapabilities capabilities; | 198 RendererCapabilities capabilities; |
200 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 199 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
201 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eRendererOnImplThread, | 200 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeRendererOnI
mplThread, |
202 &completion, | 201 base::Unretained(this), |
203 &initializeSucceeded, | 202 &completion, |
204 &capabilities)); | 203 &initializeSucceeded, |
| 204 &capabilities)); |
205 completion.wait(); | 205 completion.wait(); |
206 | 206 |
207 if (initializeSucceeded) { | 207 if (initializeSucceeded) { |
208 m_rendererInitialized = true; | 208 m_rendererInitialized = true; |
209 m_RendererCapabilitiesMainThreadCopy = capabilities; | 209 m_RendererCapabilitiesMainThreadCopy = capabilities; |
210 } | 210 } |
211 return initializeSucceeded; | 211 return initializeSucceeded; |
212 } | 212 } |
213 | 213 |
214 bool ThreadProxy::recreateContext() | 214 bool ThreadProxy::recreateContext() |
215 { | 215 { |
216 TRACE_EVENT0("cc", "ThreadProxy::recreateContext"); | 216 TRACE_EVENT0("cc", "ThreadProxy::recreateContext"); |
217 DCHECK(isMainThread()); | 217 DCHECK(isMainThread()); |
218 | 218 |
219 // Try to create the context. | 219 // Try to create the context. |
220 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); | 220 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); |
221 if (!context.get()) | 221 if (!context.get()) |
222 return false; | 222 return false; |
223 if (m_layerTreeHost->needsSharedContext()) | 223 if (m_layerTreeHost->needsSharedContext()) |
224 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) | 224 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) |
225 return false; | 225 return false; |
226 | 226 |
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(createThreadTask(this, &ThreadProxy::recreateC
ontextOnImplThread, | 234 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl
Thread, |
235 &completion, | 235 base::Unretained(this), |
236 context.release(), | 236 &completion, |
237 &recreateSucceeded, | 237 context.release(), |
238 &capabilities)); | 238 &recreateSucceeded, |
| 239 &capabilities)); |
239 completion.wait(); | 240 completion.wait(); |
240 | 241 |
241 if (recreateSucceeded) | 242 if (recreateSucceeded) |
242 m_RendererCapabilitiesMainThreadCopy = capabilities; | 243 m_RendererCapabilitiesMainThreadCopy = capabilities; |
243 return recreateSucceeded; | 244 return recreateSucceeded; |
244 } | 245 } |
245 | 246 |
246 void ThreadProxy::renderingStats(RenderingStats* stats) | 247 void ThreadProxy::renderingStats(RenderingStats* stats) |
247 { | 248 { |
248 DCHECK(isMainThread()); | 249 DCHECK(isMainThread()); |
249 | 250 |
250 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 251 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
251 CompletionEvent completion; | 252 CompletionEvent completion; |
252 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::rendering
StatsOnImplThread, | 253 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT
hread, |
253 &completion, | 254 base::Unretained(this), &completio
n, stats)); |
254 stats)); | |
255 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); | 255 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); |
256 stats->totalCommitCount = m_totalCommitCount; | 256 stats->totalCommitCount = m_totalCommitCount; |
257 | 257 |
258 completion.wait(); | 258 completion.wait(); |
259 } | 259 } |
260 | 260 |
261 const RendererCapabilities& ThreadProxy::rendererCapabilities() const | 261 const RendererCapabilities& ThreadProxy::rendererCapabilities() const |
262 { | 262 { |
263 DCHECK(m_rendererInitialized); | 263 DCHECK(m_rendererInitialized); |
264 return m_RendererCapabilitiesMainThreadCopy; | 264 return m_RendererCapabilitiesMainThreadCopy; |
265 } | 265 } |
266 | 266 |
267 void ThreadProxy::loseContext() | 267 void ThreadProxy::loseContext() |
268 { | 268 { |
269 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::didLoseCo
ntextOnImplThread)); | 269 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseContextOnImplT
hread, base::Unretained(this))); |
270 } | 270 } |
271 | 271 |
272 void ThreadProxy::setNeedsAnimate() | 272 void ThreadProxy::setNeedsAnimate() |
273 { | 273 { |
274 DCHECK(isMainThread()); | 274 DCHECK(isMainThread()); |
275 if (m_animateRequested) | 275 if (m_animateRequested) |
276 return; | 276 return; |
277 | 277 |
278 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); | 278 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); |
279 m_animateRequested = true; | 279 m_animateRequested = true; |
280 | 280 |
281 if (m_commitRequestSentToImplThread) | 281 if (m_commitRequestSentToImplThread) |
282 return; | 282 return; |
283 m_commitRequestSentToImplThread = true; | 283 m_commitRequestSentToImplThread = true; |
284 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsC
ommitOnImplThread)); | 284 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT
hread, base::Unretained(this))); |
285 } | 285 } |
286 | 286 |
287 void ThreadProxy::setNeedsCommit() | 287 void ThreadProxy::setNeedsCommit() |
288 { | 288 { |
289 DCHECK(isMainThread()); | 289 DCHECK(isMainThread()); |
290 if (m_commitRequested) | 290 if (m_commitRequested) |
291 return; | 291 return; |
292 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit"); | 292 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit"); |
293 m_commitRequested = true; | 293 m_commitRequested = true; |
294 | 294 |
295 if (m_commitRequestSentToImplThread) | 295 if (m_commitRequestSentToImplThread) |
296 return; | 296 return; |
297 m_commitRequestSentToImplThread = true; | 297 m_commitRequestSentToImplThread = true; |
298 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsC
ommitOnImplThread)); | 298 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT
hread, base::Unretained(this))); |
299 } | 299 } |
300 | 300 |
301 void ThreadProxy::didLoseContextOnImplThread() | 301 void ThreadProxy::didLoseContextOnImplThread() |
302 { | 302 { |
303 DCHECK(isImplThread()); | 303 DCHECK(isImplThread()); |
304 TRACE_EVENT0("cc", "ThreadProxy::didLoseContextOnImplThread"); | 304 TRACE_EVENT0("cc", "ThreadProxy::didLoseContextOnImplThread"); |
305 m_schedulerOnImplThread->didLoseContext(); | 305 m_schedulerOnImplThread->didLoseContext(); |
306 } | 306 } |
307 | 307 |
308 void ThreadProxy::onSwapBuffersCompleteOnImplThread() | 308 void ThreadProxy::onSwapBuffersCompleteOnImplThread() |
309 { | 309 { |
310 DCHECK(isImplThread()); | 310 DCHECK(isImplThread()); |
311 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); | 311 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); |
312 m_schedulerOnImplThread->didSwapBuffersComplete(); | 312 m_schedulerOnImplThread->didSwapBuffersComplete(); |
313 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComplete
SwapBuffers)); | 313 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteS
wapBuffers, base::Unretained(this))); |
314 } | 314 } |
315 | 315 |
316 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD
elta interval) | 316 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD
elta interval) |
317 { | 317 { |
318 DCHECK(isImplThread()); | 318 DCHECK(isImplThread()); |
319 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim
ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds
()); | 319 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim
ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds
()); |
320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); | 320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); |
321 } | 321 } |
322 | 322 |
323 void ThreadProxy::onCanDrawStateChanged(bool canDraw) | 323 void ThreadProxy::onCanDrawStateChanged(bool canDraw) |
(...skipping 15 matching lines...) Expand all 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(createThreadTask(this, &ThreadProxy::setAnimatio
nEvents, events.release(), wallClockTime)); | 349 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimation
Events, base::Unretained(this), events.release(), 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 22 matching lines...) Expand all Loading... |
382 m_layerTreeHostImpl->renderer()->sendManagedMemoryStats( | 382 m_layerTreeHostImpl->renderer()->sendManagedMemoryStats( |
383 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), | 383 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), |
384 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
, | 384 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
, |
385 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); | 385 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); |
386 } | 386 } |
387 | 387 |
388 void ThreadProxy::setNeedsRedraw() | 388 void ThreadProxy::setNeedsRedraw() |
389 { | 389 { |
390 DCHECK(isMainThread()); | 390 DCHECK(isMainThread()); |
391 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); | 391 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); |
392 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); | 392 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setFullRootLayerDamag
eOnImplThread, base::Unretained(this))); |
393 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); | 393 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsRedrawOnImplT
hread, base::Unretained(this))); |
394 } | 394 } |
395 | 395 |
396 void ThreadProxy::setDeferCommits(bool deferCommits) | 396 void ThreadProxy::setDeferCommits(bool deferCommits) |
397 { | 397 { |
398 DCHECK(isMainThread()); | 398 DCHECK(isMainThread()); |
399 DCHECK_NE(m_deferCommits, deferCommits); | 399 DCHECK_NE(m_deferCommits, deferCommits); |
400 m_deferCommits = deferCommits; | 400 m_deferCommits = deferCommits; |
401 | 401 |
402 if (m_deferCommits) | 402 if (m_deferCommits) |
403 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this); | 403 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this); |
404 else | 404 else |
405 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); | 405 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); |
406 | 406 |
407 if (!m_deferCommits && m_deferredCommitPending) { | 407 if (!m_deferCommits && m_deferredCommitPending) { |
408 m_deferredCommitPending = false; | 408 m_deferredCommitPending = false; |
409 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFr
ame)); | 409 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFra
me, base::Unretained(this))); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 bool ThreadProxy::commitRequested() const | 413 bool ThreadProxy::commitRequested() const |
414 { | 414 { |
415 DCHECK(isMainThread()); | 415 DCHECK(isMainThread()); |
416 return m_commitRequested; | 416 return m_commitRequested; |
417 } | 417 } |
418 | 418 |
419 void ThreadProxy::setNeedsRedrawOnImplThread() | 419 void ThreadProxy::setNeedsRedrawOnImplThread() |
420 { | 420 { |
421 DCHECK(isImplThread()); | 421 DCHECK(isImplThread()); |
422 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); | 422 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); |
423 m_schedulerOnImplThread->setNeedsRedraw(); | 423 m_schedulerOnImplThread->setNeedsRedraw(); |
424 } | 424 } |
425 | 425 |
426 void ThreadProxy::start() | 426 void ThreadProxy::start() |
427 { | 427 { |
428 DCHECK(isMainThread()); | 428 DCHECK(isMainThread()); |
429 DCHECK(Proxy::implThread()); | 429 DCHECK(Proxy::implThread()); |
430 // Create LayerTreeHostImpl. | 430 // Create LayerTreeHostImpl. |
431 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 431 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
432 CompletionEvent completion; | 432 CompletionEvent completion; |
433 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); | 433 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); |
434 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eImplOnImplThread, &completion, handler.release())); | 434 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeImplOnImplT
hread, base::Unretained(this), &completion, handler.release())); |
435 completion.wait(); | 435 completion.wait(); |
436 | 436 |
437 m_started = true; | 437 m_started = true; |
438 } | 438 } |
439 | 439 |
440 void ThreadProxy::stop() | 440 void ThreadProxy::stop() |
441 { | 441 { |
442 TRACE_EVENT0("cc", "ThreadProxy::stop"); | 442 TRACE_EVENT0("cc", "ThreadProxy::stop"); |
443 DCHECK(isMainThread()); | 443 DCHECK(isMainThread()); |
444 DCHECK(m_started); | 444 DCHECK(m_started); |
445 | 445 |
446 // Synchronously deletes the impl. | 446 // Synchronously deletes the impl. |
447 { | 447 { |
448 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 448 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
449 | 449 |
450 CompletionEvent completion; | 450 CompletionEvent completion; |
451 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::layer
TreeHostClosedOnImplThread, &completion)); | 451 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::layerTreeHostClos
edOnImplThread, base::Unretained(this), &completion)); |
452 completion.wait(); | 452 completion.wait(); |
453 } | 453 } |
454 | 454 |
455 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. | 455 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. |
456 | 456 |
457 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. | 457 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. |
458 m_layerTreeHost = 0; | 458 m_layerTreeHost = 0; |
459 m_started = false; | 459 m_started = false; |
460 } | 460 } |
461 | 461 |
462 void ThreadProxy::forceSerializeOnSwapBuffers() | 462 void ThreadProxy::forceSerializeOnSwapBuffers() |
463 { | 463 { |
464 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 464 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
465 CompletionEvent completion; | 465 CompletionEvent completion; |
466 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::forceSeri
alizeOnSwapBuffersOnImplThread, &completion)); | 466 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceSerializeOnSwapB
uffersOnImplThread, base::Unretained(this), &completion)); |
467 completion.wait(); | 467 completion.wait(); |
468 } | 468 } |
469 | 469 |
470 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl
etion) | 470 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl
etion) |
471 { | 471 { |
472 if (m_rendererInitialized) | 472 if (m_rendererInitialized) |
473 m_layerTreeHostImpl->renderer()->doNoOp(); | 473 m_layerTreeHostImpl->renderer()->doNoOp(); |
474 completion->signal(); | 474 completion->signal(); |
475 } | 475 } |
476 | 476 |
(...skipping 25 matching lines...) Expand all Loading... |
502 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); | 502 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); |
503 DCHECK(!m_pendingBeginFrameRequest); | 503 DCHECK(!m_pendingBeginFrameRequest); |
504 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; | 504 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; |
505 m_pendingBeginFrameRequest->monotonicFrameBeginTime = base::TimeTicks::Now()
; | 505 m_pendingBeginFrameRequest->monotonicFrameBeginTime = base::TimeTicks::Now()
; |
506 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); | 506 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); |
507 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); | 507 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); |
508 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); | 508 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); |
509 if (m_layerTreeHost->contentsTextureManager()) | 509 if (m_layerTreeHost->contentsTextureManager()) |
510 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); | 510 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); |
511 | 511 |
512 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFrame)
); | 512 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame,
base::Unretained(this))); |
513 | 513 |
514 if (m_beginFrameCompletionEventOnImplThread) { | 514 if (m_beginFrameCompletionEventOnImplThread) { |
515 m_beginFrameCompletionEventOnImplThread->signal(); | 515 m_beginFrameCompletionEventOnImplThread->signal(); |
516 m_beginFrameCompletionEventOnImplThread = 0; | 516 m_beginFrameCompletionEventOnImplThread = 0; |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 void ThreadProxy::beginFrame() | 520 void ThreadProxy::beginFrame() |
521 { | 521 { |
522 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); | 522 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 // Re-do the commit flow so that we don't send the scrollInfo on the BFAC me
ssage. | 558 // Re-do the commit flow so that we don't send the scrollInfo on the BFAC me
ssage. |
559 m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); | 559 m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); |
560 m_layerTreeHost->setImplTransform(request->implTransform); | 560 m_layerTreeHost->setImplTransform(request->implTransform); |
561 | 561 |
562 if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { | 562 if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { |
563 m_commitRequested = false; | 563 m_commitRequested = false; |
564 m_commitRequestSentToImplThread = false; | 564 m_commitRequestSentToImplThread = false; |
565 m_forcedCommitRequested = false; | 565 m_forcedCommitRequested = false; |
566 | 566 |
567 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); | 567 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
568 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameAbortedOnImplThread)); | 568 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameAborted
OnImplThread, base::Unretained(this))); |
569 return; | 569 return; |
570 } | 570 } |
571 | 571 |
572 m_layerTreeHost->willBeginFrame(); | 572 m_layerTreeHost->willBeginFrame(); |
573 | 573 |
574 m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); | 574 m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); |
575 m_layerTreeHost->layout(); | 575 m_layerTreeHost->layout(); |
576 | 576 |
577 // Clear the commit flag after updating animations and layout here --- objec
ts that only | 577 // Clear the commit flag after updating animations and layout here --- objec
ts that only |
578 // layout when painted will trigger another setNeedsCommit inside | 578 // layout when painted will trigger another setNeedsCommit inside |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // begin the commit process, which is blocking from the main thread's | 611 // begin the commit process, which is blocking from the main thread's |
612 // point of view, but asynchronously performed on the impl thread, | 612 // point of view, but asynchronously performed on the impl thread, |
613 // coordinated by the Scheduler. | 613 // coordinated by the Scheduler. |
614 { | 614 { |
615 TRACE_EVENT0("cc", "commit"); | 615 TRACE_EVENT0("cc", "commit"); |
616 | 616 |
617 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 617 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
618 | 618 |
619 base::TimeTicks startTime = base::TimeTicks::HighResNow(); | 619 base::TimeTicks startTime = base::TimeTicks::HighResNow(); |
620 CompletionEvent completion; | 620 CompletionEvent completion; |
621 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameCompleteOnImplThread, &completion, queue.release())); | 621 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet
eOnImplThread, base::Unretained(this), &completion, queue.release())); |
622 completion.wait(); | 622 completion.wait(); |
623 base::TimeTicks endTime = base::TimeTicks::HighResNow(); | 623 base::TimeTicks endTime = base::TimeTicks::HighResNow(); |
624 | 624 |
625 m_totalCommitTime += endTime - startTime; | 625 m_totalCommitTime += endTime - startTime; |
626 m_totalCommitCount++; | 626 m_totalCommitCount++; |
627 } | 627 } |
628 | 628 |
629 m_layerTreeHost->commitComplete(); | 629 m_layerTreeHost->commitComplete(); |
630 m_layerTreeHost->didBeginFrame(); | 630 m_layerTreeHost->didBeginFrame(); |
631 } | 631 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 m_commitCompletionEventOnImplThread->signal(); | 709 m_commitCompletionEventOnImplThread->signal(); |
710 m_commitCompletionEventOnImplThread = 0; | 710 m_commitCompletionEventOnImplThread = 0; |
711 | 711 |
712 // SetVisible kicks off the next scheduler action, so this must be last. | 712 // SetVisible kicks off the next scheduler action, so this must be last. |
713 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 713 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
714 } | 714 } |
715 | 715 |
716 void ThreadProxy::scheduledActionBeginContextRecreation() | 716 void ThreadProxy::scheduledActionBeginContextRecreation() |
717 { | 717 { |
718 DCHECK(isImplThread()); | 718 DCHECK(isImplThread()); |
719 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginContex
tRecreation)); | 719 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginContext
Recreation, base::Unretained(this))); |
720 } | 720 } |
721 | 721 |
722 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal
(bool forcedDraw) | 722 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal
(bool forcedDraw) |
723 { | 723 { |
724 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionDrawAndSwap"); | 724 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionDrawAndSwap"); |
725 ScheduledActionDrawAndSwapResult result; | 725 ScheduledActionDrawAndSwapResult result; |
726 result.didDraw = false; | 726 result.didDraw = false; |
727 result.didSwap = false; | 727 result.didSwap = false; |
728 DCHECK(isImplThread()); | 728 DCHECK(isImplThread()); |
729 DCHECK(m_layerTreeHostImpl.get()); | 729 DCHECK(m_layerTreeHostImpl.get()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon
textLost(); | 769 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon
textLost(); |
770 } | 770 } |
771 m_readbackRequestOnImplThread->completion.signal(); | 771 m_readbackRequestOnImplThread->completion.signal(); |
772 m_readbackRequestOnImplThread = 0; | 772 m_readbackRequestOnImplThread = 0; |
773 } else if (drawFrame) | 773 } else if (drawFrame) |
774 result.didSwap = m_layerTreeHostImpl->swapBuffers(); | 774 result.didSwap = m_layerTreeHostImpl->swapBuffers(); |
775 | 775 |
776 // Tell the main thread that the the newly-commited frame was drawn. | 776 // Tell the main thread that the the newly-commited frame was drawn. |
777 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { | 777 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { |
778 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; | 778 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; |
779 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::didComm
itAndDrawFrame)); | 779 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCommi
tAndDrawFrame, base::Unretained(this))); |
780 } | 780 } |
781 | 781 |
782 return result; | 782 return result; |
783 } | 783 } |
784 | 784 |
785 void ThreadProxy::acquireLayerTextures() | 785 void ThreadProxy::acquireLayerTextures() |
786 { | 786 { |
787 // Called when the main thread needs to modify a layer texture that is used | 787 // Called when the main thread needs to modify a layer texture that is used |
788 // directly by the compositor. | 788 // directly by the compositor. |
789 // This method will block until the next compositor draw if there is a | 789 // This method will block until the next compositor draw if there is a |
790 // previously committed frame that is still undrawn. This is necessary to | 790 // previously committed frame that is still undrawn. This is necessary to |
791 // ensure that the main thread does not monopolize access to the textures. | 791 // ensure that the main thread does not monopolize access to the textures. |
792 DCHECK(isMainThread()); | 792 DCHECK(isMainThread()); |
793 | 793 |
794 if (m_texturesAcquired) | 794 if (m_texturesAcquired) |
795 return; | 795 return; |
796 | 796 |
797 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); | 797 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); |
798 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 798 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
799 CompletionEvent completion; | 799 CompletionEvent completion; |
800 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::acquireLa
yerTexturesForMainThreadOnImplThread, &completion)); | 800 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::acquireLayerTexturesF
orMainThreadOnImplThread, base::Unretained(this), &completion)); |
801 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. | 801 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. |
802 | 802 |
803 m_texturesAcquired = true; | 803 m_texturesAcquired = true; |
804 } | 804 } |
805 | 805 |
806 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*
completion) | 806 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*
completion) |
807 { | 807 { |
808 DCHECK(isImplThread()); | 808 DCHECK(isImplThread()); |
809 DCHECK(!m_textureAcquisitionCompletionEventOnImplThread); | 809 DCHECK(!m_textureAcquisitionCompletionEventOnImplThread); |
810 | 810 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 { | 865 { |
866 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events)); | 866 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(passed_events)); |
867 | 867 |
868 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); | 868 TRACE_EVENT0("cc", "ThreadProxy::setAnimationEvents"); |
869 DCHECK(isMainThread()); | 869 DCHECK(isMainThread()); |
870 if (!m_layerTreeHost) | 870 if (!m_layerTreeHost) |
871 return; | 871 return; |
872 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); | 872 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); |
873 } | 873 } |
874 | 874 |
875 class ThreadProxyContextRecreationTimer : public Timer, TimerClient { | |
876 public: | |
877 static scoped_ptr<ThreadProxyContextRecreationTimer> create(ThreadProxy* pro
xy) { return make_scoped_ptr(new ThreadProxyContextRecreationTimer(proxy)); } | |
878 | |
879 virtual void onTimerFired() OVERRIDE | |
880 { | |
881 m_proxy->tryToRecreateContext(); | |
882 } | |
883 | |
884 private: | |
885 explicit ThreadProxyContextRecreationTimer(ThreadProxy* proxy) | |
886 : Timer(Proxy::mainThread(), this) | |
887 , m_proxy(proxy) | |
888 { | |
889 } | |
890 | |
891 ThreadProxy* m_proxy; | |
892 }; | |
893 | |
894 void ThreadProxy::beginContextRecreation() | 875 void ThreadProxy::beginContextRecreation() |
895 { | 876 { |
896 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); | 877 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); |
897 DCHECK(isMainThread()); | 878 DCHECK(isMainThread()); |
898 DCHECK(!m_contextRecreationTimer); | |
899 m_contextRecreationTimer = ThreadProxyContextRecreationTimer::create(this); | |
900 m_layerTreeHost->didLoseContext(); | 879 m_layerTreeHost->didLoseContext(); |
901 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 880 m_contextRecreationCallback.Reset(base::Bind(&ThreadProxy::tryToRecreateCont
ext, base::Unretained(this))); |
| 881 Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); |
902 } | 882 } |
903 | 883 |
904 void ThreadProxy::tryToRecreateContext() | 884 void ThreadProxy::tryToRecreateContext() |
905 { | 885 { |
906 DCHECK(isMainThread()); | 886 DCHECK(isMainThread()); |
907 DCHECK(m_layerTreeHost); | 887 DCHECK(m_layerTreeHost); |
908 LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); | 888 LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); |
909 if (result == LayerTreeHost::RecreateFailedButTryAgain) | 889 if (result == LayerTreeHost::RecreateFailedButTryAgain) |
910 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 890 Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); |
911 else if (result == LayerTreeHost::RecreateSucceeded) | 891 else if (result == LayerTreeHost::RecreateSucceeded) |
912 m_contextRecreationTimer.reset(); | 892 m_contextRecreationCallback.Cancel(); |
913 } | 893 } |
914 | 894 |
915 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
andler* handler) | 895 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
andler* handler) |
916 { | 896 { |
917 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); | 897 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); |
918 DCHECK(isImplThread()); | 898 DCHECK(isImplThread()); |
919 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); | 899 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); |
920 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); | 900 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); |
921 scoped_ptr<FrameRateController> frameRateController; | 901 scoped_ptr<FrameRateController> frameRateController; |
922 if (m_renderVSyncEnabled) | 902 if (m_renderVSyncEnabled) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 983 |
1004 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 984 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
1005 { | 985 { |
1006 } | 986 } |
1007 | 987 |
1008 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 988 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
1009 { | 989 { |
1010 } | 990 } |
1011 | 991 |
1012 } // namespace cc | 992 } // namespace cc |
OLD | NEW |