| OLD | NEW |
| 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 | 1431 |
| 1432 switch (impl->active_tree()->source_frame_number()) { | 1432 switch (impl->active_tree()->source_frame_number()) { |
| 1433 case 0: | 1433 case 0: |
| 1434 // Number of textures should be one for each layer | 1434 // Number of textures should be one for each layer |
| 1435 ASSERT_EQ(2u, context->NumTextures()); | 1435 ASSERT_EQ(2u, context->NumTextures()); |
| 1436 // Number of textures used for commit should be one for each layer. | 1436 // Number of textures used for commit should be one for each layer. |
| 1437 EXPECT_EQ(2u, context->NumUsedTextures()); | 1437 EXPECT_EQ(2u, context->NumUsedTextures()); |
| 1438 // Verify that used texture is correct. | 1438 // Verify that used texture is correct. |
| 1439 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1439 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| 1440 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1440 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| 1441 context->ResetUsedTextures(); | |
| 1442 break; | 1441 break; |
| 1443 case 1: | 1442 case 1: |
| 1444 // Number of textures should be doubled as the first context layer | 1443 // Number of textures should be doubled as the first context layer |
| 1445 // texture is being used by the impl-thread and cannot be used for | 1444 // texture is being used by the impl-thread and cannot be used for |
| 1446 // update. The scrollbar behavior is different direct renderer because | 1445 // update. The scrollbar behavior is different direct renderer because |
| 1447 // UI resource deletion with delegating renderer occurs after tree | 1446 // UI resource deletion with delegating renderer occurs after tree |
| 1448 // activation. | 1447 // activation. |
| 1449 ASSERT_EQ(4u, context->NumTextures()); | 1448 ASSERT_EQ(4u, context->NumTextures()); |
| 1450 // Number of textures used for commit should still be | 1449 // Number of textures used for commit should still be |
| 1451 // one for each layer. | 1450 // one for each layer. |
| 1452 EXPECT_EQ(2u, context->NumUsedTextures()); | 1451 EXPECT_EQ(2u, context->NumUsedTextures()); |
| 1453 // First textures should not have been used. | 1452 // First textures should not have been used. |
| 1454 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | 1453 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
| 1455 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); | 1454 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
| 1456 // New textures should have been used. | 1455 // New textures should have been used. |
| 1457 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | 1456 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| 1458 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1457 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| 1459 context->ResetUsedTextures(); | |
| 1460 break; | 1458 break; |
| 1461 case 2: | 1459 case 2: |
| 1462 EndTest(); | 1460 EndTest(); |
| 1463 break; | 1461 break; |
| 1464 default: | 1462 default: |
| 1465 NOTREACHED(); | 1463 NOTREACHED(); |
| 1466 break; | 1464 break; |
| 1467 } | 1465 } |
| 1468 } | 1466 } |
| 1469 }; | 1467 }; |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target, | 2647 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target, |
| 2650 GLint width, | 2648 GLint width, |
| 2651 GLint height, | 2649 GLint height, |
| 2652 GLuint ioSurfaceId, | 2650 GLuint ioSurfaceId, |
| 2653 GLuint plane)); | 2651 GLuint plane)); |
| 2654 MOCK_METHOD4(drawElements, void(GLenum mode, | 2652 MOCK_METHOD4(drawElements, void(GLenum mode, |
| 2655 GLsizei count, | 2653 GLsizei count, |
| 2656 GLenum type, | 2654 GLenum type, |
| 2657 GLintptr offset)); | 2655 GLintptr offset)); |
| 2658 MOCK_METHOD1(deleteTexture, void(GLenum texture)); | 2656 MOCK_METHOD1(deleteTexture, void(GLenum texture)); |
| 2659 MOCK_METHOD2(produceTextureCHROMIUM, | 2657 MOCK_METHOD3(produceTextureDirectCHROMIUM, |
| 2660 void(GLenum target, const GLbyte* mailbox)); | 2658 void(GLuint texture, GLenum target, const GLbyte* mailbox)); |
| 2661 }; | 2659 }; |
| 2662 | 2660 |
| 2663 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { | 2661 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { |
| 2664 protected: | 2662 protected: |
| 2665 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 2663 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2666 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( | 2664 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( |
| 2667 new MockIOSurfaceWebGraphicsContext3D); | 2665 new MockIOSurfaceWebGraphicsContext3D); |
| 2668 mock_context_ = mock_context_owned.get(); | 2666 mock_context_ = mock_context_owned.get(); |
| 2669 | 2667 |
| 2670 if (delegating_renderer()) | 2668 if (delegating_renderer()) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); | 2738 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); |
| 2741 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); | 2739 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); |
| 2742 const IOSurfaceDrawQuad* io_surface_draw_quad = | 2740 const IOSurfaceDrawQuad* io_surface_draw_quad = |
| 2743 IOSurfaceDrawQuad::MaterialCast(quad); | 2741 IOSurfaceDrawQuad::MaterialCast(quad); |
| 2744 EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); | 2742 EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); |
| 2745 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id); | 2743 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id); |
| 2746 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), | 2744 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), |
| 2747 resource_provider->TargetForTesting( | 2745 resource_provider->TargetForTesting( |
| 2748 io_surface_draw_quad->io_surface_resource_id)); | 2746 io_surface_draw_quad->io_surface_resource_id)); |
| 2749 | 2747 |
| 2750 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1)) | |
| 2751 .Times(1); | |
| 2752 if (delegating_renderer()) { | 2748 if (delegating_renderer()) { |
| 2753 // The io surface layer's resource should be sent to the parent. | 2749 // The io surface layer's resource should be sent to the parent. |
| 2754 EXPECT_CALL(*mock_context_, | 2750 EXPECT_CALL(*mock_context_, produceTextureDirectCHROMIUM( |
| 2755 produceTextureCHROMIUM(GL_TEXTURE_RECTANGLE_ARB, _)).Times(1); | 2751 _, GL_TEXTURE_RECTANGLE_ARB, _)).Times(1); |
| 2756 } else { | 2752 } else { |
| 2757 // The io surface layer's texture is drawn. | 2753 // The io surface layer's texture is drawn. |
| 2758 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1)); | 2754 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1)); |
| 2759 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _)) | 2755 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _)) |
| 2760 .Times(AtLeast(1)); | 2756 .Times(AtLeast(1)); |
| 2761 } | 2757 } |
| 2762 | 2758 |
| 2763 return draw_result; | 2759 return draw_result; |
| 2764 } | 2760 } |
| 2765 | 2761 |
| (...skipping 3568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6334 | 6330 |
| 6335 void AfterTest() override {} | 6331 void AfterTest() override {} |
| 6336 | 6332 |
| 6337 private: | 6333 private: |
| 6338 scoped_refptr<Layer> child_; | 6334 scoped_refptr<Layer> child_; |
| 6339 }; | 6335 }; |
| 6340 | 6336 |
| 6341 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); | 6337 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
| 6342 | 6338 |
| 6343 } // namespace cc | 6339 } // namespace cc |
| OLD | NEW |