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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 12519006: cc:: Add RenderingStatsInstrumentation to manage collection of RenderingStats (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed tests Created 7 years, 9 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
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_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "cc/compositor_frame_metadata.h" 12 #include "cc/compositor_frame_metadata.h"
13 #include "cc/delegated_renderer_layer_impl.h" 13 #include "cc/delegated_renderer_layer_impl.h"
14 #include "cc/gl_renderer.h" 14 #include "cc/gl_renderer.h"
15 #include "cc/heads_up_display_layer_impl.h" 15 #include "cc/heads_up_display_layer_impl.h"
16 #include "cc/io_surface_layer_impl.h" 16 #include "cc/io_surface_layer_impl.h"
17 #include "cc/layer_impl.h" 17 #include "cc/layer_impl.h"
18 #include "cc/layer_tiling_data.h" 18 #include "cc/layer_tiling_data.h"
19 #include "cc/layer_tree_impl.h" 19 #include "cc/layer_tree_impl.h"
20 #include "cc/math_util.h" 20 #include "cc/math_util.h"
21 #include "cc/quad_sink.h" 21 #include "cc/quad_sink.h"
22 #include "cc/render_pass_draw_quad.h" 22 #include "cc/render_pass_draw_quad.h"
23 #include "cc/rendering_stats_instrumentation.h"
23 #include "cc/scrollbar_geometry_fixed_thumb.h" 24 #include "cc/scrollbar_geometry_fixed_thumb.h"
24 #include "cc/scrollbar_layer_impl.h" 25 #include "cc/scrollbar_layer_impl.h"
25 #include "cc/single_thread_proxy.h" 26 #include "cc/single_thread_proxy.h"
26 #include "cc/solid_color_draw_quad.h" 27 #include "cc/solid_color_draw_quad.h"
27 #include "cc/solid_color_layer_impl.h" 28 #include "cc/solid_color_layer_impl.h"
28 #include "cc/test/animation_test_common.h" 29 #include "cc/test/animation_test_common.h"
29 #include "cc/test/fake_output_surface.h" 30 #include "cc/test/fake_output_surface.h"
30 #include "cc/test/fake_proxy.h" 31 #include "cc/test/fake_proxy.h"
31 #include "cc/test/fake_video_frame_provider.h" 32 #include "cc/test/fake_video_frame_provider.h"
32 #include "cc/test/fake_web_scrollbar_theme_geometry.h" 33 #include "cc/test/fake_web_scrollbar_theme_geometry.h"
(...skipping 29 matching lines...) Expand all
62 LayerTreeHostImplTest() 63 LayerTreeHostImplTest()
63 : m_proxy(scoped_ptr<Thread>(NULL)) 64 : m_proxy(scoped_ptr<Thread>(NULL))
64 , m_alwaysImplThread(&m_proxy) 65 , m_alwaysImplThread(&m_proxy)
65 , m_alwaysMainThreadBlocked(&m_proxy) 66 , m_alwaysMainThreadBlocked(&m_proxy)
66 , m_onCanDrawStateChangedCalled(false) 67 , m_onCanDrawStateChangedCalled(false)
67 , m_hasPendingTree(false) 68 , m_hasPendingTree(false)
68 , m_didRequestCommit(false) 69 , m_didRequestCommit(false)
69 , m_didRequestRedraw(false) 70 , m_didRequestRedraw(false)
70 , m_didUploadVisibleHighResolutionTile(false) 71 , m_didUploadVisibleHighResolutionTile(false)
71 , m_reduceMemoryResult(true) 72 , m_reduceMemoryResult(true)
73 , m_renderingStatsInstrumentation(RenderingStatsInstrumentation::Create( ))
72 { 74 {
73 media::InitializeMediaLibraryForTesting(); 75 media::InitializeMediaLibraryForTesting();
74 } 76 }
75 77
76 virtual void SetUp() 78 virtual void SetUp()
77 { 79 {
78 LayerTreeSettings settings; 80 LayerTreeSettings settings;
79 settings.minimumOcclusionTrackingSize = gfx::Size(); 81 settings.minimumOcclusionTrackingSize = gfx::Size();
80 82
81 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); 83 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, m_rende ringStatsInstrumentation.get());
82 m_hostImpl->InitializeRenderer(createOutputSurface()); 84 m_hostImpl->InitializeRenderer(createOutputSurface());
83 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 85 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
84 } 86 }
85 87
86 virtual void TearDown() 88 virtual void TearDown()
87 { 89 {
88 } 90 }
89 91
90 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { } 92 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { }
91 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { } 93 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { }
(...skipping 12 matching lines...) Expand all
104 virtual void RenewTreePriority() OVERRIDE { } 106 virtual void RenewTreePriority() OVERRIDE { }
105 107
106 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } 108 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; }
107 109
108 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS urface) 110 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS urface)
109 { 111 {
110 LayerTreeSettings settings; 112 LayerTreeSettings settings;
111 settings.minimumOcclusionTrackingSize = gfx::Size(); 113 settings.minimumOcclusionTrackingSize = gfx::Size();
112 settings.partialSwapEnabled = partialSwap; 114 settings.partialSwapEnabled = partialSwap;
113 115
114 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); 116 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, m_rende ringStatsInstrumentation.get());
115 117
116 m_hostImpl->InitializeRenderer(outputSurface.Pass()); 118 m_hostImpl->InitializeRenderer(outputSurface.Pass());
117 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 119 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
118 } 120 }
119 121
120 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) 122 void setupRootLayerImpl(scoped_ptr<LayerImpl> root)
121 { 123 {
122 root->SetAnchorPoint(gfx::PointF(0, 0)); 124 root->SetAnchorPoint(gfx::PointF(0, 0));
123 root->SetPosition(gfx::PointF(0, 0)); 125 root->SetPosition(gfx::PointF(0, 0));
124 root->SetBounds(gfx::Size(10, 10)); 126 root->SetBounds(gfx::Size(10, 10));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 LayerTreeHostImpl::FrameData frameData; 218 LayerTreeHostImpl::FrameData frameData;
217 m_hostImpl->PrepareToDraw(&frameData); 219 m_hostImpl->PrepareToDraw(&frameData);
218 m_hostImpl->DidDrawAllLayers(frameData); 220 m_hostImpl->DidDrawAllLayers(frameData);
219 } 221 }
220 222
221 FakeProxy m_proxy; 223 FakeProxy m_proxy;
222 DebugScopedSetImplThread m_alwaysImplThread; 224 DebugScopedSetImplThread m_alwaysImplThread;
223 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; 225 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
224 226
225 scoped_ptr<LayerTreeHostImpl> m_hostImpl; 227 scoped_ptr<LayerTreeHostImpl> m_hostImpl;
228 scoped_ptr<RenderingStatsInstrumentation> m_renderingStatsInstrumentation;
226 bool m_onCanDrawStateChangedCalled; 229 bool m_onCanDrawStateChangedCalled;
227 bool m_hasPendingTree; 230 bool m_hasPendingTree;
228 bool m_didRequestCommit; 231 bool m_didRequestCommit;
229 bool m_didRequestRedraw; 232 bool m_didRequestRedraw;
230 bool m_didUploadVisibleHighResolutionTile; 233 bool m_didUploadVisibleHighResolutionTile;
231 bool m_reduceMemoryResult; 234 bool m_reduceMemoryResult;
232 }; 235 };
233 236
234 class TestWebGraphicsContext3DMakeCurrentFails : public TestWebGraphicsContext3D { 237 class TestWebGraphicsContext3DMakeCurrentFails : public TestWebGraphicsContext3D {
235 public: 238 public:
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 379
377 TEST_F(LayerTreeHostImplTest, scrollWithoutRootLayer) 380 TEST_F(LayerTreeHostImplTest, scrollWithoutRootLayer)
378 { 381 {
379 // We should not crash when trying to scroll an empty layer tree. 382 // We should not crash when trying to scroll an empty layer tree.
380 EXPECT_EQ(m_hostImpl->ScrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 383 EXPECT_EQ(m_hostImpl->ScrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
381 } 384 }
382 385
383 TEST_F(LayerTreeHostImplTest, scrollWithoutRenderer) 386 TEST_F(LayerTreeHostImplTest, scrollWithoutRenderer)
384 { 387 {
385 LayerTreeSettings settings; 388 LayerTreeSettings settings;
386 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); 389 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, m_rendering StatsInstrumentation.get());
387 390
388 // Initialization will fail here. 391 // Initialization will fail here.
389 m_hostImpl->InitializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new TestWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>()); 392 m_hostImpl->InitializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new TestWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>());
390 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 393 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
391 394
392 setupScrollAndContentsLayers(gfx::Size(100, 100)); 395 setupScrollAndContentsLayers(gfx::Size(100, 100));
393 396
394 // We should not crash when trying to scroll after the renderer initializati on fails. 397 // We should not crash when trying to scroll after the renderer initializati on fails.
395 EXPECT_EQ(m_hostImpl->ScrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 398 EXPECT_EQ(m_hostImpl->ScrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
396 } 399 }
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 EXPECT_FALSE(m_didRequestRedraw); 1097 EXPECT_FALSE(m_didRequestRedraw);
1095 EXPECT_FALSE(m_didRequestCommit); 1098 EXPECT_FALSE(m_didRequestCommit);
1096 } 1099 }
1097 1100
1098 TEST_F(LayerTreeHostImplTest, scrollNonScrollableRootWithTopControls) 1101 TEST_F(LayerTreeHostImplTest, scrollNonScrollableRootWithTopControls)
1099 { 1102 {
1100 LayerTreeSettings settings; 1103 LayerTreeSettings settings;
1101 settings.calculateTopControlsPosition = true; 1104 settings.calculateTopControlsPosition = true;
1102 settings.topControlsHeight = 50; 1105 settings.topControlsHeight = 50;
1103 1106
1104 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); 1107 m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, m_rendering StatsInstrumentation.get());
1105 m_hostImpl->InitializeRenderer(createOutputSurface()); 1108 m_hostImpl->InitializeRenderer(createOutputSurface());
1106 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 1109 m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
1107 1110
1108 gfx::Size layerSize(5, 5); 1111 gfx::Size layerSize(5, 5);
1109 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->active_tree(), 1) ; 1112 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->active_tree(), 1) ;
1110 root->SetScrollable(true); 1113 root->SetScrollable(true);
1111 root->SetMaxScrollOffset(gfx::Vector2d(layerSize.width(), layerSize.height() )); 1114 root->SetMaxScrollOffset(gfx::Vector2d(layerSize.width(), layerSize.height() ));
1112 root->SetBounds(layerSize); 1115 root->SetBounds(layerSize);
1113 root->SetContentBounds(layerSize); 1116 root->SetContentBounds(layerSize);
1114 root->SetPosition(gfx::PointF(0, 0)); 1117 root->SetPosition(gfx::PointF(0, 0));
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 // where it should request to swap only the subBuffer that is damaged. 2147 // where it should request to swap only the subBuffer that is damaged.
2145 TEST_F(LayerTreeHostImplTest, partialSwapReceivesDamageRect) 2148 TEST_F(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
2146 { 2149 {
2147 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output Surface>(); 2150 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output Surface>();
2148 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->context3d()); 2151 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->context3d());
2149 2152
2150 // This test creates its own LayerTreeHostImpl, so 2153 // This test creates its own LayerTreeHostImpl, so
2151 // that we can force partial swap enabled. 2154 // that we can force partial swap enabled.
2152 LayerTreeSettings settings; 2155 LayerTreeSettings settings;
2153 settings.partialSwapEnabled = true; 2156 settings.partialSwapEnabled = true;
2154 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::Create( settings, this, &m_proxy); 2157 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::Create( settings, this, &m_proxy, m_renderingStatsInstrumentation.get());
2155 layerTreeHostImpl->InitializeRenderer(outputSurface.Pass()); 2158 layerTreeHostImpl->InitializeRenderer(outputSurface.Pass());
2156 layerTreeHostImpl->SetViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)) ; 2159 layerTreeHostImpl->SetViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)) ;
2157 2160
2158 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(layerTreeHostImpl ->active_tree(), 1); 2161 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(layerTreeHostImpl ->active_tree(), 1);
2159 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::Create(layerTreeHostImp l->active_tree(), 2); 2162 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::Create(layerTreeHostImp l->active_tree(), 2);
2160 child->SetPosition(gfx::PointF(12, 13)); 2163 child->SetPosition(gfx::PointF(12, 13));
2161 child->SetAnchorPoint(gfx::PointF(0, 0)); 2164 child->SetAnchorPoint(gfx::PointF(0, 0));
2162 child->SetBounds(gfx::Size(14, 15)); 2165 child->SetBounds(gfx::Size(14, 15));
2163 child->SetContentBounds(gfx::Size(14, 15)); 2166 child->SetContentBounds(gfx::Size(14, 15));
2164 child->SetDrawsContent(true); 2167 child->SetDrawsContent(true);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 } 2439 }
2437 2440
2438 // Unlimited texture size. 2441 // Unlimited texture size.
2439 virtual void getIntegerv(WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) 2442 virtual void getIntegerv(WebKit::WGC3Denum pname, WebKit::WGC3Dint* value)
2440 { 2443 {
2441 if (pname == GL_MAX_TEXTURE_SIZE) 2444 if (pname == GL_MAX_TEXTURE_SIZE)
2442 *value = 8192; 2445 *value = 8192;
2443 } 2446 }
2444 }; 2447 };
2445 2448
2446 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client, Proxy* proxy) 2449 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client, Proxy* proxy, RenderingStatsInstrumentation* Rende ringStatsInstrumentation)
2447 { 2450 {
2448 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >(); 2451 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
2449 2452
2450 LayerTreeSettings settings; 2453 LayerTreeSettings settings;
2451 settings.partialSwapEnabled = partialSwap; 2454 settings.partialSwapEnabled = partialSwap;
2452 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, client, proxy); 2455 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, client, proxy, RenderingStatsInstrumentation);
2453 myHostImpl->InitializeRenderer(outputSurface.Pass()); 2456 myHostImpl->InitializeRenderer(outputSurface.Pass());
2454 myHostImpl->SetViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 2457 myHostImpl->SetViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
2455 2458
2456 /* 2459 /*
2457 Layers are created as follows: 2460 Layers are created as follows:
2458 2461
2459 +--------------------+ 2462 +--------------------+
2460 | 1 | 2463 | 1 |
2461 | +-----------+ | 2464 | +-----------+ |
2462 | | 2 | | 2465 | | 2 | |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 2509
2507 child->AddChild(grandChild.Pass()); 2510 child->AddChild(grandChild.Pass());
2508 root->AddChild(child.Pass()); 2511 root->AddChild(child.Pass());
2509 2512
2510 myHostImpl->active_tree()->SetRootLayer(root.Pass()); 2513 myHostImpl->active_tree()->SetRootLayer(root.Pass());
2511 return myHostImpl.Pass(); 2514 return myHostImpl.Pass();
2512 } 2515 }
2513 2516
2514 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) 2517 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
2515 { 2518 {
2516 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy); 2519 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy, m_renderingStatsInstrumentation.get());
2517 2520
2518 { 2521 {
2519 LayerTreeHostImpl::FrameData frame; 2522 LayerTreeHostImpl::FrameData frame;
2520 EXPECT_TRUE(myHostImpl->PrepareToDraw(&frame)); 2523 EXPECT_TRUE(myHostImpl->PrepareToDraw(&frame));
2521 2524
2522 // Verify all quads have been computed 2525 // Verify all quads have been computed
2523 ASSERT_EQ(2U, frame.render_passes.size()); 2526 ASSERT_EQ(2U, frame.render_passes.size());
2524 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 2527 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
2525 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 2528 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
2526 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.render_passes[0]->quad_list[0]->m aterial); 2529 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.render_passes[0]->quad_list[0]->m aterial);
2527 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.render_passes[1]->quad_list[0]->m aterial); 2530 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.render_passes[1]->quad_list[0]->m aterial);
2528 2531
2529 myHostImpl->DrawLayers(&frame); 2532 myHostImpl->DrawLayers(&frame);
2530 myHostImpl->DidDrawAllLayers(frame); 2533 myHostImpl->DidDrawAllLayers(frame);
2531 } 2534 }
2532 } 2535 }
2533 2536
2534 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) 2537 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
2535 { 2538 {
2536 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this , &m_proxy); 2539 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this , &m_proxy, m_renderingStatsInstrumentation.get());
2537 2540
2538 { 2541 {
2539 LayerTreeHostImpl::FrameData frame; 2542 LayerTreeHostImpl::FrameData frame;
2540 EXPECT_TRUE(myHostImpl->PrepareToDraw(&frame)); 2543 EXPECT_TRUE(myHostImpl->PrepareToDraw(&frame));
2541 2544
2542 // Verify all quads have been computed 2545 // Verify all quads have been computed
2543 ASSERT_EQ(2U, frame.render_passes.size()); 2546 ASSERT_EQ(2U, frame.render_passes.size());
2544 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 2547 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
2545 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 2548 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
2546 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.render_passes[0]->quad_list[0]->m aterial); 2549 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.render_passes[0]->quad_list[0]->m aterial);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 class GLRendererWithReleaseTextures : public GLRenderer { 2744 class GLRendererWithReleaseTextures : public GLRenderer {
2742 public: 2745 public:
2743 using GLRenderer::ReleaseRenderPassTextures; 2746 using GLRenderer::ReleaseRenderPassTextures;
2744 }; 2747 };
2745 2748
2746 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusion) 2749 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusion)
2747 { 2750 {
2748 LayerTreeSettings settings; 2751 LayerTreeSettings settings;
2749 settings.minimumOcclusionTrackingSize = gfx::Size(); 2752 settings.minimumOcclusionTrackingSize = gfx::Size();
2750 settings.cacheRenderPassContents = true; 2753 settings.cacheRenderPassContents = true;
2751 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 2754 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
2752 2755
2753 // Layers are structure as follows: 2756 // Layers are structure as follows:
2754 // 2757 //
2755 // R +-- S1 +- L10 (owning) 2758 // R +-- S1 +- L10 (owning)
2756 // | +- L11 2759 // | +- L11
2757 // | +- L12 2760 // | +- L12
2758 // | 2761 // |
2759 // +-- S2 +- L20 (owning) 2762 // +-- S2 +- L20 (owning)
2760 // +- L21 2763 // +- L21
2761 // 2764 //
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 myHostImpl->DidDrawAllLayers(frame); 2859 myHostImpl->DidDrawAllLayers(frame);
2857 } 2860 }
2858 2861
2859 } 2862 }
2860 2863
2861 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) 2864 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
2862 { 2865 {
2863 LayerTreeSettings settings; 2866 LayerTreeSettings settings;
2864 settings.minimumOcclusionTrackingSize = gfx::Size(); 2867 settings.minimumOcclusionTrackingSize = gfx::Size();
2865 settings.cacheRenderPassContents = true; 2868 settings.cacheRenderPassContents = true;
2866 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 2869 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
2867 2870
2868 // Layers are structure as follows: 2871 // Layers are structure as follows:
2869 // 2872 //
2870 // R +-- S1 +- L10 (owning, non drawing) 2873 // R +-- S1 +- L10 (owning, non drawing)
2871 // | +- L11 (corner, unoccluded) 2874 // | +- L11 (corner, unoccluded)
2872 // | +- L12 (corner, unoccluded) 2875 // | +- L12 (corner, unoccluded)
2873 // | +- L13 (corner, unoccluded) 2876 // | +- L13 (corner, unoccluded)
2874 // | +- L14 (corner, entirely occluded) 2877 // | +- L14 (corner, entirely occluded)
2875 // | 2878 // |
2876 // +-- S2 +- L20 (owning, drawing) 2879 // +-- S2 +- L20 (owning, drawing)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 myHostImpl->DrawLayers(&frame); 2974 myHostImpl->DrawLayers(&frame);
2972 myHostImpl->DidDrawAllLayers(frame); 2975 myHostImpl->DidDrawAllLayers(frame);
2973 } 2976 }
2974 } 2977 }
2975 2978
2976 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) 2979 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
2977 { 2980 {
2978 LayerTreeSettings settings; 2981 LayerTreeSettings settings;
2979 settings.minimumOcclusionTrackingSize = gfx::Size(); 2982 settings.minimumOcclusionTrackingSize = gfx::Size();
2980 settings.cacheRenderPassContents = true; 2983 settings.cacheRenderPassContents = true;
2981 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 2984 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
2982 2985
2983 // Layers are structured as follows: 2986 // Layers are structured as follows:
2984 // 2987 //
2985 // R +-- S1 +- L10 (owning, drawing) 2988 // R +-- S1 +- L10 (owning, drawing)
2986 // | +- L11 (corner, occluded by L12) 2989 // | +- L11 (corner, occluded by L12)
2987 // | +- L12 (opposite corner) 2990 // | +- L12 (opposite corner)
2988 // | 2991 // |
2989 // +-- S2 +- L20 (owning, drawing) 2992 // +-- S2 +- L20 (owning, drawing)
2990 // 2993 //
2991 2994
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 3061
3059 myHostImpl->DrawLayers(&frame); 3062 myHostImpl->DrawLayers(&frame);
3060 myHostImpl->DidDrawAllLayers(frame); 3063 myHostImpl->DidDrawAllLayers(frame);
3061 } 3064 }
3062 } 3065 }
3063 3066
3064 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) 3067 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
3065 { 3068 {
3066 LayerTreeSettings settings; 3069 LayerTreeSettings settings;
3067 settings.cacheRenderPassContents = true; 3070 settings.cacheRenderPassContents = true;
3068 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 3071 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
3069 3072
3070 // Layers are structured as follows: 3073 // Layers are structured as follows:
3071 // 3074 //
3072 // R +-- S1 +- L10 (rotated, drawing) 3075 // R +-- S1 +- L10 (rotated, drawing)
3073 // +- L11 (occupies half surface) 3076 // +- L11 (occupies half surface)
3074 3077
3075 LayerImpl* rootPtr; 3078 LayerImpl* rootPtr;
3076 LayerImpl* layerS1Ptr; 3079 LayerImpl* layerS1Ptr;
3077 3080
3078 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >(); 3081 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 myHostImpl->DidDrawAllLayers(frame); 3136 myHostImpl->DidDrawAllLayers(frame);
3134 } 3137 }
3135 } 3138 }
3136 3139
3137 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) 3140 TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
3138 { 3141 {
3139 LayerTreeSettings settings; 3142 LayerTreeSettings settings;
3140 settings.minimumOcclusionTrackingSize = gfx::Size(); 3143 settings.minimumOcclusionTrackingSize = gfx::Size();
3141 settings.partialSwapEnabled = true; 3144 settings.partialSwapEnabled = true;
3142 settings.cacheRenderPassContents = true; 3145 settings.cacheRenderPassContents = true;
3143 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 3146 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
3144 3147
3145 // Layers are structure as follows: 3148 // Layers are structure as follows:
3146 // 3149 //
3147 // R +-- S1 +- L10 (owning) 3150 // R +-- S1 +- L10 (owning)
3148 // | +- L11 3151 // | +- L11
3149 // | +- L12 3152 // | +- L12
3150 // | 3153 // |
3151 // +-- S2 +- L20 (owning) 3154 // +-- S2 +- L20 (owning)
3152 // +- L21 3155 // +- L21
3153 // 3156 //
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 myHostImpl->DrawLayers(&frame); 3248 myHostImpl->DrawLayers(&frame);
3246 myHostImpl->DidDrawAllLayers(frame); 3249 myHostImpl->DidDrawAllLayers(frame);
3247 } 3250 }
3248 } 3251 }
3249 3252
3250 TEST_F(LayerTreeHostImplTest, textureCachingWithScissor) 3253 TEST_F(LayerTreeHostImplTest, textureCachingWithScissor)
3251 { 3254 {
3252 LayerTreeSettings settings; 3255 LayerTreeSettings settings;
3253 settings.minimumOcclusionTrackingSize = gfx::Size(); 3256 settings.minimumOcclusionTrackingSize = gfx::Size();
3254 settings.cacheRenderPassContents = true; 3257 settings.cacheRenderPassContents = true;
3255 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 3258 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
3256 3259
3257 /* 3260 /*
3258 Layers are created as follows: 3261 Layers are created as follows:
3259 3262
3260 +--------------------+ 3263 +--------------------+
3261 | 1 | 3264 | 1 |
3262 | +-----------+ | 3265 | +-----------+ |
3263 | | 2 | | 3266 | | 2 | |
3264 | | +-------------------+ 3267 | | +-------------------+
3265 | | | 3 | 3268 | | | 3 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 // We should have a cached texture for surface 2 again even though it was da maged. 3355 // We should have a cached texture for surface 2 again even though it was da maged.
3353 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child PassId)); 3356 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child PassId));
3354 } 3357 }
3355 3358
3356 TEST_F(LayerTreeHostImplTest, surfaceTextureCaching) 3359 TEST_F(LayerTreeHostImplTest, surfaceTextureCaching)
3357 { 3360 {
3358 LayerTreeSettings settings; 3361 LayerTreeSettings settings;
3359 settings.minimumOcclusionTrackingSize = gfx::Size(); 3362 settings.minimumOcclusionTrackingSize = gfx::Size();
3360 settings.partialSwapEnabled = true; 3363 settings.partialSwapEnabled = true;
3361 settings.cacheRenderPassContents = true; 3364 settings.cacheRenderPassContents = true;
3362 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 3365 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
3363 3366
3364 LayerImpl* rootPtr; 3367 LayerImpl* rootPtr;
3365 LayerImpl* intermediateLayerPtr; 3368 LayerImpl* intermediateLayerPtr;
3366 LayerImpl* surfaceLayerPtr; 3369 LayerImpl* surfaceLayerPtr;
3367 LayerImpl* childPtr; 3370 LayerImpl* childPtr;
3368 3371
3369 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100)); 3372 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100));
3370 3373
3371 { 3374 {
3372 LayerTreeHostImpl::FrameData frame; 3375 LayerTreeHostImpl::FrameData frame;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 myHostImpl->DrawLayers(&frame); 3514 myHostImpl->DrawLayers(&frame);
3512 myHostImpl->DidDrawAllLayers(frame); 3515 myHostImpl->DidDrawAllLayers(frame);
3513 } 3516 }
3514 } 3517 }
3515 3518
3516 TEST_F(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) 3519 TEST_F(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
3517 { 3520 {
3518 LayerTreeSettings settings; 3521 LayerTreeSettings settings;
3519 settings.minimumOcclusionTrackingSize = gfx::Size(); 3522 settings.minimumOcclusionTrackingSize = gfx::Size();
3520 settings.cacheRenderPassContents = true; 3523 settings.cacheRenderPassContents = true;
3521 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy); 3524 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(setting s, this, &m_proxy, m_renderingStatsInstrumentation.get());
3522 3525
3523 LayerImpl* rootPtr; 3526 LayerImpl* rootPtr;
3524 LayerImpl* intermediateLayerPtr; 3527 LayerImpl* intermediateLayerPtr;
3525 LayerImpl* surfaceLayerPtr; 3528 LayerImpl* surfaceLayerPtr;
3526 LayerImpl* childPtr; 3529 LayerImpl* childPtr;
3527 3530
3528 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100)); 3531 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100));
3529 3532
3530 { 3533 {
3531 LayerTreeHostImpl::FrameData frame; 3534 LayerTreeHostImpl::FrameData frame;
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
4341 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS tring()); 4344 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS tring());
4342 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas k_uv_rect.ToString()); 4345 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas k_uv_rect.ToString());
4343 4346
4344 m_hostImpl->DrawLayers(&frame); 4347 m_hostImpl->DrawLayers(&frame);
4345 m_hostImpl->DidDrawAllLayers(frame); 4348 m_hostImpl->DidDrawAllLayers(frame);
4346 } 4349 }
4347 } 4350 }
4348 4351
4349 } // namespace 4352 } // namespace
4350 } // namespace cc 4353 } // namespace cc
OLDNEW
« cc/layer_tree_host.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | cc/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698