| 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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 size_t num_resource_ids, | 1939 size_t num_resource_ids, |
| 1940 bool valid, | 1940 bool valid, |
| 1941 SurfaceId child_id, | 1941 SurfaceId child_id, |
| 1942 SurfaceFactory* factory, | 1942 SurfaceFactory* factory, |
| 1943 SurfaceId surface_id) { | 1943 SurfaceId surface_id) { |
| 1944 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 1944 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 1945 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1945 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1946 pass->id = RenderPassId(1, 1); | 1946 pass->id = RenderPassId(1, 1); |
| 1947 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1947 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 1948 sqs->opacity = 1.f; | 1948 sqs->opacity = 1.f; |
| 1949 if (!child_id.is_null()) { | 1949 if (child_id.is_valid()) { |
| 1950 printf("Inside the if block.\n"); |
| 1950 SurfaceDrawQuad* surface_quad = | 1951 SurfaceDrawQuad* surface_quad = |
| 1951 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1952 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1952 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 1953 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
| 1953 child_id); | 1954 child_id); |
| 1954 } | 1955 } |
| 1955 | 1956 |
| 1956 for (size_t i = 0u; i < num_resource_ids; ++i) { | 1957 for (size_t i = 0u; i < num_resource_ids; ++i) { |
| 1957 TransferableResource resource; | 1958 TransferableResource resource; |
| 1958 resource.id = resource_ids[i]; | 1959 resource.id = resource_ids[i]; |
| 1959 // ResourceProvider is software, so only software resources are valid. | 1960 // ResourceProvider is software, so only software resources are valid. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 EXPECT_EQ(3u, resource_provider_->num_resources()); | 2090 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 2090 factory.Destroy(local_frame1_id); | 2091 factory.Destroy(local_frame1_id); |
| 2091 factory.Destroy(local_frame2_id); | 2092 factory.Destroy(local_frame2_id); |
| 2092 } | 2093 } |
| 2093 | 2094 |
| 2094 // Ensure that aggregator completely ignores Surfaces that reference invalid | 2095 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 2095 // resources. | 2096 // resources. |
| 2096 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 2097 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 2097 ResourceTrackingSurfaceFactoryClient client; | 2098 ResourceTrackingSurfaceFactoryClient client; |
| 2098 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 2099 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 2099 LocalFrameId root_local_frame_id(7u, 0); | 2100 LocalFrameId root_local_frame_id(7u, 1); |
| 2100 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); | 2101 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); |
| 2101 factory.Create(root_local_frame_id); | 2102 factory.Create(root_local_frame_id); |
| 2102 LocalFrameId middle_local_frame_id(8u, 0); | 2103 LocalFrameId middle_local_frame_id(8u, 1); |
| 2103 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); | 2104 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); |
| 2104 factory.Create(middle_local_frame_id); | 2105 factory.Create(middle_local_frame_id); |
| 2105 LocalFrameId child_local_frame_id(9u, 0); | 2106 LocalFrameId child_local_frame_id(9u, 1); |
| 2106 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); | 2107 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); |
| 2107 factory.Create(child_local_frame_id); | 2108 factory.Create(child_local_frame_id); |
| 2108 | 2109 |
| 2109 ResourceId ids[] = {14, 15, 16}; | 2110 ResourceId ids[] = {14, 15, 16}; |
| 2110 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2111 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2111 &factory, child_surface_id); | 2112 &factory, child_surface_id); |
| 2112 | 2113 |
| 2113 ResourceId ids2[] = {17, 18, 19}; | 2114 ResourceId ids2[] = {17, 18, 19}; |
| 2114 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 2115 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
| 2115 child_surface_id, &factory, | 2116 child_surface_id, &factory, |
| 2116 middle_surface_id); | 2117 middle_surface_id); |
| 2117 | 2118 |
| 2118 ResourceId ids3[] = {20, 21, 22}; | 2119 ResourceId ids3[] = {20, 21, 22}; |
| 2119 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 2120 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
| 2120 middle_surface_id, &factory, | 2121 middle_surface_id, &factory, |
| 2121 root_surface_id); | 2122 root_surface_id); |
| 2122 | 2123 |
| 2123 CompositorFrame frame; | 2124 CompositorFrame frame; |
| 2124 frame = aggregator_->Aggregate(root_surface_id); | 2125 frame = aggregator_->Aggregate(root_surface_id); |
| 2125 | 2126 |
| 2126 RenderPassList* pass_list = &frame.delegated_frame_data->render_pass_list; | 2127 RenderPassList* pass_list = &frame.delegated_frame_data->render_pass_list; |
| 2127 ASSERT_EQ(1u, pass_list->size()); | 2128 ASSERT_EQ(1u, pass_list->size()); |
| 2128 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 2129 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
| 2129 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 2130 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
| 2130 | 2131 printf("child_surface_id.is_valid() = %d\n", child_surface_id.is_valid()); |
| 2131 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 2132 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
| 2132 child_surface_id, &factory, | 2133 child_surface_id, &factory, |
| 2133 middle_surface_id); | 2134 middle_surface_id); |
| 2134 | 2135 |
| 2135 frame = aggregator_->Aggregate(root_surface_id); | 2136 frame = aggregator_->Aggregate(root_surface_id); |
| 2136 | 2137 |
| 2137 pass_list = &frame.delegated_frame_data->render_pass_list; | 2138 pass_list = &frame.delegated_frame_data->render_pass_list; |
| 2138 ASSERT_EQ(1u, pass_list->size()); | 2139 ASSERT_EQ(1u, pass_list->size()); |
| 2139 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 2140 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 2140 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 2141 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 // Output is insecure, so texture should be drawn. | 2209 // Output is insecure, so texture should be drawn. |
| 2209 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2210 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2210 | 2211 |
| 2211 factory.Destroy(local_frame1_id); | 2212 factory.Destroy(local_frame1_id); |
| 2212 factory.Destroy(local_frame2_id); | 2213 factory.Destroy(local_frame2_id); |
| 2213 } | 2214 } |
| 2214 | 2215 |
| 2215 } // namespace | 2216 } // namespace |
| 2216 } // namespace cc | 2217 } // namespace cc |
| 2217 | 2218 |
| OLD | NEW |