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

Side by Side Diff: cc/thread_proxy.cc

Issue 11606012: cc: Unify context losing machinery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
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 "cc/thread_proxy.h" 5 #include "cc/thread_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/delay_based_time_source.h" 9 #include "cc/delay_based_time_source.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
11 #include "cc/frame_rate_controller.h" 11 #include "cc/frame_rate_controller.h"
12 #include "cc/input_handler.h" 12 #include "cc/input_handler.h"
13 #include "cc/layer_tree_host.h" 13 #include "cc/layer_tree_host.h"
14 #include "cc/output_surface.h" 14 #include "cc/output_surface.h"
15 #include "cc/resource_provider.h"
15 #include "cc/scheduler.h" 16 #include "cc/scheduler.h"
16 #include "cc/scoped_thread_proxy.h" 17 #include "cc/scoped_thread_proxy.h"
17 #include "cc/thread.h" 18 #include "cc/thread.h"
18 #include <public/WebSharedGraphicsContext3D.h> 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo ntext3D.h"
19 21
20 using WebKit::WebSharedGraphicsContext3D; 22 using WebKit::WebSharedGraphicsContext3D;
21 23
22 namespace { 24 namespace {
23 25
24 // Measured in seconds. 26 // Measured in seconds.
25 const double contextRecreationTickRate = 0.03; 27 const double contextRecreationTickRate = 0.03;
26 28
27 } // namespace 29 } // namespace
28 30
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 260 }
259 261
260 const RendererCapabilities& ThreadProxy::rendererCapabilities() const 262 const RendererCapabilities& ThreadProxy::rendererCapabilities() const
261 { 263 {
262 DCHECK(m_rendererInitialized); 264 DCHECK(m_rendererInitialized);
263 return m_RendererCapabilitiesMainThreadCopy; 265 return m_RendererCapabilitiesMainThreadCopy;
264 } 266 }
265 267
266 void ThreadProxy::loseOutputSurface() 268 void ThreadProxy::loseOutputSurface()
267 { 269 {
268 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseOutputSurfaceO nImplThread, base::Unretained(this))); 270 DCHECK(isMainThread());
271 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::loseOutputSurfaceOnIm plThread, base::Unretained(this)));
272 }
273
274 void ThreadProxy::loseOutputSurfaceOnImplThread()
275 {
276 DCHECK(isImplThread());
277 m_layerTreeHostImpl->resourceProvider()->loseOutputSurface();
269 } 278 }
270 279
271 void ThreadProxy::setNeedsAnimate() 280 void ThreadProxy::setNeedsAnimate()
272 { 281 {
273 DCHECK(isMainThread()); 282 DCHECK(isMainThread());
274 if (m_animateRequested) 283 if (m_animateRequested)
275 return; 284 return;
276 285
277 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); 286 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate");
278 m_animateRequested = true; 287 m_animateRequested = true;
(...skipping 15 matching lines...) Expand all
294 if (m_commitRequestSentToImplThread) 303 if (m_commitRequestSentToImplThread)
295 return; 304 return;
296 m_commitRequestSentToImplThread = true; 305 m_commitRequestSentToImplThread = true;
297 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, base::Unretained(this))); 306 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, base::Unretained(this)));
298 } 307 }
299 308
300 void ThreadProxy::didLoseOutputSurfaceOnImplThread() 309 void ThreadProxy::didLoseOutputSurfaceOnImplThread()
301 { 310 {
302 DCHECK(isImplThread()); 311 DCHECK(isImplThread());
303 TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread"); 312 TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread");
313 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::checkLostOutputSurfac eOnImplThread, base::Unretained(this)));
jamesr 2012/12/18 05:44:41 hmmm - how is this base::Unretained(this) safe? i.
314 }
315
316 void ThreadProxy::checkLostOutputSurfaceOnImplThread()
317 {
318 DCHECK(isImplThread());
319 TRACE_EVENT0("cc", "ThreadProxy::checkLostContextOnImplThread");
320 if (!m_layerTreeHostImpl->isContextLost())
321 return;
304 m_schedulerOnImplThread->didLoseOutputSurface(); 322 m_schedulerOnImplThread->didLoseOutputSurface();
305 } 323 }
306 324
307 void ThreadProxy::onSwapBuffersCompleteOnImplThread() 325 void ThreadProxy::onSwapBuffersCompleteOnImplThread()
308 { 326 {
309 DCHECK(isImplThread()); 327 DCHECK(isImplThread());
310 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); 328 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread");
311 m_schedulerOnImplThread->didSwapBuffersComplete(); 329 m_schedulerOnImplThread->didSwapBuffersComplete();
312 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteS wapBuffers, base::Unretained(this))); 330 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteS wapBuffers, base::Unretained(this)));
313 } 331 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 m_readbackRequestOnImplThread = 0; 791 m_readbackRequestOnImplThread = 0;
774 } else if (drawFrame) 792 } else if (drawFrame)
775 result.didSwap = m_layerTreeHostImpl->swapBuffers(); 793 result.didSwap = m_layerTreeHostImpl->swapBuffers();
776 794
777 // Tell the main thread that the the newly-commited frame was drawn. 795 // Tell the main thread that the the newly-commited frame was drawn.
778 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { 796 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) {
779 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; 797 m_nextFrameIsNewlyCommittedFrameOnImplThread = false;
780 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCommi tAndDrawFrame, base::Unretained(this))); 798 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCommi tAndDrawFrame, base::Unretained(this)));
781 } 799 }
782 800
801 if (drawFrame)
802 checkLostOutputSurfaceOnImplThread();
803
783 return result; 804 return result;
784 } 805 }
785 806
786 void ThreadProxy::acquireLayerTextures() 807 void ThreadProxy::acquireLayerTextures()
787 { 808 {
788 // Called when the main thread needs to modify a layer texture that is used 809 // Called when the main thread needs to modify a layer texture that is used
789 // directly by the compositor. 810 // directly by the compositor.
790 // This method will block until the next compositor draw if there is a 811 // This method will block until the next compositor draw if there is a
791 // previously committed frame that is still undrawn. This is necessary to 812 // previously committed frame that is still undrawn. This is necessary to
792 // ensure that the main thread does not monopolize access to the textures. 813 // ensure that the main thread does not monopolize access to the textures.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 } 1017 }
997 1018
998 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est) 1019 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est)
999 { 1020 {
1000 DCHECK(isImplThread()); 1021 DCHECK(isImplThread());
1001 request->commitPending = m_schedulerOnImplThread->commitPending(); 1022 request->commitPending = m_schedulerOnImplThread->commitPending();
1002 request->completion.signal(); 1023 request->completion.signal();
1003 } 1024 }
1004 1025
1005 } // namespace cc 1026 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698