Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: cc/CCThreadProxy.cpp

Issue 11048044: cc: Switch to Chromium DCHECKs and LOGs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 , m_beginFrameCompletionEventOnImplThread(0) 50 , m_beginFrameCompletionEventOnImplThread(0)
51 , m_readbackRequestOnImplThread(0) 51 , m_readbackRequestOnImplThread(0)
52 , m_commitCompletionEventOnImplThread(0) 52 , m_commitCompletionEventOnImplThread(0)
53 , m_textureAcquisitionCompletionEventOnImplThread(0) 53 , m_textureAcquisitionCompletionEventOnImplThread(0)
54 , m_resetContentsTexturesPurgedAfterCommitOnImplThread(false) 54 , m_resetContentsTexturesPurgedAfterCommitOnImplThread(false)
55 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) 55 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false)
56 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) 56 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled)
57 , m_totalCommitCount(0) 57 , m_totalCommitCount(0)
58 { 58 {
59 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); 59 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy");
60 ASSERT(isMainThread()); 60 DCHECK(isMainThread());
61 } 61 }
62 62
63 CCThreadProxy::~CCThreadProxy() 63 CCThreadProxy::~CCThreadProxy()
64 { 64 {
65 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); 65 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy");
66 ASSERT(isMainThread()); 66 DCHECK(isMainThread());
67 ASSERT(!m_started); 67 DCHECK(!m_started);
68 } 68 }
69 69
70 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) 70 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect)
71 { 71 {
72 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); 72 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback");
73 ASSERT(isMainThread()); 73 DCHECK(isMainThread());
74 ASSERT(m_layerTreeHost); 74 DCHECK(m_layerTreeHost);
75 75
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;
(...skipping 12 matching lines...) Expand all
97 { 97 {
98 DebugScopedSetMainThreadBlocked mainThreadBlocked; 98 DebugScopedSetMainThreadBlocked mainThreadBlocked;
99 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :requestReadbackOnImplThread, &request)); 99 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :requestReadbackOnImplThread, &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 CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) 105 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request)
106 { 106 {
107 ASSERT(CCProxy::isImplThread()); 107 DCHECK(CCProxy::isImplThread());
108 ASSERT(!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 CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) 120 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration)
121 { 121 {
122 ASSERT(CCProxy::isMainThread()); 122 DCHECK(CCProxy::isMainThread());
123 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat ion)); 123 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat ion));
124 } 124 }
125 125
126 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos ition, bool useAnchor, float scale, double duration) 126 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos ition, bool useAnchor, float scale, double duration)
127 { 127 {
128 ASSERT(CCProxy::isImplThread()); 128 DCHECK(CCProxy::isImplThread());
129 if (m_layerTreeHostImpl.get()) 129 if (m_layerTreeHostImpl.get())
130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration); 130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration);
131 } 131 }
132 132
133 void CCThreadProxy::finishAllRendering() 133 void CCThreadProxy::finishAllRendering()
134 { 134 {
135 ASSERT(CCProxy::isMainThread()); 135 DCHECK(CCProxy::isMainThread());
136 136
137 // Make sure all GL drawing is finished on the impl thread. 137 // Make sure all GL drawing is finished on the impl thread.
138 DebugScopedSetMainThreadBlocked mainThreadBlocked; 138 DebugScopedSetMainThreadBlocked mainThreadBlocked;
139 CCCompletionEvent completion; 139 CCCompletionEvent completion;
140 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin ishAllRenderingOnImplThread, &completion)); 140 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin ishAllRenderingOnImplThread, &completion));
141 completion.wait(); 141 completion.wait();
142 } 142 }
143 143
144 bool CCThreadProxy::isStarted() const 144 bool CCThreadProxy::isStarted() const
145 { 145 {
146 ASSERT(CCProxy::isMainThread()); 146 DCHECK(CCProxy::isMainThread());
147 return m_started; 147 return m_started;
148 } 148 }
149 149
150 bool CCThreadProxy::initializeContext() 150 bool CCThreadProxy::initializeContext()
151 { 151 {
152 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext"); 152 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext");
153 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 153 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
154 if (!context.get()) 154 if (!context.get())
155 return false; 155 return false;
156 156
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (initializeSucceeded) { 206 if (initializeSucceeded) {
207 m_rendererInitialized = true; 207 m_rendererInitialized = true;
208 m_RendererCapabilitiesMainThreadCopy = capabilities; 208 m_RendererCapabilitiesMainThreadCopy = capabilities;
209 } 209 }
210 return initializeSucceeded; 210 return initializeSucceeded;
211 } 211 }
212 212
213 bool CCThreadProxy::recreateContext() 213 bool CCThreadProxy::recreateContext()
214 { 214 {
215 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext"); 215 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext");
216 ASSERT(isMainThread()); 216 DCHECK(isMainThread());
217 217
218 // Try to create the context. 218 // Try to create the context.
219 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 219 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
220 if (!context.get()) 220 if (!context.get())
221 return false; 221 return false;
222 if (m_layerTreeHost->needsSharedContext()) 222 if (m_layerTreeHost->needsSharedContext())
223 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) 223 if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
224 return false; 224 return false;
225 225
226 // Make a blocking call to recreateContextOnImplThread. The results of that 226 // Make a blocking call to recreateContextOnImplThread. The results of that
(...skipping 10 matching lines...) Expand all
237 &capabilities)); 237 &capabilities));
238 completion.wait(); 238 completion.wait();
239 239
240 if (recreateSucceeded) 240 if (recreateSucceeded)
241 m_RendererCapabilitiesMainThreadCopy = capabilities; 241 m_RendererCapabilitiesMainThreadCopy = capabilities;
242 return recreateSucceeded; 242 return recreateSucceeded;
243 } 243 }
244 244
245 void CCThreadProxy::renderingStats(CCRenderingStats* stats) 245 void CCThreadProxy::renderingStats(CCRenderingStats* stats)
246 { 246 {
247 ASSERT(isMainThread()); 247 DCHECK(isMainThread());
248 248
249 DebugScopedSetMainThreadBlocked mainThreadBlocked; 249 DebugScopedSetMainThreadBlocked mainThreadBlocked;
250 CCCompletionEvent completion; 250 CCCompletionEvent completion;
251 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren deringStatsOnImplThread, 251 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren deringStatsOnImplThread,
252 &completion, 252 &completion,
253 stats)); 253 stats));
254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
255 stats->totalCommitCount = m_totalCommitCount; 255 stats->totalCommitCount = m_totalCommitCount;
256 256
257 completion.wait(); 257 completion.wait();
258 } 258 }
259 259
260 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const 260 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const
261 { 261 {
262 ASSERT(m_rendererInitialized); 262 DCHECK(m_rendererInitialized);
263 return m_RendererCapabilitiesMainThreadCopy; 263 return m_RendererCapabilitiesMainThreadCopy;
264 } 264 }
265 265
266 void CCThreadProxy::loseContext() 266 void CCThreadProxy::loseContext()
267 { 267 {
268 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did LoseContextOnImplThread)); 268 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did LoseContextOnImplThread));
269 } 269 }
270 270
271 void CCThreadProxy::setNeedsAnimate() 271 void CCThreadProxy::setNeedsAnimate()
272 { 272 {
273 ASSERT(isMainThread()); 273 DCHECK(isMainThread());
274 if (m_animateRequested) 274 if (m_animateRequested)
275 return; 275 return;
276 276
277 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); 277 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate");
278 m_animateRequested = true; 278 m_animateRequested = true;
279 279
280 if (m_commitRequestSentToImplThread) 280 if (m_commitRequestSentToImplThread)
281 return; 281 return;
282 m_commitRequestSentToImplThread = true; 282 m_commitRequestSentToImplThread = true;
283 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread)); 283 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread));
284 } 284 }
285 285
286 void CCThreadProxy::setNeedsCommit() 286 void CCThreadProxy::setNeedsCommit()
287 { 287 {
288 ASSERT(isMainThread()); 288 DCHECK(isMainThread());
289 if (m_commitRequested) 289 if (m_commitRequested)
290 return; 290 return;
291 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); 291 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit");
292 m_commitRequested = true; 292 m_commitRequested = true;
293 293
294 if (m_commitRequestSentToImplThread) 294 if (m_commitRequestSentToImplThread)
295 return; 295 return;
296 m_commitRequestSentToImplThread = true; 296 m_commitRequestSentToImplThread = true;
297 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread)); 297 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread));
298 } 298 }
299 299
300 void CCThreadProxy::didLoseContextOnImplThread() 300 void CCThreadProxy::didLoseContextOnImplThread()
301 { 301 {
302 ASSERT(isImplThread()); 302 DCHECK(isImplThread());
303 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); 303 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread");
304 m_schedulerOnImplThread->didLoseContext(); 304 m_schedulerOnImplThread->didLoseContext();
305 } 305 }
306 306
307 void CCThreadProxy::onSwapBuffersCompleteOnImplThread() 307 void CCThreadProxy::onSwapBuffersCompleteOnImplThread()
308 { 308 {
309 ASSERT(isImplThread()); 309 DCHECK(isImplThread());
310 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread"); 310 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread");
311 m_schedulerOnImplThread->didSwapBuffersComplete(); 311 m_schedulerOnImplThread->didSwapBuffersComplete();
312 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp leteSwapBuffers)); 312 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp leteSwapBuffers));
313 } 313 }
314 314
315 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in tervalInSeconds) 315 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in tervalInSeconds)
316 { 316 {
317 ASSERT(isImplThread()); 317 DCHECK(isImplThread());
318 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime base", monotonicTimebase, "intervalInSeconds", intervalInSeconds); 318 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime base", monotonicTimebase, "intervalInSeconds", intervalInSeconds);
319 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond); 319 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond);
320 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond); 320 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond);
321 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); 321 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval);
322 } 322 }
323 323
324 void CCThreadProxy::onCanDrawStateChanged(bool canDraw) 324 void CCThreadProxy::onCanDrawStateChanged(bool canDraw)
325 { 325 {
326 ASSERT(isImplThread()); 326 DCHECK(isImplThread());
327 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra w); 327 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra w);
328 m_schedulerOnImplThread->setCanDraw(canDraw); 328 m_schedulerOnImplThread->setCanDraw(canDraw);
329 } 329 }
330 330
331 void CCThreadProxy::setNeedsCommitOnImplThread() 331 void CCThreadProxy::setNeedsCommitOnImplThread()
332 { 332 {
333 ASSERT(isImplThread()); 333 DCHECK(isImplThread());
334 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread"); 334 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread");
335 m_schedulerOnImplThread->setNeedsCommit(); 335 m_schedulerOnImplThread->setNeedsCommit();
336 } 336 }
337 337
338 void CCThreadProxy::setNeedsForcedCommitOnImplThread() 338 void CCThreadProxy::setNeedsForcedCommitOnImplThread()
339 { 339 {
340 ASSERT(isImplThread()); 340 DCHECK(isImplThread());
341 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread"); 341 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread");
342 m_schedulerOnImplThread->setNeedsCommit(); 342 m_schedulerOnImplThread->setNeedsCommit();
343 m_schedulerOnImplThread->setNeedsForcedCommit(); 343 m_schedulerOnImplThread->setNeedsForcedCommit();
344 } 344 }
345 345
346 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni mationEventsVector> events, double wallClockTime) 346 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni mationEventsVector> events, double wallClockTime)
347 { 347 {
348 ASSERT(isImplThread()); 348 DCHECK(isImplThread());
349 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad"); 349 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad");
350 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events.release(), wallClockTime)); 350 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events.release(), wallClockTime));
351 } 351 }
352 352
353 void CCThreadProxy::releaseContentsTexturesOnImplThread() 353 void CCThreadProxy::releaseContentsTexturesOnImplThread()
354 { 354 {
355 ASSERT(isImplThread()); 355 DCHECK(isImplThread());
356 356
357 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost Impl->resourceProvider()); 357 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost Impl->resourceProvider());
358 358
359 // Make sure that we get a new commit before drawing again. 359 // Make sure that we get a new commit before drawing again.
360 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false; 360 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false;
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() && m_layerTreeHost->e victedContentsTexturesBackingsExist()) 363 if (m_currentTextureUpdateControllerOnImplThread.get() && m_layerTreeHost->e victedContentsTexturesBackingsExist())
364 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes ources(); 364 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes ources();
365 } 365 }
366 366
367 void CCThreadProxy::setNeedsRedraw() 367 void CCThreadProxy::setNeedsRedraw()
368 { 368 {
369 ASSERT(isMainThread()); 369 DCHECK(isMainThread());
370 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); 370 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw");
371 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread)); 371 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread));
372 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread)); 372 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread));
373 } 373 }
374 374
375 bool CCThreadProxy::commitRequested() const 375 bool CCThreadProxy::commitRequested() const
376 { 376 {
377 ASSERT(isMainThread()); 377 DCHECK(isMainThread());
378 return m_commitRequested; 378 return m_commitRequested;
379 } 379 }
380 380
381 void CCThreadProxy::setNeedsRedrawOnImplThread() 381 void CCThreadProxy::setNeedsRedrawOnImplThread()
382 { 382 {
383 ASSERT(isImplThread()); 383 DCHECK(isImplThread());
384 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread"); 384 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread");
385 m_schedulerOnImplThread->setNeedsRedraw(); 385 m_schedulerOnImplThread->setNeedsRedraw();
386 } 386 }
387 387
388 void CCThreadProxy::start() 388 void CCThreadProxy::start()
389 { 389 {
390 ASSERT(isMainThread()); 390 DCHECK(isMainThread());
391 ASSERT(CCProxy::implThread()); 391 DCHECK(CCProxy::implThread());
392 // Create LayerTreeHostImpl. 392 // Create LayerTreeHostImpl.
393 DebugScopedSetMainThreadBlocked mainThreadBlocked; 393 DebugScopedSetMainThreadBlocked mainThreadBlocked;
394 CCCompletionEvent completion; 394 CCCompletionEvent completion;
395 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler(); 395 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler();
396 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini tializeImplOnImplThread, &completion, handler.release())); 396 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini tializeImplOnImplThread, &completion, handler.release()));
397 completion.wait(); 397 completion.wait();
398 398
399 m_started = true; 399 m_started = true;
400 } 400 }
401 401
402 void CCThreadProxy::stop() 402 void CCThreadProxy::stop()
403 { 403 {
404 TRACE_EVENT0("cc", "CCThreadProxy::stop"); 404 TRACE_EVENT0("cc", "CCThreadProxy::stop");
405 ASSERT(isMainThread()); 405 DCHECK(isMainThread());
406 ASSERT(m_started); 406 DCHECK(m_started);
407 407
408 // Synchronously deletes the impl. 408 // Synchronously deletes the impl.
409 { 409 {
410 DebugScopedSetMainThreadBlocked mainThreadBlocked; 410 DebugScopedSetMainThreadBlocked mainThreadBlocked;
411 411
412 CCCompletionEvent completion; 412 CCCompletionEvent completion;
413 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :layerTreeHostClosedOnImplThread, &completion)); 413 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :layerTreeHostClosedOnImplThread, &completion));
414 completion.wait(); 414 completion.wait();
415 } 415 }
416 416
417 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. 417 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us.
418 418
419 ASSERT(!m_layerTreeHostImpl.get()); // verify that the impl deleted. 419 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted.
420 m_layerTreeHost = 0; 420 m_layerTreeHost = 0;
421 m_started = false; 421 m_started = false;
422 } 422 }
423 423
424 void CCThreadProxy::forceSerializeOnSwapBuffers() 424 void CCThreadProxy::forceSerializeOnSwapBuffers()
425 { 425 {
426 DebugScopedSetMainThreadBlocked mainThreadBlocked; 426 DebugScopedSetMainThreadBlocked mainThreadBlocked;
427 CCCompletionEvent completion; 427 CCCompletionEvent completion;
428 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for ceSerializeOnSwapBuffersOnImplThread, &completion)); 428 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for ceSerializeOnSwapBuffersOnImplThread, &completion));
429 completion.wait(); 429 completion.wait();
430 } 430 }
431 431
432 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c ompletion) 432 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c ompletion)
433 { 433 {
434 if (m_rendererInitialized) 434 if (m_rendererInitialized)
435 m_layerTreeHostImpl->renderer()->doNoOp(); 435 m_layerTreeHostImpl->renderer()->doNoOp();
436 completion->signal(); 436 completion->signal();
437 } 437 }
438 438
439 439
440 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion ) 440 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion )
441 { 441 {
442 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread"); 442 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread");
443 ASSERT(isImplThread()); 443 DCHECK(isImplThread());
444 m_layerTreeHostImpl->finishAllRendering(); 444 m_layerTreeHostImpl->finishAllRendering();
445 completion->signal(); 445 completion->signal();
446 } 446 }
447 447
448 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion) 448 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion)
449 { 449 {
450 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread"); 450 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread");
451 ASSERT(!m_beginFrameCompletionEventOnImplThread); 451 DCHECK(!m_beginFrameCompletionEventOnImplThread);
452 452
453 if (m_schedulerOnImplThread->commitPending()) { 453 if (m_schedulerOnImplThread->commitPending()) {
454 completion->signal(); 454 completion->signal();
455 return; 455 return;
456 } 456 }
457 457
458 m_beginFrameCompletionEventOnImplThread = completion; 458 m_beginFrameCompletionEventOnImplThread = completion;
459 setNeedsForcedCommitOnImplThread(); 459 setNeedsForcedCommitOnImplThread();
460 } 460 }
461 461
462 void CCThreadProxy::scheduledActionBeginFrame() 462 void CCThreadProxy::scheduledActionBeginFrame()
463 { 463 {
464 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); 464 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame");
465 ASSERT(!m_pendingBeginFrameRequest); 465 DCHECK(!m_pendingBeginFrameRequest);
466 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); 466 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState());
467 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime(); 467 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime();
468 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas(); 468 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas();
469 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm(); 469 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm();
470 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes(); 470 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes();
471 m_layerTreeHost->getEvictedContentTexturesBackings(m_pendingBeginFrameReques t->evictedContentsTexturesBackings); 471 m_layerTreeHost->getEvictedContentTexturesBackings(m_pendingBeginFrameReques t->evictedContentsTexturesBackings);
472 472
473 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame)); 473 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame));
474 474
475 if (m_beginFrameCompletionEventOnImplThread) { 475 if (m_beginFrameCompletionEventOnImplThread) {
476 m_beginFrameCompletionEventOnImplThread->signal(); 476 m_beginFrameCompletionEventOnImplThread->signal();
477 m_beginFrameCompletionEventOnImplThread = 0; 477 m_beginFrameCompletionEventOnImplThread = 0;
478 } 478 }
479 } 479 }
480 480
481 void CCThreadProxy::beginFrame() 481 void CCThreadProxy::beginFrame()
482 { 482 {
483 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); 483 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame");
484 ASSERT(isMainThread()); 484 DCHECK(isMainThread());
485 if (!m_layerTreeHost) 485 if (!m_layerTreeHost)
486 return; 486 return;
487 487
488 if (!m_pendingBeginFrameRequest) { 488 if (!m_pendingBeginFrameRequest) {
489 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); 489 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage");
490 return; 490 return;
491 } 491 }
492 492
493 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext()) 493 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext())
494 WebSharedGraphicsContext3D::createCompositorThreadContext(); 494 WebSharedGraphicsContext3D::createCompositorThreadContext();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 m_totalCommitCount++; 580 m_totalCommitCount++;
581 } 581 }
582 582
583 m_layerTreeHost->commitComplete(); 583 m_layerTreeHost->commitComplete();
584 m_layerTreeHost->didBeginFrame(); 584 m_layerTreeHost->didBeginFrame();
585 } 585 }
586 586
587 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue) 587 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue)
588 { 588 {
589 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); 589 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
590 ASSERT(!m_commitCompletionEventOnImplThread); 590 DCHECK(!m_commitCompletionEventOnImplThread);
591 ASSERT(isImplThread() && isMainThreadBlocked()); 591 DCHECK(isImplThread() && isMainThreadBlocked());
592 ASSERT(m_schedulerOnImplThread); 592 DCHECK(m_schedulerOnImplThread);
593 ASSERT(m_schedulerOnImplThread->commitPending()); 593 DCHECK(m_schedulerOnImplThread->commitPending());
594 594
595 if (!m_layerTreeHostImpl.get()) { 595 if (!m_layerTreeHostImpl.get()) {
596 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 596 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
597 completion->signal(); 597 completion->signal();
598 return; 598 return;
599 } 599 }
600 600
601 // Clear any uploads we were making to textures linked to evicted 601 // Clear any uploads we were making to textures linked to evicted
602 // resources 602 // resources
603 if (m_layerTreeHost->evictedContentsTexturesBackingsExist()) 603 if (m_layerTreeHost->evictedContentsTexturesBackingsExist())
(...skipping 15 matching lines...) Expand all
619 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider() , m_layerTreeHostImpl->resourceProvider()->textureUploader()); 619 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider() , m_layerTreeHostImpl->resourceProvider()->textureUploader());
620 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( 620 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(
621 m_schedulerOnImplThread->anticipatedDrawTime()); 621 m_schedulerOnImplThread->anticipatedDrawTime());
622 622
623 m_commitCompletionEventOnImplThread = completion; 623 m_commitCompletionEventOnImplThread = completion;
624 } 624 }
625 625
626 void CCThreadProxy::beginFrameAbortedOnImplThread() 626 void CCThreadProxy::beginFrameAbortedOnImplThread()
627 { 627 {
628 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); 628 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread");
629 ASSERT(isImplThread()); 629 DCHECK(isImplThread());
630 ASSERT(m_schedulerOnImplThread); 630 DCHECK(m_schedulerOnImplThread);
631 ASSERT(m_schedulerOnImplThread->commitPending()); 631 DCHECK(m_schedulerOnImplThread->commitPending());
632 632
633 m_schedulerOnImplThread->beginFrameAborted(); 633 m_schedulerOnImplThread->beginFrameAborted();
634 } 634 }
635 635
636 void CCThreadProxy::scheduledActionCommit() 636 void CCThreadProxy::scheduledActionCommit()
637 { 637 {
638 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); 638 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit");
639 ASSERT(isImplThread()); 639 DCHECK(isImplThread());
640 ASSERT(m_commitCompletionEventOnImplThread); 640 DCHECK(m_commitCompletionEventOnImplThread);
641 ASSERT(m_currentTextureUpdateControllerOnImplThread); 641 DCHECK(m_currentTextureUpdateControllerOnImplThread);
642 642
643 // Complete all remaining texture updates. 643 // Complete all remaining texture updates.
644 m_currentTextureUpdateControllerOnImplThread->finalize(); 644 m_currentTextureUpdateControllerOnImplThread->finalize();
645 m_currentTextureUpdateControllerOnImplThread.clear(); 645 m_currentTextureUpdateControllerOnImplThread.clear();
646 646
647 m_layerTreeHostImpl->beginCommit(); 647 m_layerTreeHostImpl->beginCommit();
648 648
649 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); 649 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
650 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); 650 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
651 651
652 if (m_resetContentsTexturesPurgedAfterCommitOnImplThread) { 652 if (m_resetContentsTexturesPurgedAfterCommitOnImplThread) {
653 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false; 653 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false;
654 m_layerTreeHostImpl->resetContentsTexturesPurged(); 654 m_layerTreeHostImpl->resetContentsTexturesPurged();
655 } 655 }
656 656
657 m_layerTreeHostImpl->commitComplete(); 657 m_layerTreeHostImpl->commitComplete();
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 CCThreadProxy::scheduledActionBeginContextRecreation()
669 { 669 {
670 ASSERT(isImplThread()); 670 DCHECK(isImplThread());
671 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo ntextRecreation)); 671 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo ntextRecreation));
672 } 672 }
673 673
674 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte rnal(bool forcedDraw) 674 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte rnal(bool forcedDraw)
675 { 675 {
676 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap"); 676 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap");
677 CCScheduledActionDrawAndSwapResult result; 677 CCScheduledActionDrawAndSwapResult result;
678 result.didDraw = false; 678 result.didDraw = false;
679 result.didSwap = false; 679 result.didSwap = false;
680 ASSERT(isImplThread()); 680 DCHECK(isImplThread());
681 ASSERT(m_layerTreeHostImpl.get()); 681 DCHECK(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 DCHECK(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);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 return result; 732 return result;
733 } 733 }
734 734
735 void CCThreadProxy::acquireLayerTextures() 735 void CCThreadProxy::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 DCHECK(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", "CCThreadProxy::acquireLayerTextures");
748 DebugScopedSetMainThreadBlocked mainThreadBlocked; 748 DebugScopedSetMainThreadBlocked mainThreadBlocked;
749 CCCompletionEvent completion; 749 CCCompletionEvent completion;
750 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq uireLayerTexturesForMainThreadOnImplThread, &completion)); 750 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq uireLayerTexturesForMainThreadOnImplThread, &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 CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv ent* completion)
757 { 757 {
758 ASSERT(isImplThread()); 758 DCHECK(isImplThread());
759 ASSERT(!m_textureAcquisitionCompletionEventOnImplThread); 759 DCHECK(!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 CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread()
766 { 766 {
767 ASSERT(m_textureAcquisitionCompletionEventOnImplThread); 767 DCHECK(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 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo ssible()
773 { 773 {
774 return scheduledActionDrawAndSwapInternal(false); 774 return scheduledActionDrawAndSwapInternal(false);
775 } 775 }
776 776
777 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc ed() 777 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc ed()
778 { 778 {
779 return scheduledActionDrawAndSwapInternal(true); 779 return scheduledActionDrawAndSwapInternal(true);
780 } 780 }
781 781
782 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) 782 void CCThreadProxy::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 CCThreadProxy::readyToFinalizeTextureUpdates()
791 { 791 {
792 ASSERT(isImplThread()); 792 DCHECK(isImplThread());
793 m_schedulerOnImplThread->beginFrameComplete(); 793 m_schedulerOnImplThread->beginFrameComplete();
794 } 794 }
795 795
796 void CCThreadProxy::didCommitAndDrawFrame() 796 void CCThreadProxy::didCommitAndDrawFrame()
797 { 797 {
798 ASSERT(isMainThread()); 798 DCHECK(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 CCThreadProxy::didCompleteSwapBuffers()
805 { 805 {
806 ASSERT(isMainThread()); 806 DCHECK(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 CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d ouble wallClockTime)
813 { 813 {
814 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events)); 814 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events));
815 815
816 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents"); 816 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents");
817 ASSERT(isMainThread()); 817 DCHECK(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 CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient {
824 public: 824 public:
825 static PassOwnPtr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy* proxy) { return adoptPtr(new CCThreadProxyContextRecreationTimer(proxy)); } 825 static PassOwnPtr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy* proxy) { return adoptPtr(new CCThreadProxyContextRecreationTimer(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 CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy)
834 : CCTimer(CCProxy::mainThread(), this) 834 : CCTimer(CCProxy::mainThread(), this)
835 , m_proxy(proxy) 835 , m_proxy(proxy)
836 { 836 {
837 } 837 }
838 838
839 CCThreadProxy* m_proxy; 839 CCThreadProxy* m_proxy;
840 }; 840 };
841 841
842 void CCThreadProxy::beginContextRecreation() 842 void CCThreadProxy::beginContextRecreation()
843 { 843 {
844 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation"); 844 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation");
845 ASSERT(isMainThread()); 845 DCHECK(isMainThread());
846 ASSERT(!m_contextRecreationTimer); 846 DCHECK(!m_contextRecreationTimer);
847 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this) ; 847 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::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 CCThreadProxy::tryToRecreateContext()
853 { 853 {
854 ASSERT(isMainThread()); 854 DCHECK(isMainThread());
855 ASSERT(m_layerTreeHost); 855 DCHECK(m_layerTreeHost);
856 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); 856 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext();
857 if (result == CCLayerTreeHost::RecreateFailedButTryAgain) 857 if (result == CCLayerTreeHost::RecreateFailedButTryAgain)
858 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); 858 m_contextRecreationTimer->startOneShot(contextRecreationTickRate);
859 else if (result == CCLayerTreeHost::RecreateSucceeded) 859 else if (result == CCLayerTreeHost::RecreateSucceeded)
860 m_contextRecreationTimer.clear(); 860 m_contextRecreationTimer.clear();
861 } 861 }
862 862
863 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC InputHandler* handler) 863 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC InputHandler* handler)
864 { 864 {
865 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread"); 865 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread");
866 ASSERT(isImplThread()); 866 DCHECK(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<CCFrameRateController> frameRateController;
870 if (m_renderVSyncEnabled) 870 if (m_renderVSyncEnabled)
871 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour ce::create(displayRefreshInterval, CCProxy::implThread()))); 871 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour ce::create(displayRefreshInterval, CCProxy::implThread())));
872 else 872 else
873 frameRateController.reset(new CCFrameRateController(CCProxy::implThread( ))); 873 frameRateController.reset(new CCFrameRateController(CCProxy::implThread( )));
874 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass ()); 874 m_schedulerOnImplThread = CCScheduler::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<CCInputHandler>(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 CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context)
885 { 885 {
886 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread"); 886 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread");
887 ASSERT(isImplThread()); 887 DCHECK(isImplThread());
888 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co ntext).Pass(); 888 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co ntext).Pass();
889 } 889 }
890 890
891 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion , bool* initializeSucceeded, RendererCapabilities* capabilities) 891 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion , bool* initializeSucceeded, RendererCapabilities* capabilities)
892 { 892 {
893 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread"); 893 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread");
894 ASSERT(isImplThread()); 894 DCHECK(isImplThread());
895 ASSERT(m_contextBeforeInitializationOnImplThread.get()); 895 DCHECK(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 CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio n)
907 { 907 {
908 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); 908 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread");
909 ASSERT(isImplThread()); 909 DCHECK(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.clear(); 913 m_schedulerOnImplThread.clear();
914 completion->signal(); 914 completion->signal();
915 } 915 }
916 916
917 void CCThreadProxy::setFullRootLayerDamageOnImplThread() 917 void CCThreadProxy::setFullRootLayerDamageOnImplThread()
918 { 918 {
919 ASSERT(isImplThread()); 919 DCHECK(isImplThread());
920 m_layerTreeHostImpl->setFullRootLayerDamage(); 920 m_layerTreeHostImpl->setFullRootLayerDamage();
921 } 921 }
922 922
923 size_t CCThreadProxy::maxPartialTextureUpdates() const 923 size_t CCThreadProxy::maxPartialTextureUpdates() const
924 { 924 {
925 return CCTextureUpdateController::maxPartialTextureUpdates(); 925 return CCTextureUpdateController::maxPartialTextureUpdates();
926 } 926 }
927 927
928 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities) 928 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities)
929 { 929 {
930 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); 930 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread");
931 ASSERT(isImplThread()); 931 DCHECK(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<CCGr aphicsContext>(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 CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC RenderingStats* stats)
942 { 942 {
943 ASSERT(isImplThread()); 943 DCHECK(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 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
949 : monotonicFrameBeginTime(0) 949 : monotonicFrameBeginTime(0)
950 { 950 {
951 } 951 }
952 952
953 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 953 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
954 { 954 {
955 } 955 }
956 956
957 } // namespace cc 957 } // namespace cc
OLDNEW
« cc/CCCompletionEvent.h ('K') | « cc/CCTextureLayerImpl.cpp ('k') | cc/CCThreadedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698