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

Side by Side Diff: cc/thread_proxy.cc

Issue 11048044: cc: Switch to Chromium DCHECKs and LOGs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) 49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread()))
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_nextFrameIsNewlyCommittedFrameOnImplThread(false) 54 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false)
55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) 55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled)
56 , m_totalCommitCount(0) 56 , m_totalCommitCount(0)
57 { 57 {
58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); 58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy");
59 ASSERT(isMainThread()); 59 CC_DCHECK(isMainThread());
60 } 60 }
61 61
62 CCThreadProxy::~CCThreadProxy() 62 CCThreadProxy::~CCThreadProxy()
63 { 63 {
64 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); 64 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy");
65 ASSERT(isMainThread()); 65 CC_DCHECK(isMainThread());
66 ASSERT(!m_started); 66 CC_DCHECK(!m_started);
67 } 67 }
68 68
69 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) 69 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect)
70 { 70 {
71 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); 71 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback");
72 ASSERT(isMainThread()); 72 CC_DCHECK(isMainThread());
73 ASSERT(m_layerTreeHost); 73 CC_DCHECK(m_layerTreeHost);
74 74
75 if (!m_layerTreeHost->initializeRendererIfNeeded()) { 75 if (!m_layerTreeHost->initializeRendererIfNeeded()) {
76 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); 76 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized");
77 return false; 77 return false;
78 } 78 }
79 79
80 80
81 // Perform a synchronous commit. 81 // Perform a synchronous commit.
82 { 82 {
83 DebugScopedSetMainThreadBlocked mainThreadBlocked; 83 DebugScopedSetMainThreadBlocked mainThreadBlocked;
(...skipping 12 matching lines...) Expand all
96 { 96 {
97 DebugScopedSetMainThreadBlocked mainThreadBlocked; 97 DebugScopedSetMainThreadBlocked mainThreadBlocked;
98 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :requestReadbackOnImplThread, &request)); 98 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :requestReadbackOnImplThread, &request));
99 request.completion.wait(); 99 request.completion.wait();
100 } 100 }
101 return request.success; 101 return request.success;
102 } 102 }
103 103
104 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) 104 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request)
105 { 105 {
106 ASSERT(CCProxy::isImplThread()); 106 CC_DCHECK(CCProxy::isImplThread());
107 ASSERT(!m_readbackRequestOnImplThread); 107 CC_DCHECK(!m_readbackRequestOnImplThread);
108 if (!m_layerTreeHostImpl.get()) { 108 if (!m_layerTreeHostImpl.get()) {
109 request->success = false; 109 request->success = false;
110 request->completion.signal(); 110 request->completion.signal();
111 return; 111 return;
112 } 112 }
113 113
114 m_readbackRequestOnImplThread = request; 114 m_readbackRequestOnImplThread = request;
115 m_schedulerOnImplThread->setNeedsRedraw(); 115 m_schedulerOnImplThread->setNeedsRedraw();
116 m_schedulerOnImplThread->setNeedsForcedRedraw(); 116 m_schedulerOnImplThread->setNeedsForcedRedraw();
117 } 117 }
118 118
119 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) 119 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration)
120 { 120 {
121 ASSERT(CCProxy::isMainThread()); 121 CC_DCHECK(CCProxy::isMainThread());
122 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat ion)); 122 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat ion));
123 } 123 }
124 124
125 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos ition, bool useAnchor, float scale, double duration) 125 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos ition, bool useAnchor, float scale, double duration)
126 { 126 {
127 ASSERT(CCProxy::isImplThread()); 127 CC_DCHECK(CCProxy::isImplThread());
128 if (m_layerTreeHostImpl.get()) 128 if (m_layerTreeHostImpl.get())
129 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration); 129 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration);
130 } 130 }
131 131
132 void CCThreadProxy::finishAllRendering() 132 void CCThreadProxy::finishAllRendering()
133 { 133 {
134 ASSERT(CCProxy::isMainThread()); 134 CC_DCHECK(CCProxy::isMainThread());
135 135
136 // Make sure all GL drawing is finished on the impl thread. 136 // Make sure all GL drawing is finished on the impl thread.
137 DebugScopedSetMainThreadBlocked mainThreadBlocked; 137 DebugScopedSetMainThreadBlocked mainThreadBlocked;
138 CCCompletionEvent completion; 138 CCCompletionEvent completion;
139 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin ishAllRenderingOnImplThread, &completion)); 139 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin ishAllRenderingOnImplThread, &completion));
140 completion.wait(); 140 completion.wait();
141 } 141 }
142 142
143 bool CCThreadProxy::isStarted() const 143 bool CCThreadProxy::isStarted() const
144 { 144 {
145 ASSERT(CCProxy::isMainThread()); 145 CC_DCHECK(CCProxy::isMainThread());
146 return m_started; 146 return m_started;
147 } 147 }
148 148
149 bool CCThreadProxy::initializeContext() 149 bool CCThreadProxy::initializeContext()
150 { 150 {
151 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext"); 151 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext");
152 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 152 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
153 if (!context.get()) 153 if (!context.get())
154 return false; 154 return false;
155 155
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (initializeSucceeded) { 205 if (initializeSucceeded) {
206 m_rendererInitialized = true; 206 m_rendererInitialized = true;
207 m_RendererCapabilitiesMainThreadCopy = capabilities; 207 m_RendererCapabilitiesMainThreadCopy = capabilities;
208 } 208 }
209 return initializeSucceeded; 209 return initializeSucceeded;
210 } 210 }
211 211
212 bool CCThreadProxy::recreateContext() 212 bool CCThreadProxy::recreateContext()
213 { 213 {
214 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext"); 214 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext");
215 ASSERT(isMainThread()); 215 CC_DCHECK(isMainThread());
216 216
217 // Try to create the context. 217 // Try to create the context.
218 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 218 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
219 if (!context.get()) 219 if (!context.get())
220 return false; 220 return false;
221 if (m_layerTreeHost->needsSharedContext()) 221 if (m_layerTreeHost->needsSharedContext())
222 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) 222 if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
223 return false; 223 return false;
224 224
225 // Make a blocking call to recreateContextOnImplThread. The results of that 225 // Make a blocking call to recreateContextOnImplThread. The results of that
(...skipping 10 matching lines...) Expand all
236 &capabilities)); 236 &capabilities));
237 completion.wait(); 237 completion.wait();
238 238
239 if (recreateSucceeded) 239 if (recreateSucceeded)
240 m_RendererCapabilitiesMainThreadCopy = capabilities; 240 m_RendererCapabilitiesMainThreadCopy = capabilities;
241 return recreateSucceeded; 241 return recreateSucceeded;
242 } 242 }
243 243
244 void CCThreadProxy::renderingStats(CCRenderingStats* stats) 244 void CCThreadProxy::renderingStats(CCRenderingStats* stats)
245 { 245 {
246 ASSERT(isMainThread()); 246 CC_DCHECK(isMainThread());
247 247
248 DebugScopedSetMainThreadBlocked mainThreadBlocked; 248 DebugScopedSetMainThreadBlocked mainThreadBlocked;
249 CCCompletionEvent completion; 249 CCCompletionEvent completion;
250 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren deringStatsOnImplThread, 250 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren deringStatsOnImplThread,
251 &completion, 251 &completion,
252 stats)); 252 stats));
253 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 253 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
254 stats->totalCommitCount = m_totalCommitCount; 254 stats->totalCommitCount = m_totalCommitCount;
255 255
256 completion.wait(); 256 completion.wait();
257 } 257 }
258 258
259 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const 259 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const
260 { 260 {
261 ASSERT(m_rendererInitialized); 261 CC_DCHECK(m_rendererInitialized);
262 return m_RendererCapabilitiesMainThreadCopy; 262 return m_RendererCapabilitiesMainThreadCopy;
263 } 263 }
264 264
265 void CCThreadProxy::loseContext() 265 void CCThreadProxy::loseContext()
266 { 266 {
267 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did LoseContextOnImplThread)); 267 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did LoseContextOnImplThread));
268 } 268 }
269 269
270 void CCThreadProxy::setNeedsAnimate() 270 void CCThreadProxy::setNeedsAnimate()
271 { 271 {
272 ASSERT(isMainThread()); 272 CC_DCHECK(isMainThread());
273 if (m_animateRequested) 273 if (m_animateRequested)
274 return; 274 return;
275 275
276 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); 276 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate");
277 m_animateRequested = true; 277 m_animateRequested = true;
278 278
279 if (m_commitRequestSentToImplThread) 279 if (m_commitRequestSentToImplThread)
280 return; 280 return;
281 m_commitRequestSentToImplThread = true; 281 m_commitRequestSentToImplThread = true;
282 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread)); 282 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread));
283 } 283 }
284 284
285 void CCThreadProxy::setNeedsCommit() 285 void CCThreadProxy::setNeedsCommit()
286 { 286 {
287 ASSERT(isMainThread()); 287 CC_DCHECK(isMainThread());
288 if (m_commitRequested) 288 if (m_commitRequested)
289 return; 289 return;
290 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); 290 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit");
291 m_commitRequested = true; 291 m_commitRequested = true;
292 292
293 if (m_commitRequestSentToImplThread) 293 if (m_commitRequestSentToImplThread)
294 return; 294 return;
295 m_commitRequestSentToImplThread = true; 295 m_commitRequestSentToImplThread = true;
296 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread)); 296 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsCommitOnImplThread));
297 } 297 }
298 298
299 void CCThreadProxy::didLoseContextOnImplThread() 299 void CCThreadProxy::didLoseContextOnImplThread()
300 { 300 {
301 ASSERT(isImplThread()); 301 CC_DCHECK(isImplThread());
302 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); 302 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread");
303 m_schedulerOnImplThread->didLoseContext(); 303 m_schedulerOnImplThread->didLoseContext();
304 } 304 }
305 305
306 void CCThreadProxy::onSwapBuffersCompleteOnImplThread() 306 void CCThreadProxy::onSwapBuffersCompleteOnImplThread()
307 { 307 {
308 ASSERT(isImplThread()); 308 CC_DCHECK(isImplThread());
309 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread"); 309 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread");
310 m_schedulerOnImplThread->didSwapBuffersComplete(); 310 m_schedulerOnImplThread->didSwapBuffersComplete();
311 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp leteSwapBuffers)); 311 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp leteSwapBuffers));
312 } 312 }
313 313
314 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in tervalInSeconds) 314 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in tervalInSeconds)
315 { 315 {
316 ASSERT(isImplThread()); 316 CC_DCHECK(isImplThread());
317 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime base", monotonicTimebase, "intervalInSeconds", intervalInSeconds); 317 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime base", monotonicTimebase, "intervalInSeconds", intervalInSeconds);
318 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond); 318 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond);
319 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond); 319 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond);
320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); 320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval);
321 } 321 }
322 322
323 void CCThreadProxy::onCanDrawStateChanged(bool canDraw) 323 void CCThreadProxy::onCanDrawStateChanged(bool canDraw)
324 { 324 {
325 ASSERT(isImplThread()); 325 CC_DCHECK(isImplThread());
326 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra w); 326 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra w);
327 m_schedulerOnImplThread->setCanDraw(canDraw); 327 m_schedulerOnImplThread->setCanDraw(canDraw);
328 } 328 }
329 329
330 void CCThreadProxy::setNeedsCommitOnImplThread() 330 void CCThreadProxy::setNeedsCommitOnImplThread()
331 { 331 {
332 ASSERT(isImplThread()); 332 CC_DCHECK(isImplThread());
333 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread"); 333 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread");
334 m_schedulerOnImplThread->setNeedsCommit(); 334 m_schedulerOnImplThread->setNeedsCommit();
335 } 335 }
336 336
337 void CCThreadProxy::setNeedsForcedCommitOnImplThread() 337 void CCThreadProxy::setNeedsForcedCommitOnImplThread()
338 { 338 {
339 ASSERT(isImplThread()); 339 CC_DCHECK(isImplThread());
340 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread"); 340 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread");
341 m_schedulerOnImplThread->setNeedsCommit(); 341 m_schedulerOnImplThread->setNeedsCommit();
342 m_schedulerOnImplThread->setNeedsForcedCommit(); 342 m_schedulerOnImplThread->setNeedsForcedCommit();
343 } 343 }
344 344
345 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni mationEventsVector> events, double wallClockTime) 345 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni mationEventsVector> events, double wallClockTime)
346 { 346 {
347 ASSERT(isImplThread()); 347 CC_DCHECK(isImplThread());
348 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad"); 348 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad");
349 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events.release(), wallClockTime)); 349 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events.release(), wallClockTime));
350 } 350 }
351 351
352 void CCThreadProxy::releaseContentsTexturesOnImplThread() 352 void CCThreadProxy::releaseContentsTexturesOnImplThread()
353 { 353 {
354 ASSERT(isImplThread()); 354 CC_DCHECK(isImplThread());
355 355
356 if (m_layerTreeHost->contentsTextureManager()) 356 if (m_layerTreeHost->contentsTextureManager())
357 m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(0, m _layerTreeHostImpl->resourceProvider()); 357 m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(0, m _layerTreeHostImpl->resourceProvider());
358 358
359 // The texture upload queue may reference textures that were just purged, cl ear 359 // The texture upload queue may reference textures that were just purged, cl ear
360 // them from the queue. 360 // them from the queue.
361 if (m_currentTextureUpdateControllerOnImplThread.get()) 361 if (m_currentTextureUpdateControllerOnImplThread.get())
362 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes ources(); 362 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes ources();
363 } 363 }
364 364
365 void CCThreadProxy::setNeedsRedraw() 365 void CCThreadProxy::setNeedsRedraw()
366 { 366 {
367 ASSERT(isMainThread()); 367 CC_DCHECK(isMainThread());
368 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); 368 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw");
369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread)); 369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread));
370 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread)); 370 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread));
371 } 371 }
372 372
373 bool CCThreadProxy::commitRequested() const 373 bool CCThreadProxy::commitRequested() const
374 { 374 {
375 ASSERT(isMainThread()); 375 CC_DCHECK(isMainThread());
376 return m_commitRequested; 376 return m_commitRequested;
377 } 377 }
378 378
379 void CCThreadProxy::setNeedsRedrawOnImplThread() 379 void CCThreadProxy::setNeedsRedrawOnImplThread()
380 { 380 {
381 ASSERT(isImplThread()); 381 CC_DCHECK(isImplThread());
382 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread"); 382 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread");
383 m_schedulerOnImplThread->setNeedsRedraw(); 383 m_schedulerOnImplThread->setNeedsRedraw();
384 } 384 }
385 385
386 void CCThreadProxy::start() 386 void CCThreadProxy::start()
387 { 387 {
388 ASSERT(isMainThread()); 388 CC_DCHECK(isMainThread());
389 ASSERT(CCProxy::implThread()); 389 CC_DCHECK(CCProxy::implThread());
390 // Create LayerTreeHostImpl. 390 // Create LayerTreeHostImpl.
391 DebugScopedSetMainThreadBlocked mainThreadBlocked; 391 DebugScopedSetMainThreadBlocked mainThreadBlocked;
392 CCCompletionEvent completion; 392 CCCompletionEvent completion;
393 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler(); 393 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler();
394 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini tializeImplOnImplThread, &completion, handler.release())); 394 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini tializeImplOnImplThread, &completion, handler.release()));
395 completion.wait(); 395 completion.wait();
396 396
397 m_started = true; 397 m_started = true;
398 } 398 }
399 399
400 void CCThreadProxy::stop() 400 void CCThreadProxy::stop()
401 { 401 {
402 TRACE_EVENT0("cc", "CCThreadProxy::stop"); 402 TRACE_EVENT0("cc", "CCThreadProxy::stop");
403 ASSERT(isMainThread()); 403 CC_DCHECK(isMainThread());
404 ASSERT(m_started); 404 CC_DCHECK(m_started);
405 405
406 // Synchronously deletes the impl. 406 // Synchronously deletes the impl.
407 { 407 {
408 DebugScopedSetMainThreadBlocked mainThreadBlocked; 408 DebugScopedSetMainThreadBlocked mainThreadBlocked;
409 409
410 CCCompletionEvent completion; 410 CCCompletionEvent completion;
411 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :layerTreeHostClosedOnImplThread, &completion)); 411 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :layerTreeHostClosedOnImplThread, &completion));
412 completion.wait(); 412 completion.wait();
413 } 413 }
414 414
415 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. 415 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us.
416 416
417 ASSERT(!m_layerTreeHostImpl.get()); // verify that the impl deleted. 417 CC_DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted.
418 m_layerTreeHost = 0; 418 m_layerTreeHost = 0;
419 m_started = false; 419 m_started = false;
420 } 420 }
421 421
422 void CCThreadProxy::forceSerializeOnSwapBuffers() 422 void CCThreadProxy::forceSerializeOnSwapBuffers()
423 { 423 {
424 DebugScopedSetMainThreadBlocked mainThreadBlocked; 424 DebugScopedSetMainThreadBlocked mainThreadBlocked;
425 CCCompletionEvent completion; 425 CCCompletionEvent completion;
426 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for ceSerializeOnSwapBuffersOnImplThread, &completion)); 426 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for ceSerializeOnSwapBuffersOnImplThread, &completion));
427 completion.wait(); 427 completion.wait();
428 } 428 }
429 429
430 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c ompletion) 430 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c ompletion)
431 { 431 {
432 if (m_rendererInitialized) 432 if (m_rendererInitialized)
433 m_layerTreeHostImpl->renderer()->doNoOp(); 433 m_layerTreeHostImpl->renderer()->doNoOp();
434 completion->signal(); 434 completion->signal();
435 } 435 }
436 436
437 437
438 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion ) 438 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion )
439 { 439 {
440 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread"); 440 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread");
441 ASSERT(isImplThread()); 441 CC_DCHECK(isImplThread());
442 m_layerTreeHostImpl->finishAllRendering(); 442 m_layerTreeHostImpl->finishAllRendering();
443 completion->signal(); 443 completion->signal();
444 } 444 }
445 445
446 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion) 446 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion)
447 { 447 {
448 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread"); 448 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread");
449 ASSERT(!m_beginFrameCompletionEventOnImplThread); 449 CC_DCHECK(!m_beginFrameCompletionEventOnImplThread);
450 450
451 if (m_schedulerOnImplThread->commitPending()) { 451 if (m_schedulerOnImplThread->commitPending()) {
452 completion->signal(); 452 completion->signal();
453 return; 453 return;
454 } 454 }
455 455
456 m_beginFrameCompletionEventOnImplThread = completion; 456 m_beginFrameCompletionEventOnImplThread = completion;
457 setNeedsForcedCommitOnImplThread(); 457 setNeedsForcedCommitOnImplThread();
458 } 458 }
459 459
460 void CCThreadProxy::scheduledActionBeginFrame() 460 void CCThreadProxy::scheduledActionBeginFrame()
461 { 461 {
462 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); 462 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame");
463 ASSERT(!m_pendingBeginFrameRequest); 463 CC_DCHECK(!m_pendingBeginFrameRequest);
464 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); 464 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState());
465 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime(); 465 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime();
466 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas(); 466 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas();
467 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm(); 467 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo rm();
468 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes(); 468 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes();
469 if (m_layerTreeHost->contentsTextureManager()) 469 if (m_layerTreeHost->contentsTextureManager())
470 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending BeginFrameRequest->evictedContentsTexturesBackings); 470 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending BeginFrameRequest->evictedContentsTexturesBackings);
471 471
472 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame)); 472 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame));
473 473
474 if (m_beginFrameCompletionEventOnImplThread) { 474 if (m_beginFrameCompletionEventOnImplThread) {
475 m_beginFrameCompletionEventOnImplThread->signal(); 475 m_beginFrameCompletionEventOnImplThread->signal();
476 m_beginFrameCompletionEventOnImplThread = 0; 476 m_beginFrameCompletionEventOnImplThread = 0;
477 } 477 }
478 } 478 }
479 479
480 void CCThreadProxy::beginFrame() 480 void CCThreadProxy::beginFrame()
481 { 481 {
482 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); 482 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame");
483 ASSERT(isMainThread()); 483 CC_DCHECK(isMainThread());
484 if (!m_layerTreeHost) 484 if (!m_layerTreeHost)
485 return; 485 return;
486 486
487 if (!m_pendingBeginFrameRequest) { 487 if (!m_pendingBeginFrameRequest) {
488 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); 488 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage");
489 return; 489 return;
490 } 490 }
491 491
492 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext()) 492 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext())
493 WebSharedGraphicsContext3D::createCompositorThreadContext(); 493 WebSharedGraphicsContext3D::createCompositorThreadContext();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 m_totalCommitCount++; 579 m_totalCommitCount++;
580 } 580 }
581 581
582 m_layerTreeHost->commitComplete(); 582 m_layerTreeHost->commitComplete();
583 m_layerTreeHost->didBeginFrame(); 583 m_layerTreeHost->didBeginFrame();
584 } 584 }
585 585
586 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue) 586 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue)
587 { 587 {
588 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); 588 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
589 ASSERT(!m_commitCompletionEventOnImplThread); 589 CC_DCHECK(!m_commitCompletionEventOnImplThread);
590 ASSERT(isImplThread() && isMainThreadBlocked()); 590 CC_DCHECK(isImplThread() && isMainThreadBlocked());
591 ASSERT(m_schedulerOnImplThread); 591 CC_DCHECK(m_schedulerOnImplThread);
592 ASSERT(m_schedulerOnImplThread->commitPending()); 592 CC_DCHECK(m_schedulerOnImplThread->commitPending());
593 593
594 if (!m_layerTreeHostImpl.get()) { 594 if (!m_layerTreeHostImpl.get()) {
595 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 595 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
596 completion->signal(); 596 completion->signal();
597 return; 597 return;
598 } 598 }
599 599
600 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist()) { 600 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist()) {
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 queue->clearUploadsToEvictedResources(); 603 queue->clearUploadsToEvictedResources();
604 // Some textures in the layer tree are invalid. Kick off another commit 604 // Some textures in the layer tree are invalid. Kick off another commit
605 // to fill them again. 605 // to fill them again.
606 setNeedsCommitOnImplThread(); 606 setNeedsCommitOnImplThread();
607 } 607 }
608 608
609 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings() ; 609 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings() ;
610 610
611 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider() , m_layerTreeHostImpl->resourceProvider()->textureUploader()); 611 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider() , m_layerTreeHostImpl->resourceProvider()->textureUploader());
612 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( 612 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(
613 m_schedulerOnImplThread->anticipatedDrawTime()); 613 m_schedulerOnImplThread->anticipatedDrawTime());
614 614
615 m_commitCompletionEventOnImplThread = completion; 615 m_commitCompletionEventOnImplThread = completion;
616 } 616 }
617 617
618 void CCThreadProxy::beginFrameAbortedOnImplThread() 618 void CCThreadProxy::beginFrameAbortedOnImplThread()
619 { 619 {
620 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); 620 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread");
621 ASSERT(isImplThread()); 621 CC_DCHECK(isImplThread());
622 ASSERT(m_schedulerOnImplThread); 622 CC_DCHECK(m_schedulerOnImplThread);
623 ASSERT(m_schedulerOnImplThread->commitPending()); 623 CC_DCHECK(m_schedulerOnImplThread->commitPending());
624 624
625 m_schedulerOnImplThread->beginFrameAborted(); 625 m_schedulerOnImplThread->beginFrameAborted();
626 } 626 }
627 627
628 void CCThreadProxy::scheduledActionCommit() 628 void CCThreadProxy::scheduledActionCommit()
629 { 629 {
630 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); 630 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit");
631 ASSERT(isImplThread()); 631 CC_DCHECK(isImplThread());
632 ASSERT(m_commitCompletionEventOnImplThread); 632 CC_DCHECK(m_commitCompletionEventOnImplThread);
633 ASSERT(m_currentTextureUpdateControllerOnImplThread); 633 CC_DCHECK(m_currentTextureUpdateControllerOnImplThread);
634 634
635 // Complete all remaining texture updates. 635 // Complete all remaining texture updates.
636 m_currentTextureUpdateControllerOnImplThread->finalize(); 636 m_currentTextureUpdateControllerOnImplThread->finalize();
637 m_currentTextureUpdateControllerOnImplThread.clear(); 637 m_currentTextureUpdateControllerOnImplThread.clear();
638 638
639 // If there are linked evicted backings, these backings' resources may be pu t into the 639 // If there are linked evicted backings, these backings' resources may be pu t into the
640 // impl tree, so we can't draw yet. Determine this before clearing all evict ed backings. 640 // impl tree, so we can't draw yet. Determine this before clearing all evict ed backings.
641 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan ager()->linkedEvictedBackingsExist(); 641 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan ager()->linkedEvictedBackingsExist();
642 642
643 m_layerTreeHostImpl->beginCommit(); 643 m_layerTreeHostImpl->beginCommit();
(...skipping 11 matching lines...) Expand all
655 655
656 m_commitCompletionEventOnImplThread->signal(); 656 m_commitCompletionEventOnImplThread->signal();
657 m_commitCompletionEventOnImplThread = 0; 657 m_commitCompletionEventOnImplThread = 0;
658 658
659 // SetVisible kicks off the next scheduler action, so this must be last. 659 // SetVisible kicks off the next scheduler action, so this must be last.
660 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 660 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
661 } 661 }
662 662
663 void CCThreadProxy::scheduledActionBeginContextRecreation() 663 void CCThreadProxy::scheduledActionBeginContextRecreation()
664 { 664 {
665 ASSERT(isImplThread()); 665 CC_DCHECK(isImplThread());
666 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo ntextRecreation)); 666 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo ntextRecreation));
667 } 667 }
668 668
669 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte rnal(bool forcedDraw) 669 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte rnal(bool forcedDraw)
670 { 670 {
671 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap"); 671 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap");
672 CCScheduledActionDrawAndSwapResult result; 672 CCScheduledActionDrawAndSwapResult result;
673 result.didDraw = false; 673 result.didDraw = false;
674 result.didSwap = false; 674 result.didSwap = false;
675 ASSERT(isImplThread()); 675 CC_DCHECK(isImplThread());
676 ASSERT(m_layerTreeHostImpl.get()); 676 CC_DCHECK(m_layerTreeHostImpl.get());
677 if (!m_layerTreeHostImpl.get()) 677 if (!m_layerTreeHostImpl.get())
678 return result; 678 return result;
679 679
680 ASSERT(m_layerTreeHostImpl->renderer()); 680 CC_DCHECK(m_layerTreeHostImpl->renderer());
681 if (!m_layerTreeHostImpl->renderer()) 681 if (!m_layerTreeHostImpl->renderer())
682 return result; 682 return result;
683 683
684 // FIXME: compute the frame display time more intelligently 684 // FIXME: compute the frame display time more intelligently
685 double monotonicTime = monotonicallyIncreasingTime(); 685 double monotonicTime = monotonicallyIncreasingTime();
686 double wallClockTime = currentTime(); 686 double wallClockTime = currentTime();
687 687
688 if (m_inputHandlerOnImplThread.get()) 688 if (m_inputHandlerOnImplThread.get())
689 m_inputHandlerOnImplThread->animate(monotonicTime); 689 m_inputHandlerOnImplThread->animate(monotonicTime);
690 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); 690 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 return result; 727 return result;
728 } 728 }
729 729
730 void CCThreadProxy::acquireLayerTextures() 730 void CCThreadProxy::acquireLayerTextures()
731 { 731 {
732 // Called when the main thread needs to modify a layer texture that is used 732 // Called when the main thread needs to modify a layer texture that is used
733 // directly by the compositor. 733 // directly by the compositor.
734 // This method will block until the next compositor draw if there is a 734 // This method will block until the next compositor draw if there is a
735 // previously committed frame that is still undrawn. This is necessary to 735 // previously committed frame that is still undrawn. This is necessary to
736 // ensure that the main thread does not monopolize access to the textures. 736 // ensure that the main thread does not monopolize access to the textures.
737 ASSERT(isMainThread()); 737 CC_DCHECK(isMainThread());
738 738
739 if (m_texturesAcquired) 739 if (m_texturesAcquired)
740 return; 740 return;
741 741
742 TRACE_EVENT0("cc", "CCThreadProxy::acquireLayerTextures"); 742 TRACE_EVENT0("cc", "CCThreadProxy::acquireLayerTextures");
743 DebugScopedSetMainThreadBlocked mainThreadBlocked; 743 DebugScopedSetMainThreadBlocked mainThreadBlocked;
744 CCCompletionEvent completion; 744 CCCompletionEvent completion;
745 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq uireLayerTexturesForMainThreadOnImplThread, &completion)); 745 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq uireLayerTexturesForMainThreadOnImplThread, &completion));
746 completion.wait(); // Block until it is safe to write to layer textures from the main thread. 746 completion.wait(); // Block until it is safe to write to layer textures from the main thread.
747 747
748 m_texturesAcquired = true; 748 m_texturesAcquired = true;
749 } 749 }
750 750
751 void CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv ent* completion) 751 void CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv ent* completion)
752 { 752 {
753 ASSERT(isImplThread()); 753 CC_DCHECK(isImplThread());
754 ASSERT(!m_textureAcquisitionCompletionEventOnImplThread); 754 CC_DCHECK(!m_textureAcquisitionCompletionEventOnImplThread);
755 755
756 m_textureAcquisitionCompletionEventOnImplThread = completion; 756 m_textureAcquisitionCompletionEventOnImplThread = completion;
757 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures(); 757 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures();
758 } 758 }
759 759
760 void CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread() 760 void CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread()
761 { 761 {
762 ASSERT(m_textureAcquisitionCompletionEventOnImplThread); 762 CC_DCHECK(m_textureAcquisitionCompletionEventOnImplThread);
763 m_textureAcquisitionCompletionEventOnImplThread->signal(); 763 m_textureAcquisitionCompletionEventOnImplThread->signal();
764 m_textureAcquisitionCompletionEventOnImplThread = 0; 764 m_textureAcquisitionCompletionEventOnImplThread = 0;
765 } 765 }
766 766
767 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo ssible() 767 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo ssible()
768 { 768 {
769 return scheduledActionDrawAndSwapInternal(false); 769 return scheduledActionDrawAndSwapInternal(false);
770 } 770 }
771 771
772 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc ed() 772 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc ed()
773 { 773 {
774 return scheduledActionDrawAndSwapInternal(true); 774 return scheduledActionDrawAndSwapInternal(true);
775 } 775 }
776 776
777 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) 777 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time)
778 { 778 {
779 if (!m_currentTextureUpdateControllerOnImplThread) 779 if (!m_currentTextureUpdateControllerOnImplThread)
780 return; 780 return;
781 781
782 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); 782 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time);
783 } 783 }
784 784
785 void CCThreadProxy::readyToFinalizeTextureUpdates() 785 void CCThreadProxy::readyToFinalizeTextureUpdates()
786 { 786 {
787 ASSERT(isImplThread()); 787 CC_DCHECK(isImplThread());
788 m_schedulerOnImplThread->beginFrameComplete(); 788 m_schedulerOnImplThread->beginFrameComplete();
789 } 789 }
790 790
791 void CCThreadProxy::didCommitAndDrawFrame() 791 void CCThreadProxy::didCommitAndDrawFrame()
792 { 792 {
793 ASSERT(isMainThread()); 793 CC_DCHECK(isMainThread());
794 if (!m_layerTreeHost) 794 if (!m_layerTreeHost)
795 return; 795 return;
796 m_layerTreeHost->didCommitAndDrawFrame(); 796 m_layerTreeHost->didCommitAndDrawFrame();
797 } 797 }
798 798
799 void CCThreadProxy::didCompleteSwapBuffers() 799 void CCThreadProxy::didCompleteSwapBuffers()
800 { 800 {
801 ASSERT(isMainThread()); 801 CC_DCHECK(isMainThread());
802 if (!m_layerTreeHost) 802 if (!m_layerTreeHost)
803 return; 803 return;
804 m_layerTreeHost->didCompleteSwapBuffers(); 804 m_layerTreeHost->didCompleteSwapBuffers();
805 } 805 }
806 806
807 void CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d ouble wallClockTime) 807 void CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d ouble wallClockTime)
808 { 808 {
809 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events)); 809 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events));
810 810
811 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents"); 811 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents");
812 ASSERT(isMainThread()); 812 CC_DCHECK(isMainThread());
813 if (!m_layerTreeHost) 813 if (!m_layerTreeHost)
814 return; 814 return;
815 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); 815 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
816 } 816 }
817 817
818 class CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient { 818 class CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient {
819 public: 819 public:
820 static PassOwnPtr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy* proxy) { return adoptPtr(new CCThreadProxyContextRecreationTimer(proxy)); } 820 static PassOwnPtr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy* proxy) { return adoptPtr(new CCThreadProxyContextRecreationTimer(proxy)); }
821 821
822 virtual void onTimerFired() OVERRIDE 822 virtual void onTimerFired() OVERRIDE
823 { 823 {
824 m_proxy->tryToRecreateContext(); 824 m_proxy->tryToRecreateContext();
825 } 825 }
826 826
827 private: 827 private:
828 explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy) 828 explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy)
829 : CCTimer(CCProxy::mainThread(), this) 829 : CCTimer(CCProxy::mainThread(), this)
830 , m_proxy(proxy) 830 , m_proxy(proxy)
831 { 831 {
832 } 832 }
833 833
834 CCThreadProxy* m_proxy; 834 CCThreadProxy* m_proxy;
835 }; 835 };
836 836
837 void CCThreadProxy::beginContextRecreation() 837 void CCThreadProxy::beginContextRecreation()
838 { 838 {
839 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation"); 839 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation");
840 ASSERT(isMainThread()); 840 CC_DCHECK(isMainThread());
841 ASSERT(!m_contextRecreationTimer); 841 CC_DCHECK(!m_contextRecreationTimer);
842 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this) ; 842 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this) ;
843 m_layerTreeHost->didLoseContext(); 843 m_layerTreeHost->didLoseContext();
844 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); 844 m_contextRecreationTimer->startOneShot(contextRecreationTickRate);
845 } 845 }
846 846
847 void CCThreadProxy::tryToRecreateContext() 847 void CCThreadProxy::tryToRecreateContext()
848 { 848 {
849 ASSERT(isMainThread()); 849 CC_DCHECK(isMainThread());
850 ASSERT(m_layerTreeHost); 850 CC_DCHECK(m_layerTreeHost);
851 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); 851 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext();
852 if (result == CCLayerTreeHost::RecreateFailedButTryAgain) 852 if (result == CCLayerTreeHost::RecreateFailedButTryAgain)
853 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); 853 m_contextRecreationTimer->startOneShot(contextRecreationTickRate);
854 else if (result == CCLayerTreeHost::RecreateSucceeded) 854 else if (result == CCLayerTreeHost::RecreateSucceeded)
855 m_contextRecreationTimer.clear(); 855 m_contextRecreationTimer.clear();
856 } 856 }
857 857
858 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC InputHandler* handler) 858 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC InputHandler* handler)
859 { 859 {
860 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread"); 860 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread");
861 ASSERT(isImplThread()); 861 CC_DCHECK(isImplThread());
862 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); 862 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
863 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec onds(base::Time::kMicrosecondsPerSecond / 60); 863 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec onds(base::Time::kMicrosecondsPerSecond / 60);
864 scoped_ptr<CCFrameRateController> frameRateController; 864 scoped_ptr<CCFrameRateController> frameRateController;
865 if (m_renderVSyncEnabled) 865 if (m_renderVSyncEnabled)
866 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour ce::create(displayRefreshInterval, CCProxy::implThread()))); 866 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour ce::create(displayRefreshInterval, CCProxy::implThread())));
867 else 867 else
868 frameRateController.reset(new CCFrameRateController(CCProxy::implThread( ))); 868 frameRateController.reset(new CCFrameRateController(CCProxy::implThread( )));
869 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass ()); 869 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass ());
870 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 870 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
871 871
872 m_inputHandlerOnImplThread = scoped_ptr<CCInputHandler>(handler); 872 m_inputHandlerOnImplThread = scoped_ptr<CCInputHandler>(handler);
873 if (m_inputHandlerOnImplThread.get()) 873 if (m_inputHandlerOnImplThread.get())
874 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); 874 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get());
875 875
876 completion->signal(); 876 completion->signal();
877 } 877 }
878 878
879 void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context) 879 void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context)
880 { 880 {
881 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread"); 881 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread");
882 ASSERT(isImplThread()); 882 CC_DCHECK(isImplThread());
883 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co ntext).Pass(); 883 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co ntext).Pass();
884 } 884 }
885 885
886 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion , bool* initializeSucceeded, RendererCapabilities* capabilities) 886 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion , bool* initializeSucceeded, RendererCapabilities* capabilities)
887 { 887 {
888 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread"); 888 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread");
889 ASSERT(isImplThread()); 889 CC_DCHECK(isImplThread());
890 ASSERT(m_contextBeforeInitializationOnImplThread.get()); 890 CC_DCHECK(m_contextBeforeInitializationOnImplThread.get());
891 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo reInitializationOnImplThread.Pass()); 891 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo reInitializationOnImplThread.Pass());
892 if (*initializeSucceeded) { 892 if (*initializeSucceeded) {
893 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 893 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
894 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( 894 m_schedulerOnImplThread->setSwapBuffersCompleteSupported(
895 capabilities->usingSwapCompleteCallback); 895 capabilities->usingSwapCompleteCallback);
896 } 896 }
897 897
898 completion->signal(); 898 completion->signal();
899 } 899 }
900 900
901 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio n) 901 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio n)
902 { 902 {
903 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); 903 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread");
904 ASSERT(isImplThread()); 904 CC_DCHECK(isImplThread());
905 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider()); 905 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider());
906 m_inputHandlerOnImplThread.reset(); 906 m_inputHandlerOnImplThread.reset();
907 m_layerTreeHostImpl.reset(); 907 m_layerTreeHostImpl.reset();
908 m_schedulerOnImplThread.clear(); 908 m_schedulerOnImplThread.clear();
909 completion->signal(); 909 completion->signal();
910 } 910 }
911 911
912 void CCThreadProxy::setFullRootLayerDamageOnImplThread() 912 void CCThreadProxy::setFullRootLayerDamageOnImplThread()
913 { 913 {
914 ASSERT(isImplThread()); 914 CC_DCHECK(isImplThread());
915 m_layerTreeHostImpl->setFullRootLayerDamage(); 915 m_layerTreeHostImpl->setFullRootLayerDamage();
916 } 916 }
917 917
918 size_t CCThreadProxy::maxPartialTextureUpdates() const 918 size_t CCThreadProxy::maxPartialTextureUpdates() const
919 { 919 {
920 return CCTextureUpdateController::maxPartialTextureUpdates(); 920 return CCTextureUpdateController::maxPartialTextureUpdates();
921 } 921 }
922 922
923 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities) 923 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities)
924 { 924 {
925 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); 925 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread");
926 ASSERT(isImplThread()); 926 CC_DCHECK(isImplThread());
927 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider()); 927 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider());
928 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<CCGr aphicsContext>(contextPtr).Pass()); 928 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<CCGr aphicsContext>(contextPtr).Pass());
929 if (*recreateSucceeded) { 929 if (*recreateSucceeded) {
930 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 930 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
931 m_schedulerOnImplThread->didRecreateContext(); 931 m_schedulerOnImplThread->didRecreateContext();
932 } 932 }
933 completion->signal(); 933 completion->signal();
934 } 934 }
935 935
936 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC RenderingStats* stats) 936 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC RenderingStats* stats)
937 { 937 {
938 ASSERT(isImplThread()); 938 CC_DCHECK(isImplThread());
939 m_layerTreeHostImpl->renderingStats(stats); 939 m_layerTreeHostImpl->renderingStats(stats);
940 completion->signal(); 940 completion->signal();
941 } 941 }
942 942
943 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 943 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
944 : monotonicFrameBeginTime(0) 944 : monotonicFrameBeginTime(0)
945 { 945 {
946 } 946 }
947 947
948 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 948 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
949 { 949 {
950 } 950 }
951 951
952 } // namespace cc 952 } // namespace cc
OLDNEW
« no previous file with comments | « cc/texture_layer_impl.cc ('k') | cc/threaded_unittest.cc » ('j') | cc/yuv_video_draw_quad.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698