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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
8 #include "cc/draw_quad.h" | 9 #include "cc/draw_quad.h" |
9 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
10 #include "cc/output_surface.h" | 11 #include "cc/output_surface.h" |
11 #include "cc/prioritized_resource_manager.h" | 12 #include "cc/prioritized_resource_manager.h" |
12 #include "cc/resource_update_controller.h" | 13 #include "cc/resource_update_controller.h" |
13 #include "cc/thread.h" | 14 #include "cc/thread.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
17 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) | 18 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) |
18 { | 19 { |
19 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>()
; | 20 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>()
; |
20 } | 21 } |
21 | 22 |
22 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) | 23 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) |
23 : Proxy(scoped_ptr<Thread>(NULL)) | 24 : Proxy(scoped_ptr<Thread>(NULL)) |
24 , m_layerTreeHost(layerTreeHost) | 25 , m_layerTreeHost(layerTreeHost) |
25 , m_outputSurfaceLost(false) | 26 , m_outputSurfaceLost(false) |
26 , m_rendererInitialized(false) | 27 , m_rendererInitialized(false) |
27 , m_nextFrameIsNewlyCommittedFrame(false) | 28 , m_nextFrameIsNewlyCommittedFrame(false) |
| 29 , m_insideDraw(false) |
28 , m_totalCommitCount(0) | 30 , m_totalCommitCount(0) |
29 { | 31 { |
30 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 32 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
31 DCHECK(Proxy::isMainThread()); | 33 DCHECK(Proxy::isMainThread()); |
32 DCHECK(layerTreeHost); | 34 DCHECK(layerTreeHost); |
33 | 35 |
34 // Impl-side painting not supported without threaded compositing | 36 // Impl-side painting not supported without threaded compositing |
35 DCHECK(!layerTreeHost->settings().implSidePainting); | 37 DCHECK(!layerTreeHost->settings().implSidePainting); |
36 } | 38 } |
37 | 39 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 m_layerTreeHostImpl.reset(); | 264 m_layerTreeHostImpl.reset(); |
263 } | 265 } |
264 m_layerTreeHost = 0; | 266 m_layerTreeHost = 0; |
265 } | 267 } |
266 | 268 |
267 void SingleThreadProxy::setNeedsRedrawOnImplThread() | 269 void SingleThreadProxy::setNeedsRedrawOnImplThread() |
268 { | 270 { |
269 m_layerTreeHost->scheduleComposite(); | 271 m_layerTreeHost->scheduleComposite(); |
270 } | 272 } |
271 | 273 |
| 274 void SingleThreadProxy::didSwapUseIncompleteTextureOnImplThread() |
| 275 { |
| 276 // implSidePainting only. |
| 277 NOTREACHED(); |
| 278 } |
| 279 |
| 280 void SingleThreadProxy::didUploadVisibleHighResolutionTileOnImplTread() |
| 281 { |
| 282 // implSidePainting only. |
| 283 NOTREACHED(); |
| 284 } |
| 285 |
272 void SingleThreadProxy::setNeedsCommitOnImplThread() | 286 void SingleThreadProxy::setNeedsCommitOnImplThread() |
273 { | 287 { |
274 m_layerTreeHost->scheduleComposite(); | 288 m_layerTreeHost->scheduleComposite(); |
275 } | 289 } |
276 | 290 |
277 void SingleThreadProxy::setNeedsManageTilesOnImplThread() | 291 void SingleThreadProxy::setNeedsManageTilesOnImplThread() |
278 { | 292 { |
279 m_layerTreeHost->scheduleComposite(); | 293 m_layerTreeHost->scheduleComposite(); |
280 } | 294 } |
281 | 295 |
(...skipping 20 matching lines...) Expand all Loading... |
302 return; | 316 return; |
303 if (!m_layerTreeHost->contentsTextureManager()) | 317 if (!m_layerTreeHost->contentsTextureManager()) |
304 return; | 318 return; |
305 | 319 |
306 m_layerTreeHostImpl->sendManagedMemoryStats( | 320 m_layerTreeHostImpl->sendManagedMemoryStats( |
307 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), | 321 m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), |
308 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
, | 322 m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes()
, |
309 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); | 323 m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); |
310 } | 324 } |
311 | 325 |
| 326 bool SingleThreadProxy::isInsideDraw() |
| 327 { |
| 328 return m_insideDraw; |
| 329 } |
| 330 |
312 // Called by the legacy scheduling path (e.g. where render_widget does the sched
uling) | 331 // Called by the legacy scheduling path (e.g. where render_widget does the sched
uling) |
313 void SingleThreadProxy::compositeImmediately() | 332 void SingleThreadProxy::compositeImmediately() |
314 { | 333 { |
315 if (commitAndComposite()) { | 334 if (commitAndComposite()) { |
316 m_layerTreeHostImpl->swapBuffers(); | 335 m_layerTreeHostImpl->swapBuffers(); |
317 didSwapFrame(); | 336 didSwapFrame(); |
318 } | 337 } |
319 } | 338 } |
320 | 339 |
321 void SingleThreadProxy::forceSerializeOnSwapBuffers() | 340 void SingleThreadProxy::forceSerializeOnSwapBuffers() |
(...skipping 30 matching lines...) Expand all Loading... |
352 bool result = doComposite(); | 371 bool result = doComposite(); |
353 m_layerTreeHost->didBeginFrame(); | 372 m_layerTreeHost->didBeginFrame(); |
354 return result; | 373 return result; |
355 } | 374 } |
356 | 375 |
357 bool SingleThreadProxy::doComposite() | 376 bool SingleThreadProxy::doComposite() |
358 { | 377 { |
359 DCHECK(!m_outputSurfaceLost); | 378 DCHECK(!m_outputSurfaceLost); |
360 { | 379 { |
361 DebugScopedSetImplThread impl(this); | 380 DebugScopedSetImplThread impl(this); |
| 381 base::AutoReset<bool> markInside(&m_insideDraw, true); |
362 | 382 |
363 if (!m_layerTreeHostImpl->visible()) | 383 if (!m_layerTreeHostImpl->visible()) |
364 return false; | 384 return false; |
365 | 385 |
366 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); | 386 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
367 | 387 |
368 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only | 388 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only |
369 // be used when such a frame is possible. Since drawLayers() depends on
the result of | 389 // be used when such a frame is possible. Since drawLayers() depends on
the result of |
370 // prepareToDraw(), it is guarded on canDraw() as well. | 390 // prepareToDraw(), it is guarded on canDraw() as well. |
371 if (!m_layerTreeHostImpl->canDraw()) | 391 if (!m_layerTreeHostImpl->canDraw()) |
(...skipping 28 matching lines...) Expand all Loading... |
400 } | 420 } |
401 | 421 |
402 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 422 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() |
403 { | 423 { |
404 // Requires impl-side painting, which is only supported in threaded composit
ing. | 424 // Requires impl-side painting, which is only supported in threaded composit
ing. |
405 NOTREACHED(); | 425 NOTREACHED(); |
406 return skia::RefPtr<SkPicture>(); | 426 return skia::RefPtr<SkPicture>(); |
407 } | 427 } |
408 | 428 |
409 } // namespace cc | 429 } // namespace cc |
OLD | NEW |