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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 root_render_pass->SetNew( | 159 root_render_pass->SetNew( |
160 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); | 160 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); |
161 render_passes_in_draw_order_.push_back(root_render_pass.Pass()); | 161 render_passes_in_draw_order_.push_back(root_render_pass.Pass()); |
162 } | 162 } |
163 | 163 |
164 // RendererClient methods. | 164 // RendererClient methods. |
165 virtual gfx::Size DeviceViewportSize() const OVERRIDE { | 165 virtual gfx::Size DeviceViewportSize() const OVERRIDE { |
166 static gfx::Size fake_size(1, 1); | 166 static gfx::Size fake_size(1, 1); |
167 return fake_size; | 167 return fake_size; |
168 } | 168 } |
169 virtual float DeviceScaleFactor() const OVERRIDE { | |
170 return 1.f; | |
danakj
2013/05/22 14:08:42
Can we have a test where this is != 1?
ccameron
2013/05/22 18:26:11
The test wasn't verifying any of the Reshape argum
| |
171 } | |
169 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 172 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
170 static LayerTreeSettings fake_settings; | 173 static LayerTreeSettings fake_settings; |
171 return fake_settings; | 174 return fake_settings; |
172 } | 175 } |
173 virtual void SetFullRootLayerDamage() OVERRIDE { | 176 virtual void SetFullRootLayerDamage() OVERRIDE { |
174 set_full_root_layer_damage_count_++; | 177 set_full_root_layer_damage_count_++; |
175 } | 178 } |
176 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) | 179 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) |
177 OVERRIDE { | 180 OVERRIDE { |
178 memory_allocation_limit_bytes_ = policy.bytes_limit_when_visible; | 181 memory_allocation_limit_bytes_ = policy.bytes_limit_when_visible; |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { | 1433 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { |
1431 public: | 1434 public: |
1432 // Specifically override methods even if they are unused (used in conjunction | 1435 // Specifically override methods even if they are unused (used in conjunction |
1433 // with StrictMock). We need to make sure that GLRenderer does not issue | 1436 // with StrictMock). We need to make sure that GLRenderer does not issue |
1434 // framebuffer-related GL calls directly. Instead these are supposed to go | 1437 // framebuffer-related GL calls directly. Instead these are supposed to go |
1435 // through the OutputSurface abstraction. | 1438 // through the OutputSurface abstraction. |
1436 MOCK_METHOD0(ensureBackbufferCHROMIUM, void()); | 1439 MOCK_METHOD0(ensureBackbufferCHROMIUM, void()); |
1437 MOCK_METHOD0(discardBackbufferCHROMIUM, void()); | 1440 MOCK_METHOD0(discardBackbufferCHROMIUM, void()); |
1438 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer)); | 1441 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer)); |
1439 MOCK_METHOD0(prepareTexture, void()); | 1442 MOCK_METHOD0(prepareTexture, void()); |
1440 MOCK_METHOD2(reshape, void(int width, int height)); | 1443 MOCK_METHOD3(reshapeWithScaleFactor, |
1444 void(int width, int height, float scale_factor)); | |
1441 MOCK_METHOD4(drawElements, | 1445 MOCK_METHOD4(drawElements, |
1442 void(WGC3Denum mode, | 1446 void(WGC3Denum mode, |
1443 WGC3Dsizei count, | 1447 WGC3Dsizei count, |
1444 WGC3Denum type, | 1448 WGC3Denum type, |
1445 WGC3Dintptr offset)); | 1449 WGC3Dintptr offset)); |
1446 | 1450 |
1447 virtual WebString getString(WebKit::WGC3Denum name) { | 1451 virtual WebString getString(WebKit::WGC3Denum name) { |
1448 if (name == GL_EXTENSIONS) | 1452 if (name == GL_EXTENSIONS) |
1449 return WebString( | 1453 return WebString( |
1450 "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_discard_backbuffer"); | 1454 "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_discard_backbuffer"); |
1451 return WebString(); | 1455 return WebString(); |
1452 } | 1456 } |
1453 }; | 1457 }; |
1454 | 1458 |
1455 class MockOutputSurface : public OutputSurface { | 1459 class MockOutputSurface : public OutputSurface { |
1456 public: | 1460 public: |
1457 MockOutputSurface() | 1461 MockOutputSurface() |
1458 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( | 1462 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( |
1459 new StrictMock<OutputSurfaceMockContext>)) {} | 1463 new StrictMock<OutputSurfaceMockContext>)) {} |
1460 virtual ~MockOutputSurface() {} | 1464 virtual ~MockOutputSurface() {} |
1461 | 1465 |
1462 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); | 1466 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); |
1463 MOCK_METHOD0(EnsureBackbuffer, void()); | 1467 MOCK_METHOD0(EnsureBackbuffer, void()); |
1464 MOCK_METHOD0(DiscardBackbuffer, void()); | 1468 MOCK_METHOD0(DiscardBackbuffer, void()); |
1465 MOCK_METHOD1(Reshape, void(gfx::Size size)); | 1469 MOCK_METHOD2(Reshape, void(gfx::Size size, float scale_factor)); |
1466 MOCK_METHOD0(BindFramebuffer, void()); | 1470 MOCK_METHOD0(BindFramebuffer, void()); |
1467 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const LatencyInfo&)); | 1471 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const LatencyInfo&)); |
1468 MOCK_METHOD1(SwapBuffers, void(const LatencyInfo&)); | 1472 MOCK_METHOD1(SwapBuffers, void(const LatencyInfo&)); |
1469 }; | 1473 }; |
1470 | 1474 |
1471 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { | 1475 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { |
1472 protected: | 1476 protected: |
1473 MockOutputSurfaceTest() | 1477 MockOutputSurfaceTest() |
1474 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), | 1478 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), |
1475 renderer_(this, &output_surface_, resource_provider_.get()) {} | 1479 renderer_(this, &output_surface_, resource_provider_.get()) {} |
1476 | 1480 |
1477 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } | 1481 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } |
1478 | 1482 |
1479 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } | 1483 void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); } |
1480 | 1484 |
1481 void DrawFrame() { | 1485 void DrawFrame() { |
1482 gfx::Rect viewport_rect(DeviceViewportSize()); | 1486 gfx::Rect viewport_rect(DeviceViewportSize()); |
1483 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 1487 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
1484 render_passes->clear(); | 1488 render_passes->clear(); |
1485 | 1489 |
1486 RenderPass::Id render_pass_id(1, 0); | 1490 RenderPass::Id render_pass_id(1, 0); |
1487 TestRenderPass* render_pass = AddRenderPass( | 1491 TestRenderPass* render_pass = AddRenderPass( |
1488 render_passes, render_pass_id, viewport_rect, gfx::Transform()); | 1492 render_passes, render_pass_id, viewport_rect, gfx::Transform()); |
1489 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); | 1493 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); |
1490 | 1494 |
1491 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); | 1495 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); |
1492 | 1496 |
1493 EXPECT_CALL(output_surface_, Reshape(_)).Times(1); | 1497 EXPECT_CALL(output_surface_, Reshape(_, _)).Times(1); |
1494 | 1498 |
1495 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); | 1499 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); |
1496 | 1500 |
1497 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); | 1501 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); |
1498 | 1502 |
1499 renderer_.DecideRenderPassAllocationsForFrame( | 1503 renderer_.DecideRenderPassAllocationsForFrame( |
1500 *render_passes_in_draw_order()); | 1504 *render_passes_in_draw_order()); |
1501 renderer_.DrawFrame(render_passes_in_draw_order()); | 1505 renderer_.DrawFrame(render_passes_in_draw_order()); |
1502 } | 1506 } |
1503 | 1507 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1613 base::MessageLoop::current()->Run(); | 1617 base::MessageLoop::current()->Run(); |
1614 | 1618 |
1615 // The sync point should have happened. | 1619 // The sync point should have happened. |
1616 EXPECT_EQ(1, sync_point_callback_count); | 1620 EXPECT_EQ(1, sync_point_callback_count); |
1617 EXPECT_EQ(1, other_callback_count); | 1621 EXPECT_EQ(1, other_callback_count); |
1618 } | 1622 } |
1619 #endif // OS_ANDROID | 1623 #endif // OS_ANDROID |
1620 | 1624 |
1621 } // namespace | 1625 } // namespace |
1622 } // namespace cc | 1626 } // namespace cc |
OLD | NEW |