| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/output/compositor_frame_metadata.h" | 10 #include "cc/output/compositor_frame_metadata.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 output_surface_(FakeOutputSurface::Create3d( | 261 output_surface_(FakeOutputSurface::Create3d( |
| 262 scoped_ptr<WebKit::WebGraphicsContext3D>( | 262 scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 263 new FrameCountingMemoryAllocationSettingContext()))), | 263 new FrameCountingMemoryAllocationSettingContext()))), |
| 264 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), | 264 resource_provider_(ResourceProvider::Create(output_surface_.get(), 0)), |
| 265 renderer_(&mock_client_, | 265 renderer_(&mock_client_, |
| 266 output_surface_.get(), | 266 output_surface_.get(), |
| 267 resource_provider_.get()) {} | 267 resource_provider_.get()) {} |
| 268 | 268 |
| 269 virtual void SetUp() { renderer_.Initialize(); } | 269 virtual void SetUp() { renderer_.Initialize(); } |
| 270 | 270 |
| 271 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } | 271 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); } |
| 272 | 272 |
| 273 FrameCountingMemoryAllocationSettingContext* Context() { | 273 FrameCountingMemoryAllocationSettingContext* Context() { |
| 274 return static_cast<FrameCountingMemoryAllocationSettingContext*>( | 274 return static_cast<FrameCountingMemoryAllocationSettingContext*>( |
| 275 output_surface_->context3d()); | 275 output_surface_->context3d()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_; | 278 WebGraphicsMemoryAllocation suggest_have_backbuffer_yes_; |
| 279 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_; | 279 WebGraphicsMemoryAllocation suggest_have_backbuffer_no_; |
| 280 | 280 |
| 281 scoped_ptr<OutputSurface> output_surface_; | 281 scoped_ptr<OutputSurface> output_surface_; |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 MockOutputSurface() | 1475 MockOutputSurface() |
| 1476 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( | 1476 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( |
| 1477 new StrictMock<OutputSurfaceMockContext>)) {} | 1477 new StrictMock<OutputSurfaceMockContext>)) {} |
| 1478 virtual ~MockOutputSurface() {} | 1478 virtual ~MockOutputSurface() {} |
| 1479 | 1479 |
| 1480 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); | 1480 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); |
| 1481 MOCK_METHOD0(EnsureBackbuffer, void()); | 1481 MOCK_METHOD0(EnsureBackbuffer, void()); |
| 1482 MOCK_METHOD0(DiscardBackbuffer, void()); | 1482 MOCK_METHOD0(DiscardBackbuffer, void()); |
| 1483 MOCK_METHOD2(Reshape, void(gfx::Size size, float scale_factor)); | 1483 MOCK_METHOD2(Reshape, void(gfx::Size size, float scale_factor)); |
| 1484 MOCK_METHOD0(BindFramebuffer, void()); | 1484 MOCK_METHOD0(BindFramebuffer, void()); |
| 1485 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const LatencyInfo&)); | 1485 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const ui::LatencyInfo&)); |
| 1486 MOCK_METHOD1(SwapBuffers, void(const LatencyInfo&)); | 1486 MOCK_METHOD1(SwapBuffers, void(const ui::LatencyInfo&)); |
| 1487 }; | 1487 }; |
| 1488 | 1488 |
| 1489 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { | 1489 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { |
| 1490 protected: | 1490 protected: |
| 1491 MockOutputSurfaceTest() | 1491 MockOutputSurfaceTest() |
| 1492 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), | 1492 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), |
| 1493 renderer_(this, &output_surface_, resource_provider_.get()) {} | 1493 renderer_(this, &output_surface_, resource_provider_.get()) {} |
| 1494 | 1494 |
| 1495 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } | 1495 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } |
| 1496 | 1496 |
| 1497 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } | 1497 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); } |
| 1498 | 1498 |
| 1499 void DrawFrame() { | 1499 void DrawFrame() { |
| 1500 gfx::Rect viewport_rect(DeviceViewportSize()); | 1500 gfx::Rect viewport_rect(DeviceViewportSize()); |
| 1501 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 1501 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
| 1502 render_passes->clear(); | 1502 render_passes->clear(); |
| 1503 | 1503 |
| 1504 RenderPass::Id render_pass_id(1, 0); | 1504 RenderPass::Id render_pass_id(1, 0); |
| 1505 TestRenderPass* render_pass = AddRenderPass( | 1505 TestRenderPass* render_pass = AddRenderPass( |
| 1506 render_passes, render_pass_id, viewport_rect, gfx::Transform()); | 1506 render_passes, render_pass_id, viewport_rect, gfx::Transform()); |
| 1507 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); | 1507 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1529 | 1529 |
| 1530 StrictMock<MockOutputSurface> output_surface_; | 1530 StrictMock<MockOutputSurface> output_surface_; |
| 1531 scoped_ptr<ResourceProvider> resource_provider_; | 1531 scoped_ptr<ResourceProvider> resource_provider_; |
| 1532 FakeRendererGL renderer_; | 1532 FakeRendererGL renderer_; |
| 1533 }; | 1533 }; |
| 1534 | 1534 |
| 1535 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { | 1535 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { |
| 1536 DrawFrame(); | 1536 DrawFrame(); |
| 1537 | 1537 |
| 1538 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1538 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1539 renderer_.SwapBuffers(LatencyInfo()); | 1539 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) { | 1542 TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) { |
| 1543 DrawFrame(); | 1543 DrawFrame(); |
| 1544 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1544 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1545 renderer_.SwapBuffers(LatencyInfo()); | 1545 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1546 | 1546 |
| 1547 set_viewport_and_scale(gfx::Size(2, 2), 2.f); | 1547 set_viewport_and_scale(gfx::Size(2, 2), 2.f); |
| 1548 renderer_.ViewportChanged(); | 1548 renderer_.ViewportChanged(); |
| 1549 | 1549 |
| 1550 DrawFrame(); | 1550 DrawFrame(); |
| 1551 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1551 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1552 renderer_.SwapBuffers(LatencyInfo()); | 1552 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1553 | 1553 |
| 1554 DrawFrame(); | 1554 DrawFrame(); |
| 1555 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1555 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1556 renderer_.SwapBuffers(LatencyInfo()); | 1556 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1557 | 1557 |
| 1558 set_viewport_and_scale(gfx::Size(1, 1), 1.f); | 1558 set_viewport_and_scale(gfx::Size(1, 1), 1.f); |
| 1559 renderer_.ViewportChanged(); | 1559 renderer_.ViewportChanged(); |
| 1560 | 1560 |
| 1561 DrawFrame(); | 1561 DrawFrame(); |
| 1562 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1562 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1563 renderer_.SwapBuffers(LatencyInfo()); | 1563 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest { | 1566 class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest { |
| 1567 public: | 1567 public: |
| 1568 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 1568 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
| 1569 static LayerTreeSettings fake_settings; | 1569 static LayerTreeSettings fake_settings; |
| 1570 fake_settings.partial_swap_enabled = true; | 1570 fake_settings.partial_swap_enabled = true; |
| 1571 return fake_settings; | 1571 return fake_settings; |
| 1572 } | 1572 } |
| 1573 }; | 1573 }; |
| 1574 | 1574 |
| 1575 TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) { | 1575 TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) { |
| 1576 DrawFrame(); | 1576 DrawFrame(); |
| 1577 | 1577 |
| 1578 EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1); | 1578 EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1); |
| 1579 renderer_.SwapBuffers(LatencyInfo()); | 1579 renderer_.SwapBuffers(ui::LatencyInfo()); |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 class MockOutputSurfaceTestWithSendCompositorFrame | 1582 class MockOutputSurfaceTestWithSendCompositorFrame |
| 1583 : public MockOutputSurfaceTest { | 1583 : public MockOutputSurfaceTest { |
| 1584 public: | 1584 public: |
| 1585 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 1585 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
| 1586 static LayerTreeSettings fake_settings; | 1586 static LayerTreeSettings fake_settings; |
| 1587 fake_settings.compositor_frame_message = true; | 1587 fake_settings.compositor_frame_message = true; |
| 1588 return fake_settings; | 1588 return fake_settings; |
| 1589 } | 1589 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 base::MessageLoop::current()->Run(); | 1659 base::MessageLoop::current()->Run(); |
| 1660 | 1660 |
| 1661 // The sync point should have happened. | 1661 // The sync point should have happened. |
| 1662 EXPECT_EQ(1, sync_point_callback_count); | 1662 EXPECT_EQ(1, sync_point_callback_count); |
| 1663 EXPECT_EQ(1, other_callback_count); | 1663 EXPECT_EQ(1, other_callback_count); |
| 1664 } | 1664 } |
| 1665 #endif // OS_ANDROID | 1665 #endif // OS_ANDROID |
| 1666 | 1666 |
| 1667 } // namespace | 1667 } // namespace |
| 1668 } // namespace cc | 1668 } // namespace cc |
| OLD | NEW |