| OLD | NEW | 
|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "cc/single_thread_proxy.h" | 5 #include "cc/single_thread_proxy.h" | 
| 6 | 6 | 
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" | 
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" | 
| 9 #include "cc/draw_quad.h" | 9 #include "cc/draw_quad.h" | 
| 10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 52 } | 52 } | 
| 53 | 53 | 
| 54 bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect
     ) | 54 bool SingleThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect
     ) | 
| 55 { | 55 { | 
| 56     TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback"); | 56     TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback"); | 
| 57     DCHECK(Proxy::isMainThread()); | 57     DCHECK(Proxy::isMainThread()); | 
| 58 | 58 | 
| 59     if (!commitAndComposite()) | 59     if (!commitAndComposite()) | 
| 60         return false; | 60         return false; | 
| 61 | 61 | 
| 62     m_layerTreeHostImpl->readback(pixels, rect); | 62     { | 
|  | 63         DebugScopedSetImplThread impl(this); | 
|  | 64         m_layerTreeHostImpl->readback(pixels, rect); | 
| 63 | 65 | 
| 64     if (m_layerTreeHostImpl->isContextLost()) | 66         if (m_layerTreeHostImpl->isContextLost()) | 
| 65         return false; | 67             return false; | 
| 66 | 68 | 
| 67     m_layerTreeHostImpl->swapBuffers(); | 69         m_layerTreeHostImpl->swapBuffers(); | 
|  | 70     } | 
| 68     didSwapFrame(); | 71     didSwapFrame(); | 
| 69 | 72 | 
| 70     return true; | 73     return true; | 
| 71 } | 74 } | 
| 72 | 75 | 
| 73 void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
      useAnchor, float scale, base::TimeDelta duration) | 76 void SingleThreadProxy::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
      useAnchor, float scale, base::TimeDelta duration) | 
| 74 { | 77 { | 
| 75     m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale,
      base::TimeTicks::Now(), duration); | 78     m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, scale,
      base::TimeTicks::Now(), duration); | 
| 76 } | 79 } | 
| 77 | 80 | 
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 322         m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), | 325         m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), | 
| 323         m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
     , | 326         m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
     , | 
| 324         m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); | 327         m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); | 
| 325 } | 328 } | 
| 326 | 329 | 
| 327 bool SingleThreadProxy::isInsideDraw() | 330 bool SingleThreadProxy::isInsideDraw() | 
| 328 { | 331 { | 
| 329     return m_insideDraw; | 332     return m_insideDraw; | 
| 330 } | 333 } | 
| 331 | 334 | 
|  | 335 void SingleThreadProxy::didLoseOutputSurfaceOnImplThread() | 
|  | 336 { | 
|  | 337     // Cause a commit so we can notice the lost context. | 
|  | 338     setNeedsCommitOnImplThread(); | 
|  | 339 } | 
|  | 340 | 
| 332 // Called by the legacy scheduling path (e.g. where render_widget does the sched
     uling) | 341 // Called by the legacy scheduling path (e.g. where render_widget does the sched
     uling) | 
| 333 void SingleThreadProxy::compositeImmediately() | 342 void SingleThreadProxy::compositeImmediately() | 
| 334 { | 343 { | 
| 335     if (commitAndComposite()) { | 344     if (commitAndComposite()) { | 
| 336         m_layerTreeHostImpl->swapBuffers(); | 345         m_layerTreeHostImpl->swapBuffers(); | 
| 337         didSwapFrame(); | 346         didSwapFrame(); | 
| 338     } | 347     } | 
| 339 } | 348 } | 
| 340 | 349 | 
| 341 void SingleThreadProxy::forceSerializeOnSwapBuffers() | 350 void SingleThreadProxy::forceSerializeOnSwapBuffers() | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 386         // We guard prepareToDraw() with canDraw() because it always returns a v
     alid frame, so can only | 395         // We guard prepareToDraw() with canDraw() because it always returns a v
     alid frame, so can only | 
| 387         // be used when such a frame is possible. Since drawLayers() depends on 
     the result of | 396         // be used when such a frame is possible. Since drawLayers() depends on 
     the result of | 
| 388         // prepareToDraw(), it is guarded on canDraw() as well. | 397         // prepareToDraw(), it is guarded on canDraw() as well. | 
| 389         if (!m_layerTreeHostImpl->canDraw()) | 398         if (!m_layerTreeHostImpl->canDraw()) | 
| 390             return false; | 399             return false; | 
| 391 | 400 | 
| 392         LayerTreeHostImpl::FrameData frame; | 401         LayerTreeHostImpl::FrameData frame; | 
| 393         m_layerTreeHostImpl->prepareToDraw(frame); | 402         m_layerTreeHostImpl->prepareToDraw(frame); | 
| 394         m_layerTreeHostImpl->drawLayers(frame); | 403         m_layerTreeHostImpl->drawLayers(frame); | 
| 395         m_layerTreeHostImpl->didDrawAllLayers(frame); | 404         m_layerTreeHostImpl->didDrawAllLayers(frame); | 
|  | 405         m_outputSurfaceLost = m_layerTreeHostImpl->isContextLost(); | 
| 396     } | 406     } | 
| 397 | 407 | 
| 398     if (m_layerTreeHostImpl->isContextLost()) { | 408     if (m_outputSurfaceLost) { | 
| 399         m_outputSurfaceLost = true; |  | 
| 400         m_layerTreeHost->didLoseOutputSurface(); | 409         m_layerTreeHost->didLoseOutputSurface(); | 
| 401         return false; | 410         return false; | 
| 402     } | 411     } | 
| 403 | 412 | 
| 404     return true; | 413     return true; | 
| 405 } | 414 } | 
| 406 | 415 | 
| 407 void SingleThreadProxy::didSwapFrame() | 416 void SingleThreadProxy::didSwapFrame() | 
| 408 { | 417 { | 
| 409     if (m_nextFrameIsNewlyCommittedFrame) { | 418     if (m_nextFrameIsNewlyCommittedFrame) { | 
| 410         m_nextFrameIsNewlyCommittedFrame = false; | 419         m_nextFrameIsNewlyCommittedFrame = false; | 
| 411         m_layerTreeHost->didCommitAndDrawFrame(); | 420         m_layerTreeHost->didCommitAndDrawFrame(); | 
| 412     } | 421     } | 
| 413 } | 422 } | 
| 414 | 423 | 
| 415 bool SingleThreadProxy::commitPendingForTesting() | 424 bool SingleThreadProxy::commitPendingForTesting() | 
| 416 { | 425 { | 
| 417     return false; | 426     return false; | 
| 418 } | 427 } | 
| 419 | 428 | 
| 420 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 429 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 
| 421 { | 430 { | 
| 422     // Requires impl-side painting, which is only supported in threaded composit
     ing. | 431     // Requires impl-side painting, which is only supported in threaded composit
     ing. | 
| 423     NOTREACHED(); | 432     NOTREACHED(); | 
| 424     return skia::RefPtr<SkPicture>(); | 433     return skia::RefPtr<SkPicture>(); | 
| 425 } | 434 } | 
| 426 | 435 | 
| 427 }  // namespace cc | 436 }  // namespace cc | 
| OLD | NEW | 
|---|