| 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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 | 1434 |
| 1435 switch (impl->active_tree()->source_frame_number()) { | 1435 switch (impl->active_tree()->source_frame_number()) { |
| 1436 case 0: | 1436 case 0: |
| 1437 // Number of textures should be one for each layer | 1437 // Number of textures should be one for each layer |
| 1438 ASSERT_EQ(2u, context->NumTextures()); | 1438 ASSERT_EQ(2u, context->NumTextures()); |
| 1439 // Number of textures used for commit should be one for each layer. | 1439 // Number of textures used for commit should be one for each layer. |
| 1440 EXPECT_EQ(2u, context->NumUsedTextures()); | 1440 EXPECT_EQ(2u, context->NumUsedTextures()); |
| 1441 // Verify that used texture is correct. | 1441 // Verify that used texture is correct. |
| 1442 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1442 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| 1443 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1443 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| 1444 context->ResetUsedTextures(); | |
| 1445 break; | 1444 break; |
| 1446 case 1: | 1445 case 1: |
| 1447 // Number of textures should be doubled as the first context layer | 1446 // Number of textures should be doubled as the first context layer |
| 1448 // texture is being used by the impl-thread and cannot be used for | 1447 // texture is being used by the impl-thread and cannot be used for |
| 1449 // update. The scrollbar behavior is different direct renderer because | 1448 // update. The scrollbar behavior is different direct renderer because |
| 1450 // UI resource deletion with delegating renderer occurs after tree | 1449 // UI resource deletion with delegating renderer occurs after tree |
| 1451 // activation. | 1450 // activation. |
| 1452 ASSERT_EQ(4u, context->NumTextures()); | 1451 ASSERT_EQ(4u, context->NumTextures()); |
| 1453 // Number of textures used for commit should still be | 1452 // Number of textures used for commit should still be |
| 1454 // one for each layer. | 1453 // one for each layer. |
| 1455 EXPECT_EQ(2u, context->NumUsedTextures()); | 1454 EXPECT_EQ(2u, context->NumUsedTextures()); |
| 1456 // First textures should not have been used. | 1455 // First textures should not have been used. |
| 1457 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | 1456 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
| 1458 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); | 1457 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
| 1459 // New textures should have been used. | 1458 // New textures should have been used. |
| 1460 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | 1459 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| 1461 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1460 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| 1462 context->ResetUsedTextures(); | |
| 1463 break; | 1461 break; |
| 1464 case 2: | 1462 case 2: |
| 1465 EndTest(); | 1463 EndTest(); |
| 1466 break; | 1464 break; |
| 1467 default: | 1465 default: |
| 1468 NOTREACHED(); | 1466 NOTREACHED(); |
| 1469 break; | 1467 break; |
| 1470 } | 1468 } |
| 1471 } | 1469 } |
| 1472 }; | 1470 }; |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target, | 2676 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target, |
| 2679 GLint width, | 2677 GLint width, |
| 2680 GLint height, | 2678 GLint height, |
| 2681 GLuint ioSurfaceId, | 2679 GLuint ioSurfaceId, |
| 2682 GLuint plane)); | 2680 GLuint plane)); |
| 2683 MOCK_METHOD4(drawElements, void(GLenum mode, | 2681 MOCK_METHOD4(drawElements, void(GLenum mode, |
| 2684 GLsizei count, | 2682 GLsizei count, |
| 2685 GLenum type, | 2683 GLenum type, |
| 2686 GLintptr offset)); | 2684 GLintptr offset)); |
| 2687 MOCK_METHOD1(deleteTexture, void(GLenum texture)); | 2685 MOCK_METHOD1(deleteTexture, void(GLenum texture)); |
| 2688 MOCK_METHOD2(produceTextureCHROMIUM, | 2686 MOCK_METHOD3(produceTextureDirectCHROMIUM, |
| 2689 void(GLenum target, const GLbyte* mailbox)); | 2687 void(GLuint texture, GLenum target, const GLbyte* mailbox)); |
| 2690 }; | 2688 }; |
| 2691 | 2689 |
| 2692 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { | 2690 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { |
| 2693 protected: | 2691 protected: |
| 2694 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 2692 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2695 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( | 2693 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( |
| 2696 new MockIOSurfaceWebGraphicsContext3D); | 2694 new MockIOSurfaceWebGraphicsContext3D); |
| 2697 mock_context_ = mock_context_owned.get(); | 2695 mock_context_ = mock_context_owned.get(); |
| 2698 | 2696 |
| 2699 if (delegating_renderer()) | 2697 if (delegating_renderer()) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); | 2767 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); |
| 2770 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); | 2768 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); |
| 2771 const IOSurfaceDrawQuad* io_surface_draw_quad = | 2769 const IOSurfaceDrawQuad* io_surface_draw_quad = |
| 2772 IOSurfaceDrawQuad::MaterialCast(quad); | 2770 IOSurfaceDrawQuad::MaterialCast(quad); |
| 2773 EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); | 2771 EXPECT_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); |
| 2774 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id); | 2772 EXPECT_NE(0u, io_surface_draw_quad->io_surface_resource_id); |
| 2775 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), | 2773 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), |
| 2776 resource_provider->TargetForTesting( | 2774 resource_provider->TargetForTesting( |
| 2777 io_surface_draw_quad->io_surface_resource_id)); | 2775 io_surface_draw_quad->io_surface_resource_id)); |
| 2778 | 2776 |
| 2779 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1)) | |
| 2780 .Times(1); | |
| 2781 if (delegating_renderer()) { | 2777 if (delegating_renderer()) { |
| 2782 // The io surface layer's resource should be sent to the parent. | 2778 // The io surface layer's resource should be sent to the parent. |
| 2783 EXPECT_CALL(*mock_context_, | 2779 EXPECT_CALL(*mock_context_, produceTextureDirectCHROMIUM( |
| 2784 produceTextureCHROMIUM(GL_TEXTURE_RECTANGLE_ARB, _)).Times(1); | 2780 _, GL_TEXTURE_RECTANGLE_ARB, _)).Times(1); |
| 2785 } else { | 2781 } else { |
| 2786 // The io surface layer's texture is drawn. | 2782 // The io surface layer's texture is drawn. |
| 2787 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1)); | 2783 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1)); |
| 2788 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _)) | 2784 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _)) |
| 2789 .Times(AtLeast(1)); | 2785 .Times(AtLeast(1)); |
| 2790 } | 2786 } |
| 2791 | 2787 |
| 2792 return draw_result; | 2788 return draw_result; |
| 2793 } | 2789 } |
| 2794 | 2790 |
| (...skipping 3274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6069 | 6065 |
| 6070 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6066 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
| 6071 | 6067 |
| 6072 private: | 6068 private: |
| 6073 bool did_commit_; | 6069 bool did_commit_; |
| 6074 }; | 6070 }; |
| 6075 | 6071 |
| 6076 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6072 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
| 6077 | 6073 |
| 6078 } // namespace cc | 6074 } // namespace cc |
| OLD | NEW |