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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11270047: cc: Rename TextureUpdate to ResourceUpdate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sort includes and forward declarations. Created 8 years, 1 month 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.cc ('k') | cc/layer_updater.h » ('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 "cc/layer_tree_host.h" 7 #include "cc/layer_tree_host.h"
8 8
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/content_layer.h" 10 #include "cc/content_layer.h"
11 #include "cc/content_layer_client.h" 11 #include "cc/content_layer_client.h"
12 #include "cc/graphics_context.h" 12 #include "cc/graphics_context.h"
13 #include "cc/layer_tree_host_impl.h" 13 #include "cc/layer_tree_host_impl.h"
14 #include "cc/settings.h" 14 #include "cc/settings.h"
15 #include "cc/single_thread_proxy.h" 15 #include "cc/single_thread_proxy.h"
16 #include "cc/test/fake_web_compositor_output_surface.h" 16 #include "cc/test/fake_web_compositor_output_surface.h"
17 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
18 #include "cc/test/layer_tree_test_common.h" 18 #include "cc/test/layer_tree_test_common.h"
19 #include "cc/test/occlusion_tracker_test_common.h" 19 #include "cc/test/occlusion_tracker_test_common.h"
20 #include "cc/texture_update_queue.h" 20 #include "cc/resource_update_queue.h"
21 #include "cc/timing_function.h" 21 #include "cc/timing_function.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "third_party/khronos/GLES2/gl2.h" 23 #include "third_party/khronos/GLES2/gl2.h"
24 #include "third_party/khronos/GLES2/gl2ext.h" 24 #include "third_party/khronos/GLES2/gl2ext.h"
25 #include <public/Platform.h> 25 #include <public/Platform.h>
26 #include <public/WebLayerScrollClient.h> 26 #include <public/WebLayerScrollClient.h>
27 #include <public/WebSize.h> 27 #include <public/WebSize.h>
28 28
29 using namespace cc; 29 using namespace cc;
30 using namespace WebKit; 30 using namespace WebKit;
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 LayerTreeHostTest* m_test; 1173 LayerTreeHostTest* m_test;
1174 }; 1174 };
1175 1175
1176 class ContentLayerWithUpdateTracking : public ContentLayer { 1176 class ContentLayerWithUpdateTracking : public ContentLayer {
1177 public: 1177 public:
1178 static scoped_refptr<ContentLayerWithUpdateTracking> create(ContentLayerClie nt* client) { return make_scoped_refptr(new ContentLayerWithUpdateTracking(clien t)); } 1178 static scoped_refptr<ContentLayerWithUpdateTracking> create(ContentLayerClie nt* client) { return make_scoped_refptr(new ContentLayerWithUpdateTracking(clien t)); }
1179 1179
1180 int paintContentsCount() { return m_paintContentsCount; } 1180 int paintContentsCount() { return m_paintContentsCount; }
1181 void resetPaintContentsCount() { m_paintContentsCount = 0; } 1181 void resetPaintContentsCount() { m_paintContentsCount = 0; }
1182 1182
1183 virtual void update(TextureUpdateQueue& queue, const OcclusionTracker* occlu sion, RenderingStats& stats) OVERRIDE 1183 virtual void update(ResourceUpdateQueue& queue, const OcclusionTracker* occl usion, RenderingStats& stats) OVERRIDE
1184 { 1184 {
1185 ContentLayer::update(queue, occlusion, stats); 1185 ContentLayer::update(queue, occlusion, stats);
1186 m_paintContentsCount++; 1186 m_paintContentsCount++;
1187 } 1187 }
1188 1188
1189 private: 1189 private:
1190 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) 1190 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client)
1191 : ContentLayer(client) 1191 : ContentLayer(client)
1192 , m_paintContentsCount(0) 1192 , m_paintContentsCount(0)
1193 { 1193 {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1606
1607 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) 1607 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread)
1608 { 1608 {
1609 runTest(true); 1609 runTest(true);
1610 } 1610 }
1611 1611
1612 class TestLayer : public Layer { 1612 class TestLayer : public Layer {
1613 public: 1613 public:
1614 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes tLayer()); } 1614 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes tLayer()); }
1615 1615
1616 virtual void update(TextureUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE 1616 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE
1617 { 1617 {
1618 // Gain access to internals of the OcclusionTracker. 1618 // Gain access to internals of the OcclusionTracker.
1619 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus ionTracker*>(occlusion); 1619 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus ionTracker*>(occlusion);
1620 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen Space() : Region(); 1620 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen Space() : Region();
1621 } 1621 }
1622 1622
1623 virtual bool drawsContent() const OVERRIDE { return true; } 1623 virtual bool drawsContent() const OVERRIDE { return true; }
1624 1624
1625 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } 1625 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; }
1626 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); } 1626 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 // positioned on the screen. 1662 // positioned on the screen.
1663 1663
1664 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer 1664 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer
1665 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); 1665 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true);
1666 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); 1666 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);
1667 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); 1667 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
1668 1668
1669 m_layerTreeHost->setRootLayer(rootLayer); 1669 m_layerTreeHost->setRootLayer(rootLayer);
1670 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1670 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1671 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1671 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1672 TextureUpdateQueue queue; 1672 ResourceUpdateQueue queue;
1673 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1673 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1674 m_layerTreeHost->commitComplete(); 1674 m_layerTreeHost->commitComplete();
1675 1675
1676 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); 1676 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds());
1677 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); 1677 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());
1678 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds()); 1678 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds());
1679 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); 1679 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());
1680 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), rootLayer->occludedScreenSpace ().bounds()); 1680 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), rootLayer->occludedScreenSpace ().bounds());
1681 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); 1681 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());
1682 1682
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 1870
1871 { 1871 {
1872 WebFilterOperations filters; 1872 WebFilterOperations filters;
1873 filters.append(WebFilterOperation::createOpacityFilter(0.5)); 1873 filters.append(WebFilterOperation::createOpacityFilter(0.5));
1874 child->setFilters(filters); 1874 child->setFilters(filters);
1875 } 1875 }
1876 1876
1877 m_layerTreeHost->setRootLayer(rootLayer); 1877 m_layerTreeHost->setRootLayer(rootLayer);
1878 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1878 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1879 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1879 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1880 TextureUpdateQueue queue; 1880 ResourceUpdateQueue queue;
1881 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1881 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1882 m_layerTreeHost->commitComplete(); 1882 m_layerTreeHost->commitComplete();
1883 1883
1884 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); 1884 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds());
1885 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); 1885 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());
1886 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac e().bounds()); 1886 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac e().bounds());
1887 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); 1887 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size());
1888 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b ounds()); 1888 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b ounds());
1889 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); 1889 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size());
1890 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds()); 1890 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 } 1959 }
1960 1960
1961 for (int i = 1; i < numSurfaces; ++i) { 1961 for (int i = 1; i < numSurfaces; ++i) {
1962 children.push_back(TestLayer::create()); 1962 children.push_back(TestLayer::create());
1963 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge t(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), fals e); 1963 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge t(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), fals e);
1964 } 1964 }
1965 1965
1966 m_layerTreeHost->setRootLayer(layers[0].get()); 1966 m_layerTreeHost->setRootLayer(layers[0].get());
1967 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( )); 1967 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( ));
1968 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1968 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1969 TextureUpdateQueue queue; 1969 ResourceUpdateQueue queue;
1970 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1970 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1971 m_layerTreeHost->commitComplete(); 1971 m_layerTreeHost->commitComplete();
1972 1972
1973 for (int i = 0; i < numSurfaces-1; ++i) { 1973 for (int i = 0; i < numSurfaces-1; ++i) {
1974 IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); 1974 IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1);
1975 1975
1976 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b ounds()); 1976 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b ounds());
1977 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size()); 1977 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size());
1978 } 1978 }
1979 1979
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2; 2599 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2;
2600 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2; 2600 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2;
2601 }; 2601 };
2602 2602
2603 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit) 2603 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit)
2604 2604
2605 class EvictionTestLayer : public Layer { 2605 class EvictionTestLayer : public Layer {
2606 public: 2606 public:
2607 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); } 2607 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); }
2608 2608
2609 virtual void update(TextureUpdateQueue&, const OcclusionTracker*, RenderingS tats&) OVERRIDE; 2609 virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, Rendering Stats&) OVERRIDE;
2610 virtual bool drawsContent() const OVERRIDE { return true; } 2610 virtual bool drawsContent() const OVERRIDE { return true; }
2611 2611
2612 virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE; 2612 virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE;
2613 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; 2613 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
2614 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; 2614 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
2615 2615
2616 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; } 2616 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; }
2617 2617
2618 private: 2618 private:
2619 EvictionTestLayer() : Layer() { } 2619 EvictionTestLayer() : Layer() { }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2657 }; 2657 };
2658 2658
2659 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&) 2659 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&)
2660 { 2660 {
2661 createTextureIfNeeded(); 2661 createTextureIfNeeded();
2662 if (!m_texture.get()) 2662 if (!m_texture.get())
2663 return; 2663 return;
2664 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); 2664 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true));
2665 } 2665 }
2666 2666
2667 void EvictionTestLayer::update(TextureUpdateQueue& queue, const OcclusionTracker *, RenderingStats&) 2667 void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracke r*, RenderingStats&)
2668 { 2668 {
2669 createTextureIfNeeded(); 2669 createTextureIfNeeded();
2670 if (!m_texture.get()) 2670 if (!m_texture.get())
2671 return; 2671 return;
2672 IntRect fullRect(0, 0, 10, 10); 2672 IntRect fullRect(0, 0, 10, 10);
2673 2673
2674 ResourceUpdate upload = ResourceUpdate::Create( 2674 ResourceUpdate upload = ResourceUpdate::Create(
2675 m_texture.get(), &m_bitmap, fullRect, fullRect, IntSize()); 2675 m_texture.get(), &m_bitmap, fullRect, fullRect, IntSize());
2676 queue.appendFullUpload(upload); 2676 queue.appendFullUpload(upload);
2677 } 2677 }
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 int m_numCommitComplete; 3177 int m_numCommitComplete;
3178 int m_numDrawLayers; 3178 int m_numDrawLayers;
3179 }; 3179 };
3180 3180
3181 TEST_F(LayerTreeHostTestContinuousAnimate, runMultiThread) 3181 TEST_F(LayerTreeHostTestContinuousAnimate, runMultiThread)
3182 { 3182 {
3183 runTest(true); 3183 runTest(true);
3184 } 3184 }
3185 3185
3186 } // namespace 3186 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host.cc ('k') | cc/layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698