OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include "cc/output/compositor_frame_metadata.h" | 7 #include "cc/output/compositor_frame_metadata.h" |
8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
10 #include "cc/resources/sync_point_helper.h" | 10 #include "cc/resources/sync_point_helper.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 output_surface_(FakeOutputSurface::Create3d( | 241 output_surface_(FakeOutputSurface::Create3d( |
242 scoped_ptr<WebKit::WebGraphicsContext3D>( | 242 scoped_ptr<WebKit::WebGraphicsContext3D>( |
243 new FrameCountingMemoryAllocationSettingContext()))), | 243 new FrameCountingMemoryAllocationSettingContext()))), |
244 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), | 244 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), |
245 renderer_(&mock_client_, | 245 renderer_(&mock_client_, |
246 output_surface_.get(), | 246 output_surface_.get(), |
247 resource_provider_.get()) {} | 247 resource_provider_.get()) {} |
248 | 248 |
249 virtual void SetUp() { renderer_.Initialize(); } | 249 virtual void SetUp() { renderer_.Initialize(); } |
250 | 250 |
251 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } | 251 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); } |
252 | 252 |
253 FrameCountingMemoryAllocationSettingContext* Context() { | 253 FrameCountingMemoryAllocationSettingContext* Context() { |
254 return static_cast<FrameCountingMemoryAllocationSettingContext*>( | 254 return static_cast<FrameCountingMemoryAllocationSettingContext*>( |
255 output_surface_->context3d()); | 255 output_surface_->context3d()); |
256 } | 256 } |
257 | 257 |
258 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_; | 258 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_; |
259 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_; | 259 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_; |
260 | 260 |
261 scoped_ptr<OutputSurface> output_surface_; | 261 scoped_ptr<OutputSurface> output_surface_; |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 MockOutputSurface() | 1337 MockOutputSurface() |
1338 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( | 1338 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( |
1339 new StrictMock<OutputSurfaceMockContext>)) {} | 1339 new StrictMock<OutputSurfaceMockContext>)) {} |
1340 virtual ~MockOutputSurface() {} | 1340 virtual ~MockOutputSurface() {} |
1341 | 1341 |
1342 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); | 1342 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); |
1343 MOCK_METHOD0(EnsureBackbuffer, void()); | 1343 MOCK_METHOD0(EnsureBackbuffer, void()); |
1344 MOCK_METHOD0(DiscardBackbuffer, void()); | 1344 MOCK_METHOD0(DiscardBackbuffer, void()); |
1345 MOCK_METHOD1(Reshape, void(gfx::Size size)); | 1345 MOCK_METHOD1(Reshape, void(gfx::Size size)); |
1346 MOCK_METHOD0(BindFramebuffer, void()); | 1346 MOCK_METHOD0(BindFramebuffer, void()); |
1347 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const LatencyInfo&)); | 1347 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const ui::LatencyInfo&)); |
1348 MOCK_METHOD1(SwapBuffers, void(const LatencyInfo&)); | 1348 MOCK_METHOD1(SwapBuffers, void(const ui::LatencyInfo&)); |
1349 }; | 1349 }; |
1350 | 1350 |
1351 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { | 1351 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { |
1352 protected: | 1352 protected: |
1353 MockOutputSurfaceTest() | 1353 MockOutputSurfaceTest() |
1354 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), | 1354 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), |
1355 renderer_(this, &output_surface_, resource_provider_.get()) {} | 1355 renderer_(this, &output_surface_, resource_provider_.get()) {} |
1356 | 1356 |
1357 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } | 1357 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } |
1358 | 1358 |
1359 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } | 1359 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); } |
1360 | 1360 |
1361 void DrawFrame() { | 1361 void DrawFrame() { |
1362 gfx::Rect viewport_rect(DeviceViewportSize()); | 1362 gfx::Rect viewport_rect(DeviceViewportSize()); |
1363 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 1363 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
1364 render_passes->clear(); | 1364 render_passes->clear(); |
1365 | 1365 |
1366 RenderPass::Id render_pass_id(1, 0); | 1366 RenderPass::Id render_pass_id(1, 0); |
1367 TestRenderPass* render_pass = AddRenderPass( | 1367 TestRenderPass* render_pass = AddRenderPass( |
1368 render_passes, render_pass_id, viewport_rect, gfx::Transform()); | 1368 render_passes, render_pass_id, viewport_rect, gfx::Transform()); |
1369 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); | 1369 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); |
(...skipping 17 matching lines...) Expand all Loading... |
1387 | 1387 |
1388 StrictMock<MockOutputSurface> output_surface_; | 1388 StrictMock<MockOutputSurface> output_surface_; |
1389 scoped_ptr<ResourceProvider> resource_provider_; | 1389 scoped_ptr<ResourceProvider> resource_provider_; |
1390 FakeRendererGL renderer_; | 1390 FakeRendererGL renderer_; |
1391 }; | 1391 }; |
1392 | 1392 |
1393 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { | 1393 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { |
1394 DrawFrame(); | 1394 DrawFrame(); |
1395 | 1395 |
1396 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1396 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1397 renderer_.SwapBuffers(LatencyInfo()); | 1397 renderer_.SwapBuffers(ui::LatencyInfo()); |
1398 } | 1398 } |
1399 | 1399 |
1400 class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest { | 1400 class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest { |
1401 public: | 1401 public: |
1402 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 1402 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
1403 static LayerTreeSettings fake_settings; | 1403 static LayerTreeSettings fake_settings; |
1404 fake_settings.partial_swap_enabled = true; | 1404 fake_settings.partial_swap_enabled = true; |
1405 return fake_settings; | 1405 return fake_settings; |
1406 } | 1406 } |
1407 }; | 1407 }; |
1408 | 1408 |
1409 TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) { | 1409 TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) { |
1410 DrawFrame(); | 1410 DrawFrame(); |
1411 | 1411 |
1412 EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1); | 1412 EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1); |
1413 renderer_.SwapBuffers(LatencyInfo()); | 1413 renderer_.SwapBuffers(ui::LatencyInfo()); |
1414 } | 1414 } |
1415 | 1415 |
1416 class MockOutputSurfaceTestWithSendCompositorFrame | 1416 class MockOutputSurfaceTestWithSendCompositorFrame |
1417 : public MockOutputSurfaceTest { | 1417 : public MockOutputSurfaceTest { |
1418 public: | 1418 public: |
1419 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 1419 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
1420 static LayerTreeSettings fake_settings; | 1420 static LayerTreeSettings fake_settings; |
1421 fake_settings.compositor_frame_message = true; | 1421 fake_settings.compositor_frame_message = true; |
1422 return fake_settings; | 1422 return fake_settings; |
1423 } | 1423 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 base::MessageLoop::current()->Run(); | 1493 base::MessageLoop::current()->Run(); |
1494 | 1494 |
1495 // The sync point should have happened. | 1495 // The sync point should have happened. |
1496 EXPECT_EQ(1, sync_point_callback_count); | 1496 EXPECT_EQ(1, sync_point_callback_count); |
1497 EXPECT_EQ(1, other_callback_count); | 1497 EXPECT_EQ(1, other_callback_count); |
1498 } | 1498 } |
1499 #endif // OS_ANDROID | 1499 #endif // OS_ANDROID |
1500 | 1500 |
1501 } // namespace | 1501 } // namespace |
1502 } // namespace cc | 1502 } // namespace cc |
OLD | NEW |