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

Side by Side Diff: cc/single_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/single_thread_proxy.h" 5 #include "cc/single_thread_proxy.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/draw_quad.h" 8 #include "cc/draw_quad.h"
9 #include "cc/layer_tree_host.h" 9 #include "cc/layer_tree_host.h"
10 #include "cc/output_surface.h" 10 #include "cc/output_surface.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect ) 46 bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect )
47 { 47 {
48 TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback"); 48 TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback");
49 DCHECK(Proxy::isMainThread()); 49 DCHECK(Proxy::isMainThread());
50 50
51 if (!commitAndComposite()) 51 if (!commitAndComposite())
52 return false; 52 return false;
53 53
54 m_layerTreeHostImpl->readback(pixels, rect); 54 {
55 DebugScopedSetImplThread impl(this);
56 m_layerTreeHostImpl->readback(pixels, rect);
55 57
56 if (m_layerTreeHostImpl->isContextLost()) 58 if (m_layerTreeHostImpl->isContextLost())
57 return false; 59 return false;
58 60
59 m_layerTreeHostImpl->swapBuffers(); 61 m_layerTreeHostImpl->swapBuffers();
62 }
60 didSwapFrame(); 63 didSwapFrame();
61 64
62 return true; 65 return true;
63 } 66 }
64 67
65 void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) 68 void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration)
66 { 69 {
67 m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration); 70 m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale, base::TimeTicks::Now(), duration);
68 } 71 }
69 72
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const RendererCapabilities& SingleThreadProxy::rendererCapabilities() const 160 const RendererCapabilities& SingleThreadProxy::rendererCapabilities() const
158 { 161 {
159 DCHECK(m_rendererInitialized); 162 DCHECK(m_rendererInitialized);
160 // Note: this gets called during the commit by the "impl" thread 163 // Note: this gets called during the commit by the "impl" thread
161 return m_RendererCapabilitiesForMainThread; 164 return m_RendererCapabilitiesForMainThread;
162 } 165 }
163 166
164 void SingleThreadProxy::loseOutputSurface() 167 void SingleThreadProxy::loseOutputSurface()
165 { 168 {
166 DCHECK(Proxy::isMainThread()); 169 DCHECK(Proxy::isMainThread());
167 m_layerTreeHost->didLoseOutputSurface(); 170
168 m_outputSurfaceLost = true; 171 DebugScopedSetImplThread impl(this);
172 m_layerTreeHostImpl->resourceProvider()->loseOutputSurface();
169 } 173 }
170 174
171 void SingleThreadProxy::setNeedsAnimate() 175 void SingleThreadProxy::setNeedsAnimate()
172 { 176 {
173 // Thread-only feature 177 // Thread-only feature
174 NOTREACHED(); 178 NOTREACHED();
175 } 179 }
176 180
177 void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue) 181 void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue)
178 { 182 {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return; 307 return;
304 if (!m_layerTreeHost->contentsTextureManager()) 308 if (!m_layerTreeHost->contentsTextureManager())
305 return; 309 return;
306 310
307 m_layerTreeHostImpl->sendManagedMemoryStats( 311 m_layerTreeHostImpl->sendManagedMemoryStats(
308 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), 312 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(),
309 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes() , 313 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes() ,
310 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); 314 m_layerTreeHost->contentsTextureManager()->memoryUseBytes());
311 } 315 }
312 316
317 void SingleThreadProxy::didLoseOutputSurfaceOnImplThread()
318 {
319 // Cause a commit so we can notice the lost context.
320 setNeedsCommitOnImplThread();
321 }
322
313 // Called by the legacy scheduling path (e.g. where render_widget does the sched uling) 323 // Called by the legacy scheduling path (e.g. where render_widget does the sched uling)
314 void SingleThreadProxy::compositeImmediately() 324 void SingleThreadProxy::compositeImmediately()
315 { 325 {
316 if (commitAndComposite()) { 326 if (commitAndComposite()) {
317 m_layerTreeHostImpl->swapBuffers(); 327 m_layerTreeHostImpl->swapBuffers();
318 didSwapFrame(); 328 didSwapFrame();
319 } 329 }
320 } 330 }
321 331
322 void SingleThreadProxy::forceSerializeOnSwapBuffers() 332 void SingleThreadProxy::forceSerializeOnSwapBuffers()
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only 382 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only
373 // be used when such a frame is possible. Since drawLayers() depends on the result of 383 // be used when such a frame is possible. Since drawLayers() depends on the result of
374 // prepareToDraw(), it is guarded on canDraw() as well. 384 // prepareToDraw(), it is guarded on canDraw() as well.
375 if (!m_layerTreeHostImpl->canDraw()) 385 if (!m_layerTreeHostImpl->canDraw())
376 return false; 386 return false;
377 387
378 LayerTreeHostImpl::FrameData frame; 388 LayerTreeHostImpl::FrameData frame;
379 m_layerTreeHostImpl->prepareToDraw(frame); 389 m_layerTreeHostImpl->prepareToDraw(frame);
380 m_layerTreeHostImpl->drawLayers(frame); 390 m_layerTreeHostImpl->drawLayers(frame);
381 m_layerTreeHostImpl->didDrawAllLayers(frame); 391 m_layerTreeHostImpl->didDrawAllLayers(frame);
392 m_outputSurfaceLost = m_layerTreeHostImpl->isContextLost();
382 } 393 }
383 394
384 if (m_layerTreeHostImpl->isContextLost()) { 395 if (m_outputSurfaceLost) {
385 m_outputSurfaceLost = true;
386 m_layerTreeHost->didLoseOutputSurface(); 396 m_layerTreeHost->didLoseOutputSurface();
387 return false; 397 return false;
388 } 398 }
389 399
390 return true; 400 return true;
391 } 401 }
392 402
393 void SingleThreadProxy::didSwapFrame() 403 void SingleThreadProxy::didSwapFrame()
394 { 404 {
395 if (m_nextFrameIsNewlyCommittedFrame) { 405 if (m_nextFrameIsNewlyCommittedFrame) {
396 m_nextFrameIsNewlyCommittedFrame = false; 406 m_nextFrameIsNewlyCommittedFrame = false;
397 m_layerTreeHost->didCommitAndDrawFrame(); 407 m_layerTreeHost->didCommitAndDrawFrame();
398 } 408 }
399 } 409 }
400 410
401 bool SingleThreadProxy::commitPendingForTesting() 411 bool SingleThreadProxy::commitPendingForTesting()
402 { 412 {
403 return false; 413 return false;
404 } 414 }
405 415
406 } // namespace cc 416 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698