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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11074009: cc: Remove LayerTextureUpdater::Texture::updateRect() callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 2 months 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
« no previous file with comments | « cc/layer_texture_updater.cc ('k') | cc/prioritized_texture_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHost.h" 7 #include "CCLayerTreeHost.h"
8 8
9 #include "CCGeometryTestUtils.h" 9 #include "CCGeometryTestUtils.h"
10 #include "CCGraphicsContext.h" 10 #include "CCGraphicsContext.h"
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 MockContentLayerChromiumClient m_mockDelegate; 2391 MockContentLayerChromiumClient m_mockDelegate;
2392 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_rootLayer; 2392 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_rootLayer;
2393 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer1; 2393 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer1;
2394 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer1; 2394 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer1;
2395 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer2; 2395 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer2;
2396 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer2; 2396 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer2;
2397 }; 2397 };
2398 2398
2399 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSurfaceNotAllocatedForLayersOu tsideMemoryLimit) 2399 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSurfaceNotAllocatedForLayersOu tsideMemoryLimit)
2400 2400
2401
2402 class EvictionTrackingTexture : public LayerTextureUpdater::Texture {
2403 public:
2404 static PassOwnPtr<EvictionTrackingTexture> create(scoped_ptr<CCPrioritizedTe xture> texture) { return adoptPtr(new EvictionTrackingTexture(texture.Pass())); }
2405 virtual ~EvictionTrackingTexture() { }
2406
2407 virtual void updateRect(CCResourceProvider* resourceProvider, const IntRect& , const IntSize&) OVERRIDE
2408 {
2409 ASSERT_TRUE(!texture()->haveBackingTexture() || resourceProvider->numRes ources() > 0);
2410 texture()->acquireBackingTexture(resourceProvider);
2411 m_updated = true;
2412 }
2413 void resetUpdated() { m_updated = false; }
2414 bool updated() const { return m_updated; }
2415
2416 private:
2417 explicit EvictionTrackingTexture(scoped_ptr<CCPrioritizedTexture> texture)
2418 : LayerTextureUpdater::Texture(texture.Pass())
2419 , m_updated(false)
2420 { }
2421 bool m_updated;
2422 };
2423
2424 class EvictionTestLayer : public LayerChromium { 2401 class EvictionTestLayer : public LayerChromium {
2425 public: 2402 public:
2426 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); } 2403 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); }
2427 2404
2428 virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRend eringStats&) OVERRIDE; 2405 virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRend eringStats&) OVERRIDE;
2429 virtual bool drawsContent() const OVERRIDE { return true; } 2406 virtual bool drawsContent() const OVERRIDE { return true; }
2430 2407
2431 virtual scoped_ptr<CCLayerImpl> createCCLayerImpl() OVERRIDE; 2408 virtual scoped_ptr<CCLayerImpl> createCCLayerImpl() OVERRIDE;
2432 virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE; 2409 virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
2433 virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE; 2410 virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE;
2434 2411
2435 void resetUpdated() 2412 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; }
2436 {
2437 if (m_texture.get())
2438 m_texture->resetUpdated();
2439 }
2440 bool updated() const { return m_texture.get() ? m_texture->updated() : false ; }
2441 2413
2442 private: 2414 private:
2443 EvictionTestLayer() : LayerChromium() { } 2415 EvictionTestLayer() : LayerChromium() { }
2444 virtual ~EvictionTestLayer() { } 2416 virtual ~EvictionTestLayer() { }
2445 2417
2446 void createTextureIfNeeded() 2418 void createTextureIfNeeded()
2447 { 2419 {
2448 if (m_texture.get()) 2420 if (m_texture.get())
2449 return; 2421 return;
2450 m_texture = EvictionTrackingTexture::create(CCPrioritizedTexture::create (layerTreeHost()->contentsTextureManager())); 2422 m_texture = CCPrioritizedTexture::create(layerTreeHost()->contentsTextur eManager());
2451 m_texture->texture()->setDimensions(IntSize(10, 10), cc::GraphicsContext 3D::RGBA); 2423 m_texture->setDimensions(IntSize(10, 10), cc::GraphicsContext3D::RGBA);
2424 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
2452 } 2425 }
2453 2426
2454 OwnPtr<EvictionTrackingTexture> m_texture; 2427 scoped_ptr<CCPrioritizedTexture> m_texture;
2428 SkBitmap m_bitmap;
2455 }; 2429 };
2456 2430
2457 class EvictionTestLayerImpl : public CCLayerImpl { 2431 class EvictionTestLayerImpl : public CCLayerImpl {
2458 public: 2432 public:
2459 static scoped_ptr<EvictionTestLayerImpl> create(int id) 2433 static scoped_ptr<EvictionTestLayerImpl> create(int id)
2460 { 2434 {
2461 return make_scoped_ptr(new EvictionTestLayerImpl(id)); 2435 return make_scoped_ptr(new EvictionTestLayerImpl(id));
2462 } 2436 }
2463 virtual ~EvictionTestLayerImpl() { } 2437 virtual ~EvictionTestLayerImpl() { }
2464 2438
(...skipping 11 matching lines...) Expand all
2476 , m_hasTexture(false) { } 2450 , m_hasTexture(false) { }
2477 2451
2478 bool m_hasTexture; 2452 bool m_hasTexture;
2479 }; 2453 };
2480 2454
2481 void EvictionTestLayer::setTexturePriorities(const CCPriorityCalculator&) 2455 void EvictionTestLayer::setTexturePriorities(const CCPriorityCalculator&)
2482 { 2456 {
2483 createTextureIfNeeded(); 2457 createTextureIfNeeded();
2484 if (!m_texture.get()) 2458 if (!m_texture.get())
2485 return; 2459 return;
2486 m_texture->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(tr ue)); 2460 m_texture->setRequestPriority(CCPriorityCalculator::uiPriority(true));
2487 } 2461 }
2488 2462
2489 void EvictionTestLayer::update(CCTextureUpdateQueue& queue, const CCOcclusionTra cker*, CCRenderingStats&) 2463 void EvictionTestLayer::update(CCTextureUpdateQueue& queue, const CCOcclusionTra cker*, CCRenderingStats&)
2490 { 2464 {
2491 createTextureIfNeeded(); 2465 createTextureIfNeeded();
2492 if (!m_texture.get()) 2466 if (!m_texture.get())
2493 return; 2467 return;
2494 IntRect fullRect(0, 0, 10, 10); 2468 IntRect fullRect(0, 0, 10, 10);
2495 TextureUploader::Parameters parameters = { m_texture.get(), fullRect, IntSiz e() }; 2469 TextureUploader::Parameters upload = { m_texture.get(), &m_bitmap, NULL, { f ullRect, fullRect, IntSize() } };
2496 queue.appendFullUpload(parameters); 2470 queue.appendFullUpload(upload);
2497 } 2471 }
2498 2472
2499 scoped_ptr<CCLayerImpl> EvictionTestLayer::createCCLayerImpl() 2473 scoped_ptr<CCLayerImpl> EvictionTestLayer::createCCLayerImpl()
2500 { 2474 {
2501 return EvictionTestLayerImpl::create(m_layerId).PassAs<CCLayerImpl>(); 2475 return EvictionTestLayerImpl::create(m_layerId).PassAs<CCLayerImpl>();
2502 } 2476 }
2503 2477
2504 void EvictionTestLayer::pushPropertiesTo(CCLayerImpl* layerImpl) 2478 void EvictionTestLayer::pushPropertiesTo(CCLayerImpl* layerImpl)
2505 { 2479 {
2506 LayerChromium::pushPropertiesTo(layerImpl); 2480 LayerChromium::pushPropertiesTo(layerImpl);
2507 2481
2508 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl); 2482 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl);
2509 testLayerImpl->setHasTexture(m_texture->texture()->haveBackingTexture()); 2483 testLayerImpl->setHasTexture(m_texture->haveBackingTexture());
2510 } 2484 }
2511 2485
2512 class CCLayerTreeHostTestEvictTextures : public CCLayerTreeHostTest { 2486 class CCLayerTreeHostTestEvictTextures : public CCLayerTreeHostTest {
2513 public: 2487 public:
2514 CCLayerTreeHostTestEvictTextures() 2488 CCLayerTreeHostTestEvictTextures()
2515 : m_layer(EvictionTestLayer::create()) 2489 : m_layer(EvictionTestLayer::create())
2516 , m_implForEvictTextures(0) 2490 , m_implForEvictTextures(0)
2517 , m_numCommits(0) 2491 , m_numCommits(0)
2518 { 2492 {
2519 } 2493 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 // Commits 1+2 test the eviction recovery path where eviction happens outsid e 2540 // Commits 1+2 test the eviction recovery path where eviction happens outsid e
2567 // of the beginFrame/commit pair. 2541 // of the beginFrame/commit pair.
2568 // Commits 3+4 test the eviction recovery path where eviction happens inside 2542 // Commits 3+4 test the eviction recovery path where eviction happens inside
2569 // the beginFrame/commit pair. 2543 // the beginFrame/commit pair.
2570 // Commits 5+6 test the path where an eviction happens during the eviction 2544 // Commits 5+6 test the path where an eviction happens during the eviction
2571 // recovery path. 2545 // recovery path.
2572 virtual void didCommitAndDrawFrame() OVERRIDE 2546 virtual void didCommitAndDrawFrame() OVERRIDE
2573 { 2547 {
2574 switch (m_numCommits) { 2548 switch (m_numCommits) {
2575 case 1: 2549 case 1:
2576 EXPECT_TRUE(m_layer->updated()); 2550 EXPECT_TRUE(m_layer->haveBackingTexture());
2577 postEvictTextures(); 2551 postEvictTextures();
2578 break; 2552 break;
2579 case 2: 2553 case 2:
2580 EXPECT_TRUE(m_layer->updated()); 2554 EXPECT_TRUE(m_layer->haveBackingTexture());
2581 m_layerTreeHost->setNeedsCommit(); 2555 m_layerTreeHost->setNeedsCommit();
2582 break; 2556 break;
2583 case 3: 2557 case 3:
2584 break; 2558 break;
2585 case 4: 2559 case 4:
2586 EXPECT_TRUE(m_layer->updated()); 2560 EXPECT_TRUE(m_layer->haveBackingTexture());
2587 m_layerTreeHost->setNeedsCommit(); 2561 m_layerTreeHost->setNeedsCommit();
2588 break; 2562 break;
2589 case 5: 2563 case 5:
2590 break; 2564 break;
2591 case 6: 2565 case 6:
2592 EXPECT_TRUE(m_layer->updated()); 2566 EXPECT_TRUE(m_layer->haveBackingTexture());
2593 endTest(); 2567 endTest();
2594 break; 2568 break;
2595 default: 2569 default:
2596 ASSERT_NOT_REACHED(); 2570 ASSERT_NOT_REACHED();
2597 break; 2571 break;
2598 } 2572 }
2599 } 2573 }
2600 2574
2601 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2575 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
2602 { 2576 {
2603 m_implForEvictTextures = impl; 2577 m_implForEvictTextures = impl;
2604 } 2578 }
2605 2579
2606 virtual void layout() OVERRIDE 2580 virtual void layout() OVERRIDE
2607 { 2581 {
2608 ++m_numCommits; 2582 ++m_numCommits;
2609 switch (m_numCommits) { 2583 switch (m_numCommits) {
2610 case 1: 2584 case 1:
2611 case 2: 2585 case 2:
2612 break; 2586 break;
2613 case 3: 2587 case 3:
2614 postEvictTextures(); 2588 postEvictTextures();
2615 break; 2589 break;
2616 case 4: 2590 case 4:
2617 // We couldn't check in didCommitAndDrawFrame on commit 3, so check here. 2591 // We couldn't check in didCommitAndDrawFrame on commit 3, so check here.
2618 EXPECT_FALSE(m_layer->updated()); 2592 EXPECT_FALSE(m_layer->haveBackingTexture());
2619 break; 2593 break;
2620 case 5: 2594 case 5:
2621 postEvictTextures(); 2595 postEvictTextures();
2622 break; 2596 break;
2623 case 6: 2597 case 6:
2624 // We couldn't check in didCommitAndDrawFrame on commit 5, so check here. 2598 // We couldn't check in didCommitAndDrawFrame on commit 5, so check here.
2625 EXPECT_FALSE(m_layer->updated()); 2599 EXPECT_FALSE(m_layer->haveBackingTexture());
2626 postEvictTextures(); 2600 postEvictTextures();
2627 break; 2601 break;
2628 default: 2602 default:
2629 ASSERT_NOT_REACHED(); 2603 ASSERT_NOT_REACHED();
2630 break; 2604 break;
2631 } 2605 }
2632 m_layer->resetUpdated();
2633 } 2606 }
2634 2607
2635 virtual void afterTest() OVERRIDE 2608 virtual void afterTest() OVERRIDE
2636 { 2609 {
2637 } 2610 }
2638 2611
2639 private: 2612 private:
2640 MockContentLayerChromiumClient m_client; 2613 MockContentLayerChromiumClient m_client;
2641 scoped_refptr<EvictionTestLayer> m_layer; 2614 scoped_refptr<EvictionTestLayer> m_layer;
2642 CCLayerTreeHostImpl* m_implForEvictTextures; 2615 CCLayerTreeHostImpl* m_implForEvictTextures;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 // invisible (to prevent a commit that would recreate textures after 2672 // invisible (to prevent a commit that would recreate textures after
2700 // eviction, before the context recovery), and post a task that will evict 2673 // eviction, before the context recovery), and post a task that will evict
2701 // textures, then cause the context to be lost, and then set ourselves 2674 // textures, then cause the context to be lost, and then set ourselves
2702 // visible again (to allow commits, since that's what causes context 2675 // visible again (to allow commits, since that's what causes context
2703 // recovery in single thread). 2676 // recovery in single thread).
2704 virtual void didCommitAndDrawFrame() OVERRIDE 2677 virtual void didCommitAndDrawFrame() OVERRIDE
2705 { 2678 {
2706 ++m_numCommits; 2679 ++m_numCommits;
2707 switch (m_numCommits) { 2680 switch (m_numCommits) {
2708 case 1: 2681 case 1:
2709 EXPECT_TRUE(m_layer->updated()); 2682 EXPECT_TRUE(m_layer->haveBackingTexture());
2710 m_layerTreeHost->setVisible(false); 2683 m_layerTreeHost->setVisible(false);
2711 postEvictTextures(); 2684 postEvictTextures();
2712 m_layerTreeHost->loseContext(1); 2685 m_layerTreeHost->loseContext(1);
2713 m_layerTreeHost->setVisible(true); 2686 m_layerTreeHost->setVisible(true);
2714 break; 2687 break;
2715 default: 2688 default:
2716 break; 2689 break;
2717 } 2690 }
2718 } 2691 }
2719 2692
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 int m_numCommitComplete; 2967 int m_numCommitComplete;
2995 int m_numDrawLayers; 2968 int m_numDrawLayers;
2996 }; 2969 };
2997 2970
2998 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) 2971 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread)
2999 { 2972 {
3000 runTest(true); 2973 runTest(true);
3001 } 2974 }
3002 2975
3003 } // namespace 2976 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_texture_updater.cc ('k') | cc/prioritized_texture_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698