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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11519018: [cc] Make LayerImpls point at LayerTreeImpl instead of LTHI (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/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/layer_impl.h" 10 #include "cc/layer_impl.h"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/layer_tree_impl.h"
12 #include "cc/output_surface.h" 13 #include "cc/output_surface.h"
13 #include "cc/single_thread_proxy.h" 14 #include "cc/single_thread_proxy.h"
14 #include "cc/test/fake_content_layer_client.h" 15 #include "cc/test/fake_content_layer_client.h"
15 #include "cc/test/fake_layer_tree_host_client.h" 16 #include "cc/test/fake_layer_tree_host_client.h"
16 #include "cc/test/fake_output_surface.h" 17 #include "cc/test/fake_output_surface.h"
17 #include "cc/test/fake_proxy.h" 18 #include "cc/test/fake_proxy.h"
18 #include "cc/test/geometry_test_utils.h" 19 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/layer_tree_test_common.h" 20 #include "cc/test/layer_tree_test_common.h"
20 #include "cc/test/occlusion_tracker_test_common.h" 21 #include "cc/test/occlusion_tracker_test_common.h"
21 #include "cc/resource_update_queue.h" 22 #include "cc/resource_update_queue.h"
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 2612
2612 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit) 2613 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit)
2613 2614
2614 class EvictionTestLayer : public Layer { 2615 class EvictionTestLayer : public Layer {
2615 public: 2616 public:
2616 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); } 2617 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); }
2617 2618
2618 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats&) OVERRIDE; 2619 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats&) OVERRIDE;
2619 virtual bool drawsContent() const OVERRIDE { return true; } 2620 virtual bool drawsContent() const OVERRIDE { return true; }
2620 2621
2621 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeHostImpl* hostImpl) O VERRIDE; 2622 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* treeImpl) OVERR IDE;
2622 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; 2623 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
2623 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; 2624 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
2624 2625
2625 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; } 2626 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; }
2626 2627
2627 private: 2628 private:
2628 EvictionTestLayer() : Layer() { } 2629 EvictionTestLayer() : Layer() { }
2629 virtual ~EvictionTestLayer() { } 2630 virtual ~EvictionTestLayer() { }
2630 2631
2631 void createTextureIfNeeded() 2632 void createTextureIfNeeded()
2632 { 2633 {
2633 if (m_texture.get()) 2634 if (m_texture.get())
2634 return; 2635 return;
2635 m_texture = PrioritizedResource::create(layerTreeHost()->contentsTexture Manager()); 2636 m_texture = PrioritizedResource::create(layerTreeHost()->contentsTexture Manager());
2636 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); 2637 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA);
2637 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 2638 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
2638 } 2639 }
2639 2640
2640 scoped_ptr<PrioritizedResource> m_texture; 2641 scoped_ptr<PrioritizedResource> m_texture;
2641 SkBitmap m_bitmap; 2642 SkBitmap m_bitmap;
2642 }; 2643 };
2643 2644
2644 class EvictionTestLayerImpl : public LayerImpl { 2645 class EvictionTestLayerImpl : public LayerImpl {
2645 public: 2646 public:
2646 static scoped_ptr<EvictionTestLayerImpl> create(LayerTreeHostImpl* hostImpl, int id) 2647 static scoped_ptr<EvictionTestLayerImpl> create(LayerTreeImpl* treeImpl, int id)
2647 { 2648 {
2648 return make_scoped_ptr(new EvictionTestLayerImpl(hostImpl, id)); 2649 return make_scoped_ptr(new EvictionTestLayerImpl(treeImpl, id));
2649 } 2650 }
2650 virtual ~EvictionTestLayerImpl() { } 2651 virtual ~EvictionTestLayerImpl() { }
2651 2652
2652 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE 2653 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE
2653 { 2654 {
2654 ASSERT_TRUE(m_hasTexture); 2655 ASSERT_TRUE(m_hasTexture);
2655 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources()); 2656 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources());
2656 } 2657 }
2657 2658
2658 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } 2659 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; }
2659 2660
2660 private: 2661 private:
2661 EvictionTestLayerImpl(LayerTreeHostImpl* hostImpl, int id) 2662 EvictionTestLayerImpl(LayerTreeImpl* treeImpl, int id)
2662 : LayerImpl(hostImpl, id) 2663 : LayerImpl(treeImpl, id)
2663 , m_hasTexture(false) { } 2664 , m_hasTexture(false) { }
2664 2665
2665 bool m_hasTexture; 2666 bool m_hasTexture;
2666 }; 2667 };
2667 2668
2668 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&) 2669 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&)
2669 { 2670 {
2670 createTextureIfNeeded(); 2671 createTextureIfNeeded();
2671 if (!m_texture.get()) 2672 if (!m_texture.get())
2672 return; 2673 return;
2673 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); 2674 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true));
2674 } 2675 }
2675 2676
2676 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke r*, RenderingStats&) 2677 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke r*, RenderingStats&)
2677 { 2678 {
2678 createTextureIfNeeded(); 2679 createTextureIfNeeded();
2679 if (!m_texture.get()) 2680 if (!m_texture.get())
2680 return; 2681 return;
2681 2682
2682 gfx::Rect fullRect(0, 0, 10, 10); 2683 gfx::Rect fullRect(0, 0, 10, 10);
2683 ResourceUpdate upload = ResourceUpdate::Create( 2684 ResourceUpdate upload = ResourceUpdate::Create(
2684 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d()); 2685 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d());
2685 queue.appendFullUpload(upload); 2686 queue.appendFullUpload(upload);
2686 } 2687 }
2687 2688
2688 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl(LayerTreeHostImpl* host Impl) 2689 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl(LayerTreeImpl* treeImpl )
2689 { 2690 {
2690 return EvictionTestLayerImpl::create(hostImpl, m_layerId).PassAs<LayerImpl>( ); 2691 return EvictionTestLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>( );
2691 } 2692 }
2692 2693
2693 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl) 2694 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl)
2694 { 2695 {
2695 Layer::pushPropertiesTo(layerImpl); 2696 Layer::pushPropertiesTo(layerImpl);
2696 2697
2697 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl); 2698 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl);
2698 testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); 2699 testLayerImpl->setHasTexture(m_texture->haveBackingTexture());
2699 } 2700 }
2700 2701
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
3378 LayerTreeSettings settings; 3379 LayerTreeSettings settings;
3379 settings.maxPartialTextureUpdates = 4; 3380 settings.maxPartialTextureUpdates = 4;
3380 3381
3381 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 3382 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
3382 EXPECT_TRUE(host->initializeRendererIfNeeded()); 3383 EXPECT_TRUE(host->initializeRendererIfNeeded());
3383 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); 3384 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates);
3384 } 3385 }
3385 3386
3386 } // namespace 3387 } // namespace
3387 } // namespace cc 3388 } // namespace cc
OLDNEW
« cc/layer.h ('K') | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698