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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
« no previous file with comments | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/layer_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 "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"
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 2610
2611 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit) 2611 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit)
2612 2612
2613 class EvictionTestLayer : public Layer { 2613 class EvictionTestLayer : public Layer {
2614 public: 2614 public:
2615 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); } 2615 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); }
2616 2616
2617 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats&) OVERRIDE; 2617 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats&) OVERRIDE;
2618 virtual bool drawsContent() const OVERRIDE { return true; } 2618 virtual bool drawsContent() const OVERRIDE { return true; }
2619 2619
2620 virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE; 2620 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeHostImpl* hostImpl) O VERRIDE;
2621 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; 2621 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
2622 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; 2622 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
2623 2623
2624 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; } 2624 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; }
2625 2625
2626 private: 2626 private:
2627 EvictionTestLayer() : Layer() { } 2627 EvictionTestLayer() : Layer() { }
2628 virtual ~EvictionTestLayer() { } 2628 virtual ~EvictionTestLayer() { }
2629 2629
2630 void createTextureIfNeeded() 2630 void createTextureIfNeeded()
2631 { 2631 {
2632 if (m_texture.get()) 2632 if (m_texture.get())
2633 return; 2633 return;
2634 m_texture = PrioritizedResource::create(layerTreeHost()->contentsTexture Manager()); 2634 m_texture = PrioritizedResource::create(layerTreeHost()->contentsTexture Manager());
2635 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); 2635 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA);
2636 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 2636 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
2637 } 2637 }
2638 2638
2639 scoped_ptr<PrioritizedResource> m_texture; 2639 scoped_ptr<PrioritizedResource> m_texture;
2640 SkBitmap m_bitmap; 2640 SkBitmap m_bitmap;
2641 }; 2641 };
2642 2642
2643 class EvictionTestLayerImpl : public LayerImpl { 2643 class EvictionTestLayerImpl : public LayerImpl {
2644 public: 2644 public:
2645 static scoped_ptr<EvictionTestLayerImpl> create(int id) 2645 static scoped_ptr<EvictionTestLayerImpl> create(LayerTreeHostImpl* hostImpl, int id)
2646 { 2646 {
2647 return make_scoped_ptr(new EvictionTestLayerImpl(id)); 2647 return make_scoped_ptr(new EvictionTestLayerImpl(hostImpl, id));
2648 } 2648 }
2649 virtual ~EvictionTestLayerImpl() { } 2649 virtual ~EvictionTestLayerImpl() { }
2650 2650
2651 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE 2651 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE
2652 { 2652 {
2653 ASSERT_TRUE(m_hasTexture); 2653 ASSERT_TRUE(m_hasTexture);
2654 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources()); 2654 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources());
2655 } 2655 }
2656 2656
2657 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } 2657 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; }
2658 2658
2659 private: 2659 private:
2660 explicit EvictionTestLayerImpl(int id) 2660 EvictionTestLayerImpl(LayerTreeHostImpl* hostImpl, int id)
2661 : LayerImpl(id) 2661 : LayerImpl(hostImpl, id)
2662 , m_hasTexture(false) { } 2662 , m_hasTexture(false) { }
2663 2663
2664 bool m_hasTexture; 2664 bool m_hasTexture;
2665 }; 2665 };
2666 2666
2667 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&) 2667 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&)
2668 { 2668 {
2669 createTextureIfNeeded(); 2669 createTextureIfNeeded();
2670 if (!m_texture.get()) 2670 if (!m_texture.get())
2671 return; 2671 return;
2672 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); 2672 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true));
2673 } 2673 }
2674 2674
2675 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke r*, RenderingStats&) 2675 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke r*, RenderingStats&)
2676 { 2676 {
2677 createTextureIfNeeded(); 2677 createTextureIfNeeded();
2678 if (!m_texture.get()) 2678 if (!m_texture.get())
2679 return; 2679 return;
2680 2680
2681 gfx::Rect fullRect(0, 0, 10, 10); 2681 gfx::Rect fullRect(0, 0, 10, 10);
2682 ResourceUpdate upload = ResourceUpdate::Create( 2682 ResourceUpdate upload = ResourceUpdate::Create(
2683 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d()); 2683 m_texture.get(), &m_bitmap, fullRect, fullRect, gfx::Vector2d());
2684 queue.appendFullUpload(upload); 2684 queue.appendFullUpload(upload);
2685 } 2685 }
2686 2686
2687 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl() 2687 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl(LayerTreeHostImpl* host Impl)
2688 { 2688 {
2689 return EvictionTestLayerImpl::create(m_layerId).PassAs<LayerImpl>(); 2689 return EvictionTestLayerImpl::create(hostImpl, m_layerId).PassAs<LayerImpl>( );
2690 } 2690 }
2691 2691
2692 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl) 2692 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl)
2693 { 2693 {
2694 Layer::pushPropertiesTo(layerImpl); 2694 Layer::pushPropertiesTo(layerImpl);
2695 2695
2696 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl); 2696 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl);
2697 testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); 2697 testLayerImpl->setHasTexture(m_texture->haveBackingTexture());
2698 } 2698 }
2699 2699
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 LayerTreeSettings settings; 3352 LayerTreeSettings settings;
3353 settings.maxPartialTextureUpdates = 4; 3353 settings.maxPartialTextureUpdates = 4;
3354 3354
3355 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 3355 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
3356 EXPECT_TRUE(host->initializeRendererIfNeeded()); 3356 EXPECT_TRUE(host->initializeRendererIfNeeded());
3357 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); 3357 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates);
3358 } 3358 }
3359 3359
3360 } // namespace 3360 } // namespace
3361 } // namespace cc 3361 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698