| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 size_t num_resource_ids, | 1747 size_t num_resource_ids, |
| 1748 bool valid, | 1748 bool valid, |
| 1749 SurfaceId child_id, | 1749 SurfaceId child_id, |
| 1750 SurfaceFactory* factory, | 1750 SurfaceFactory* factory, |
| 1751 SurfaceId surface_id) { | 1751 SurfaceId surface_id) { |
| 1752 CompositorFrame frame; | 1752 CompositorFrame frame; |
| 1753 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1753 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1754 pass->id = RenderPassId(1, 1); | 1754 pass->id = RenderPassId(1, 1); |
| 1755 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1755 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 1756 sqs->opacity = 1.f; | 1756 sqs->opacity = 1.f; |
| 1757 if (!child_id.is_null()) { | 1757 if (child_id.is_valid()) { |
| 1758 SurfaceDrawQuad* surface_quad = | 1758 SurfaceDrawQuad* surface_quad = |
| 1759 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1759 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1760 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 1760 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
| 1761 child_id); | 1761 child_id); |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 for (size_t i = 0u; i < num_resource_ids; ++i) { | 1764 for (size_t i = 0u; i < num_resource_ids; ++i) { |
| 1765 TransferableResource resource; | 1765 TransferableResource resource; |
| 1766 resource.id = resource_ids[i]; | 1766 resource.id = resource_ids[i]; |
| 1767 // ResourceProvider is software, so only software resources are valid. | 1767 // ResourceProvider is software, so only software resources are valid. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1893 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 1894 factory.Destroy(local_frame1_id); | 1894 factory.Destroy(local_frame1_id); |
| 1895 factory.Destroy(local_frame2_id); | 1895 factory.Destroy(local_frame2_id); |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1898 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 1899 // resources. | 1899 // resources. |
| 1900 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1900 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 1901 ResourceTrackingSurfaceFactoryClient client; | 1901 ResourceTrackingSurfaceFactoryClient client; |
| 1902 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1902 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 1903 LocalFrameId root_local_frame_id(7u, 0); | 1903 LocalFrameId root_local_frame_id(7u, 1); |
| 1904 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); | 1904 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); |
| 1905 factory.Create(root_local_frame_id); | 1905 factory.Create(root_local_frame_id); |
| 1906 LocalFrameId middle_local_frame_id(8u, 0); | 1906 LocalFrameId middle_local_frame_id(8u, 1); |
| 1907 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); | 1907 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); |
| 1908 factory.Create(middle_local_frame_id); | 1908 factory.Create(middle_local_frame_id); |
| 1909 LocalFrameId child_local_frame_id(9u, 0); | 1909 LocalFrameId child_local_frame_id(9u, 1); |
| 1910 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); | 1910 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); |
| 1911 factory.Create(child_local_frame_id); | 1911 factory.Create(child_local_frame_id); |
| 1912 | 1912 |
| 1913 ResourceId ids[] = {14, 15, 16}; | 1913 ResourceId ids[] = {14, 15, 16}; |
| 1914 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1914 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1915 &factory, child_surface_id); | 1915 &factory, child_surface_id); |
| 1916 | 1916 |
| 1917 ResourceId ids2[] = {17, 18, 19}; | 1917 ResourceId ids2[] = {17, 18, 19}; |
| 1918 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1918 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
| 1919 child_surface_id, &factory, | 1919 child_surface_id, &factory, |
| 1920 middle_surface_id); | 1920 middle_surface_id); |
| 1921 | 1921 |
| 1922 ResourceId ids3[] = {20, 21, 22}; | 1922 ResourceId ids3[] = {20, 21, 22}; |
| 1923 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1923 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
| 1924 middle_surface_id, &factory, | 1924 middle_surface_id, &factory, |
| 1925 root_surface_id); | 1925 root_surface_id); |
| 1926 | 1926 |
| 1927 CompositorFrame frame; | 1927 CompositorFrame frame; |
| 1928 frame = aggregator_->Aggregate(root_surface_id); | 1928 frame = aggregator_->Aggregate(root_surface_id); |
| 1929 | 1929 |
| 1930 RenderPassList* pass_list = &frame.render_pass_list; | 1930 RenderPassList* pass_list = &frame.render_pass_list; |
| 1931 ASSERT_EQ(1u, pass_list->size()); | 1931 ASSERT_EQ(1u, pass_list->size()); |
| 1932 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1932 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
| 1933 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1933 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
| 1934 | |
| 1935 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1934 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
| 1936 child_surface_id, &factory, | 1935 child_surface_id, &factory, |
| 1937 middle_surface_id); | 1936 middle_surface_id); |
| 1938 | 1937 |
| 1939 frame = aggregator_->Aggregate(root_surface_id); | 1938 frame = aggregator_->Aggregate(root_surface_id); |
| 1940 | 1939 |
| 1941 pass_list = &frame.render_pass_list; | 1940 pass_list = &frame.render_pass_list; |
| 1942 ASSERT_EQ(1u, pass_list->size()); | 1941 ASSERT_EQ(1u, pass_list->size()); |
| 1943 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1942 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 1944 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1943 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 // Output is insecure, so texture should be drawn. | 2009 // Output is insecure, so texture should be drawn. |
| 2011 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2010 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2012 | 2011 |
| 2013 factory.Destroy(local_frame1_id); | 2012 factory.Destroy(local_frame1_id); |
| 2014 factory.Destroy(local_frame2_id); | 2013 factory.Destroy(local_frame2_id); |
| 2015 } | 2014 } |
| 2016 | 2015 |
| 2017 } // namespace | 2016 } // namespace |
| 2018 } // namespace cc | 2017 } // namespace cc |
| 2019 | 2018 |
| OLD | NEW |