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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
10 #include "cc/graphics_context.h" | 10 #include "cc/graphics_context.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 virtual void didCommit() OVERRIDE | 309 virtual void didCommit() OVERRIDE |
310 { | 310 { |
311 m_numCommits++; | 311 m_numCommits++; |
312 if (m_numCommits == 1) { | 312 if (m_numCommits == 1) { |
313 // Make the viewport empty so the host says it can't draw. | 313 // Make the viewport empty so the host says it can't draw. |
314 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); | 314 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); |
315 | 315 |
316 scoped_array<char> pixels(new char[4]); | 316 char pixels[4]; |
317 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get(
)), gfx::Rect(0, 0, 1, 1)); | 317 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
318 } else if (m_numCommits == 2) { | 318 } else if (m_numCommits == 2) { |
319 m_layerTreeHost->setNeedsRedraw(); | 319 m_layerTreeHost->setNeedsRedraw(); |
320 m_layerTreeHost->setNeedsCommit(); | 320 m_layerTreeHost->setNeedsCommit(); |
321 } else | 321 } else |
322 endTest(); | 322 endTest(); |
323 } | 323 } |
324 | 324 |
325 virtual void afterTest() OVERRIDE | 325 virtual void afterTest() OVERRIDE |
326 { | 326 { |
327 } | 327 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 postSetNeedsCommitToMainThread(); | 431 postSetNeedsCommitToMainThread(); |
432 } | 432 } |
433 | 433 |
434 virtual void didCommitAndDrawFrame() OVERRIDE | 434 virtual void didCommitAndDrawFrame() OVERRIDE |
435 { | 435 { |
436 m_numCommits++; | 436 m_numCommits++; |
437 if (m_numCommits == 1) { | 437 if (m_numCommits == 1) { |
438 m_layerTreeHost->setVisible(false); | 438 m_layerTreeHost->setVisible(false); |
439 m_layerTreeHost->setNeedsCommit(); | 439 m_layerTreeHost->setNeedsCommit(); |
440 m_layerTreeHost->setNeedsCommit(); | 440 m_layerTreeHost->setNeedsCommit(); |
441 scoped_array<char> pixels(new char[4]); | 441 char pixels[4]; |
442 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get(
)), gfx::Rect(0, 0, 1, 1)); | 442 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
443 } else | 443 } else |
444 endTest(); | 444 endTest(); |
445 | 445 |
446 } | 446 } |
447 | 447 |
448 virtual void afterTest() OVERRIDE | 448 virtual void afterTest() OVERRIDE |
449 { | 449 { |
450 } | 450 } |
451 | 451 |
452 private: | 452 private: |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 } | 2463 } |
2464 | 2464 |
2465 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest { | 2465 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest { |
2466 public: | 2466 public: |
2467 LayerTreeHostTestCompositeAndReadbackCleanup() { } | 2467 LayerTreeHostTestCompositeAndReadbackCleanup() { } |
2468 | 2468 |
2469 virtual void beginTest() OVERRIDE | 2469 virtual void beginTest() OVERRIDE |
2470 { | 2470 { |
2471 Layer* rootLayer = m_layerTreeHost->rootLayer(); | 2471 Layer* rootLayer = m_layerTreeHost->rootLayer(); |
2472 | 2472 |
2473 scoped_array<char> pixels(new char[4]); | 2473 char pixels[4]; |
2474 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get()),
gfx::Rect(0, 0, 1, 1)); | 2474 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::
Rect(0, 0, 1, 1)); |
2475 EXPECT_FALSE(rootLayer->renderSurface()); | 2475 EXPECT_FALSE(rootLayer->renderSurface()); |
2476 | 2476 |
2477 endTest(); | 2477 endTest(); |
2478 } | 2478 } |
2479 | 2479 |
2480 virtual void afterTest() OVERRIDE | 2480 virtual void afterTest() OVERRIDE |
2481 { | 2481 { |
2482 } | 2482 } |
2483 }; | 2483 }; |
2484 | 2484 |
2485 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup) | 2485 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup) |
2486 | 2486 |
| 2487 class LayerTreeHostTestCompositeAndReadbackAnimateCount : public LayerTreeHostTe
st { |
| 2488 public: |
| 2489 LayerTreeHostTestCompositeAndReadbackAnimateCount() |
| 2490 : m_layoutCount(0) |
| 2491 { |
| 2492 } |
| 2493 |
| 2494 virtual void animate(base::TimeTicks) OVERRIDE |
| 2495 { |
| 2496 // We shouldn't animate on the compositeAndReadback-forced commit, but w
e should |
| 2497 // for the setNeedsCommit-triggered commit. |
| 2498 EXPECT_EQ(1, m_layoutCount); |
| 2499 } |
| 2500 |
| 2501 virtual void layout() OVERRIDE |
| 2502 { |
| 2503 m_layoutCount++; |
| 2504 if (m_layoutCount == 2) |
| 2505 endTest(); |
| 2506 } |
| 2507 |
| 2508 virtual void beginTest() OVERRIDE |
| 2509 { |
| 2510 m_layerTreeHost->setNeedsCommit(); |
| 2511 |
| 2512 char pixels[4]; |
| 2513 m_layerTreeHost->compositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); |
| 2514 } |
| 2515 |
| 2516 virtual void afterTest() OVERRIDE |
| 2517 { |
| 2518 } |
| 2519 |
| 2520 private: |
| 2521 int m_layoutCount; |
| 2522 }; |
| 2523 |
| 2524 TEST_F(LayerTreeHostTestCompositeAndReadbackAnimateCount, runMultiThread) |
| 2525 { |
| 2526 runTest(true); |
| 2527 } |
| 2528 |
2487 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public L
ayerTreeHostTest { | 2529 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public L
ayerTreeHostTest { |
2488 public: | 2530 public: |
2489 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() | 2531 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() |
2490 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_fakeDelegate)) | 2532 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_fakeDelegate)) |
2491 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 2533 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) |
2492 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 2534 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) |
2493 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 2535 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) |
2494 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) | 2536 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_fakeDelegate
)) |
2495 { | 2537 { |
2496 } | 2538 } |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3216 int m_numCompleteCommits; | 3258 int m_numCompleteCommits; |
3217 }; | 3259 }; |
3218 | 3260 |
3219 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) | 3261 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) |
3220 { | 3262 { |
3221 runTest(true); | 3263 runTest(true); |
3222 } | 3264 } |
3223 | 3265 |
3224 } // namespace | 3266 } // namespace |
3225 } // namespace cc | 3267 } // namespace cc |
OLD | NEW |