| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/surfaces/surface.h" | 8 #include "cc/surfaces/surface.h" |
| 9 #include "cc/surfaces/surface_factory.h" | 9 #include "cc/surfaces/surface_factory.h" |
| 10 #include "cc/surfaces/surface_factory_client.h" | 10 #include "cc/surfaces/surface_factory_client.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 EmptySurfaceFactoryClient client; | 65 EmptySurfaceFactoryClient client; |
| 66 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); | 66 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
| 67 SurfaceFactory root_factory(root_frame_sink_id, &manager, &client); | 67 SurfaceFactory root_factory(root_frame_sink_id, &manager, &client); |
| 68 | 68 |
| 69 // Creates a root surface. | 69 // Creates a root surface. |
| 70 gfx::Rect root_rect(300, 300); | 70 gfx::Rect root_rect(300, 300); |
| 71 RenderPass* root_pass = nullptr; | 71 RenderPass* root_pass = nullptr; |
| 72 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 72 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 73 | 73 |
| 74 // Add a reference to a non-existant child surface on the root surface. | 74 // Add a reference to a non-existant child surface on the root surface. |
| 75 SurfaceId child_surface_id(kArbitraryFrameSinkId, 0xdeadbeef, 0); | 75 SurfaceId child_surface_id(kArbitraryFrameSinkId, |
| 76 LocalFrameId(0xdeadbeef, 0)); |
| 76 gfx::Rect child_rect(200, 200); | 77 gfx::Rect child_rect(200, 200); |
| 77 CreateSurfaceDrawQuad(root_pass, | 78 CreateSurfaceDrawQuad(root_pass, |
| 78 gfx::Transform(), | 79 gfx::Transform(), |
| 79 root_rect, | 80 root_rect, |
| 80 child_rect, | 81 child_rect, |
| 81 child_surface_id); | 82 child_surface_id); |
| 82 | 83 |
| 83 // Submit the root frame. | 84 // Submit the root frame. |
| 84 SurfaceIdAllocator root_allocator(root_frame_sink_id); | 85 SurfaceIdAllocator root_allocator; |
| 85 SurfaceId root_surface_id = root_allocator.GenerateId(); | 86 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 86 root_factory.Create(root_surface_id); | 87 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 87 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 88 root_factory.Create(root_local_frame_id); |
| 89 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 88 SurfaceFactory::DrawCallback()); | 90 SurfaceFactory::DrawCallback()); |
| 89 | 91 |
| 90 { | 92 { |
| 91 SurfaceHittest hittest(nullptr, &manager); | 93 SurfaceHittest hittest(nullptr, &manager); |
| 92 // It is expected this test will complete without crashes. | 94 // It is expected this test will complete without crashes. |
| 93 gfx::Transform transform; | 95 gfx::Transform transform; |
| 94 EXPECT_EQ(root_surface_id, | 96 EXPECT_EQ(root_surface_id, |
| 95 hittest.GetTargetSurfaceAtPoint( | 97 hittest.GetTargetSurfaceAtPoint( |
| 96 root_surface_id, gfx::Point(100, 100), &transform)); | 98 root_surface_id, gfx::Point(100, 100), &transform)); |
| 97 } | 99 } |
| 98 | 100 |
| 99 root_factory.Destroy(root_surface_id); | 101 root_factory.Destroy(root_local_frame_id); |
| 100 } | 102 } |
| 101 | 103 |
| 102 TEST(SurfaceHittestTest, Hittest_SingleSurface) { | 104 TEST(SurfaceHittestTest, Hittest_SingleSurface) { |
| 103 SurfaceManager manager; | 105 SurfaceManager manager; |
| 104 | 106 |
| 105 // Set up root FrameSink. | 107 // Set up root FrameSink. |
| 106 EmptySurfaceFactoryClient root_client; | 108 EmptySurfaceFactoryClient root_client; |
| 107 FrameSinkId root_frame_sink_id(1, 1); | 109 FrameSinkId root_frame_sink_id(1, 1); |
| 108 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 110 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 109 | 111 |
| 110 // Creates a root surface. | 112 // Creates a root surface. |
| 111 gfx::Rect root_rect(300, 300); | 113 gfx::Rect root_rect(300, 300); |
| 112 RenderPass* root_pass = nullptr; | 114 RenderPass* root_pass = nullptr; |
| 113 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 115 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 114 | 116 |
| 115 // Submit the root frame. | 117 // Submit the root frame. |
| 116 SurfaceIdAllocator root_allocator(root_frame_sink_id); | 118 SurfaceIdAllocator root_allocator; |
| 117 SurfaceId root_surface_id = root_allocator.GenerateId(); | 119 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 118 root_factory.Create(root_surface_id); | 120 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 119 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 121 root_factory.Create(root_local_frame_id); |
| 122 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 120 SurfaceFactory::DrawCallback()); | 123 SurfaceFactory::DrawCallback()); |
| 121 TestCase tests[] = { | 124 TestCase tests[] = { |
| 122 { | 125 { |
| 123 root_surface_id, | 126 root_surface_id, |
| 124 gfx::Point(100, 100), | 127 gfx::Point(100, 100), |
| 125 root_surface_id, | 128 root_surface_id, |
| 126 gfx::Point(100, 100) | 129 gfx::Point(100, 100) |
| 127 }, | 130 }, |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 RunTests(nullptr, &manager, tests, arraysize(tests)); | 133 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 131 | 134 |
| 132 root_factory.Destroy(root_surface_id); | 135 root_factory.Destroy(root_local_frame_id); |
| 133 } | 136 } |
| 134 | 137 |
| 135 TEST(SurfaceHittestTest, Hittest_ChildSurface) { | 138 TEST(SurfaceHittestTest, Hittest_ChildSurface) { |
| 136 SurfaceManager manager; | 139 SurfaceManager manager; |
| 137 | 140 |
| 138 // Set up root FrameSink. | 141 // Set up root FrameSink. |
| 139 EmptySurfaceFactoryClient root_client; | 142 EmptySurfaceFactoryClient root_client; |
| 140 FrameSinkId root_frame_sink_id(1, 1); | 143 FrameSinkId root_frame_sink_id(1, 1); |
| 141 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 144 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 142 | 145 |
| 143 // Set up child FrameSink. | 146 // Set up child FrameSink. |
| 144 EmptySurfaceFactoryClient child_client; | 147 EmptySurfaceFactoryClient child_client; |
| 145 FrameSinkId child_frame_sink_id(2, 2); | 148 FrameSinkId child_frame_sink_id(2, 2); |
| 146 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); | 149 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); |
| 147 | 150 |
| 148 // Creates a root surface. | 151 // Creates a root surface. |
| 149 gfx::Rect root_rect(300, 300); | 152 gfx::Rect root_rect(300, 300); |
| 150 RenderPass* root_pass = nullptr; | 153 RenderPass* root_pass = nullptr; |
| 151 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 154 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 152 | 155 |
| 153 // Add a reference to the child surface on the root surface. | 156 // Add a reference to the child surface on the root surface. |
| 154 SurfaceIdAllocator child_allocator(child_frame_sink_id); | 157 SurfaceIdAllocator child_allocator; |
| 155 SurfaceId child_surface_id = child_allocator.GenerateId(); | 158 LocalFrameId child_local_frame_id = child_allocator.GenerateId(); |
| 159 SurfaceId child_surface_id(child_frame_sink_id, child_local_frame_id); |
| 156 gfx::Rect child_rect(200, 200); | 160 gfx::Rect child_rect(200, 200); |
| 157 CreateSurfaceDrawQuad(root_pass, | 161 CreateSurfaceDrawQuad(root_pass, |
| 158 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 162 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 159 0.0f, 1.0f, 0.0f, 50.0f, | 163 0.0f, 1.0f, 0.0f, 50.0f, |
| 160 0.0f, 0.0f, 1.0f, 0.0f, | 164 0.0f, 0.0f, 1.0f, 0.0f, |
| 161 0.0f, 0.0f, 0.0f, 1.0f), | 165 0.0f, 0.0f, 0.0f, 1.0f), |
| 162 root_rect, | 166 root_rect, |
| 163 child_rect, | 167 child_rect, |
| 164 child_surface_id); | 168 child_surface_id); |
| 165 | 169 |
| 166 // Submit the root frame. | 170 // Submit the root frame. |
| 167 SurfaceIdAllocator root_allocator(root_frame_sink_id); | 171 SurfaceIdAllocator root_allocator; |
| 168 SurfaceId root_surface_id = root_allocator.GenerateId(); | 172 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 169 root_factory.Create(root_surface_id); | 173 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 170 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 174 root_factory.Create(root_local_frame_id); |
| 175 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 171 SurfaceFactory::DrawCallback()); | 176 SurfaceFactory::DrawCallback()); |
| 172 | 177 |
| 173 // Creates a child surface. | 178 // Creates a child surface. |
| 174 RenderPass* child_pass = nullptr; | 179 RenderPass* child_pass = nullptr; |
| 175 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 180 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 176 | 181 |
| 177 // Add a solid quad in the child surface. | 182 // Add a solid quad in the child surface. |
| 178 gfx::Rect child_solid_quad_rect(100, 100); | 183 gfx::Rect child_solid_quad_rect(100, 100); |
| 179 CreateSolidColorDrawQuad( | 184 CreateSolidColorDrawQuad( |
| 180 child_pass, | 185 child_pass, |
| 181 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 186 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 182 0.0f, 1.0f, 0.0f, 50.0f, | 187 0.0f, 1.0f, 0.0f, 50.0f, |
| 183 0.0f, 0.0f, 1.0f, 0.0f, | 188 0.0f, 0.0f, 1.0f, 0.0f, |
| 184 0.0f, 0.0f, 0.0f, 1.0f), | 189 0.0f, 0.0f, 0.0f, 1.0f), |
| 185 root_rect, child_solid_quad_rect); | 190 root_rect, child_solid_quad_rect); |
| 186 | 191 |
| 187 // Submit the frame. | 192 // Submit the frame. |
| 188 child_factory.Create(child_surface_id); | 193 child_factory.Create(child_local_frame_id); |
| 189 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 194 child_factory.SubmitCompositorFrame(child_local_frame_id, |
| 195 std::move(child_frame), |
| 190 SurfaceFactory::DrawCallback()); | 196 SurfaceFactory::DrawCallback()); |
| 191 | 197 |
| 192 TestCase tests[] = { | 198 TestCase tests[] = { |
| 193 { | 199 { |
| 194 root_surface_id, | 200 root_surface_id, |
| 195 gfx::Point(10, 10), | 201 gfx::Point(10, 10), |
| 196 root_surface_id, | 202 root_surface_id, |
| 197 gfx::Point(10, 10) | 203 gfx::Point(10, 10) |
| 198 }, | 204 }, |
| 199 { | 205 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Submit another root frame, with a slightly perturbed child Surface. | 239 // Submit another root frame, with a slightly perturbed child Surface. |
| 234 root_frame = CreateCompositorFrame(root_rect, &root_pass); | 240 root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 235 CreateSurfaceDrawQuad(root_pass, | 241 CreateSurfaceDrawQuad(root_pass, |
| 236 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, | 242 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, |
| 237 0.0f, 1.0f, 0.0f, 75.0f, | 243 0.0f, 1.0f, 0.0f, 75.0f, |
| 238 0.0f, 0.0f, 1.0f, 0.0f, | 244 0.0f, 0.0f, 1.0f, 0.0f, |
| 239 0.0f, 0.0f, 0.0f, 1.0f), | 245 0.0f, 0.0f, 0.0f, 1.0f), |
| 240 root_rect, | 246 root_rect, |
| 241 child_rect, | 247 child_rect, |
| 242 child_surface_id); | 248 child_surface_id); |
| 243 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 249 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 244 SurfaceFactory::DrawCallback()); | 250 SurfaceFactory::DrawCallback()); |
| 245 | 251 |
| 246 // Verify that point (100, 100) no longer falls on the child surface. | 252 // Verify that point (100, 100) no longer falls on the child surface. |
| 247 // Verify that the transform to the child surface's space has also shifted. | 253 // Verify that the transform to the child surface's space has also shifted. |
| 248 { | 254 { |
| 249 SurfaceHittest hittest(nullptr, &manager); | 255 SurfaceHittest hittest(nullptr, &manager); |
| 250 | 256 |
| 251 gfx::Point point(100, 100); | 257 gfx::Point point(100, 100); |
| 252 gfx::Transform transform; | 258 gfx::Transform transform; |
| 253 EXPECT_EQ(root_surface_id, | 259 EXPECT_EQ(root_surface_id, |
| 254 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, | 260 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, |
| 255 &transform)); | 261 &transform)); |
| 256 transform.TransformPoint(&point); | 262 transform.TransformPoint(&point); |
| 257 EXPECT_EQ(gfx::Point(100, 100), point); | 263 EXPECT_EQ(gfx::Point(100, 100), point); |
| 258 | 264 |
| 259 gfx::Point point_in_target_space(100, 100); | 265 gfx::Point point_in_target_space(100, 100); |
| 260 gfx::Transform target_transform; | 266 gfx::Transform target_transform; |
| 261 EXPECT_TRUE(hittest.GetTransformToTargetSurface( | 267 EXPECT_TRUE(hittest.GetTransformToTargetSurface( |
| 262 root_surface_id, child_surface_id, &target_transform)); | 268 root_surface_id, child_surface_id, &target_transform)); |
| 263 target_transform.TransformPoint(&point_in_target_space); | 269 target_transform.TransformPoint(&point_in_target_space); |
| 264 EXPECT_NE(transform, target_transform); | 270 EXPECT_NE(transform, target_transform); |
| 265 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); | 271 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); |
| 266 } | 272 } |
| 267 | 273 |
| 268 root_factory.Destroy(root_surface_id); | 274 root_factory.Destroy(root_local_frame_id); |
| 269 child_factory.Destroy(child_surface_id); | 275 child_factory.Destroy(child_local_frame_id); |
| 270 } | 276 } |
| 271 | 277 |
| 272 // This test verifies that hit testing will progress to the next quad if it | 278 // This test verifies that hit testing will progress to the next quad if it |
| 273 // encounters an invalid RenderPassDrawQuad for whatever reason. | 279 // encounters an invalid RenderPassDrawQuad for whatever reason. |
| 274 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { | 280 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { |
| 275 SurfaceManager manager; | 281 SurfaceManager manager; |
| 276 | 282 |
| 277 // Set up root FrameSink. | 283 // Set up root FrameSink. |
| 278 EmptySurfaceFactoryClient root_client; | 284 EmptySurfaceFactoryClient root_client; |
| 279 FrameSinkId root_frame_sink_id(1, 1); | 285 FrameSinkId root_frame_sink_id(1, 1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 290 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 296 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 291 | 297 |
| 292 // Create a RenderPassDrawQuad to a non-existant RenderPass. | 298 // Create a RenderPassDrawQuad to a non-existant RenderPass. |
| 293 CreateRenderPassDrawQuad(root_pass, | 299 CreateRenderPassDrawQuad(root_pass, |
| 294 gfx::Transform(), | 300 gfx::Transform(), |
| 295 root_rect, | 301 root_rect, |
| 296 root_rect, | 302 root_rect, |
| 297 RenderPassId(1337, 1337)); | 303 RenderPassId(1337, 1337)); |
| 298 | 304 |
| 299 // Add a reference to the child surface on the root surface. | 305 // Add a reference to the child surface on the root surface. |
| 300 SurfaceIdAllocator child_allocator(child_frame_sink_id); | 306 SurfaceIdAllocator child_allocator; |
| 301 SurfaceId child_surface_id = child_allocator.GenerateId(); | 307 LocalFrameId child_local_frame_id = child_allocator.GenerateId(); |
| 308 SurfaceId child_surface_id(child_frame_sink_id, child_local_frame_id); |
| 302 gfx::Rect child_rect(200, 200); | 309 gfx::Rect child_rect(200, 200); |
| 303 CreateSurfaceDrawQuad(root_pass, | 310 CreateSurfaceDrawQuad(root_pass, |
| 304 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 311 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 305 0.0f, 1.0f, 0.0f, 50.0f, | 312 0.0f, 1.0f, 0.0f, 50.0f, |
| 306 0.0f, 0.0f, 1.0f, 0.0f, | 313 0.0f, 0.0f, 1.0f, 0.0f, |
| 307 0.0f, 0.0f, 0.0f, 1.0f), | 314 0.0f, 0.0f, 0.0f, 1.0f), |
| 308 root_rect, | 315 root_rect, |
| 309 child_rect, | 316 child_rect, |
| 310 child_surface_id); | 317 child_surface_id); |
| 311 | 318 |
| 312 // Submit the root frame. | 319 // Submit the root frame. |
| 313 SurfaceIdAllocator root_allocator(root_frame_sink_id); | 320 SurfaceIdAllocator root_allocator; |
| 314 SurfaceId root_surface_id = root_allocator.GenerateId(); | 321 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 315 root_factory.Create(root_surface_id); | 322 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 316 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 323 root_factory.Create(root_local_frame_id); |
| 324 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 317 SurfaceFactory::DrawCallback()); | 325 SurfaceFactory::DrawCallback()); |
| 318 | 326 |
| 319 // Creates a child surface. | 327 // Creates a child surface. |
| 320 RenderPass* child_pass = nullptr; | 328 RenderPass* child_pass = nullptr; |
| 321 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 329 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 322 | 330 |
| 323 // Add a solid quad in the child surface. | 331 // Add a solid quad in the child surface. |
| 324 gfx::Rect child_solid_quad_rect(100, 100); | 332 gfx::Rect child_solid_quad_rect(100, 100); |
| 325 CreateSolidColorDrawQuad(child_pass, | 333 CreateSolidColorDrawQuad(child_pass, |
| 326 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 334 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 327 0.0f, 1.0f, 0.0f, 50.0f, | 335 0.0f, 1.0f, 0.0f, 50.0f, |
| 328 0.0f, 0.0f, 1.0f, 0.0f, | 336 0.0f, 0.0f, 1.0f, 0.0f, |
| 329 0.0f, 0.0f, 0.0f, 1.0f), | 337 0.0f, 0.0f, 0.0f, 1.0f), |
| 330 root_rect, | 338 root_rect, |
| 331 child_solid_quad_rect); | 339 child_solid_quad_rect); |
| 332 | 340 |
| 333 // Submit the frame. | 341 // Submit the frame. |
| 334 child_factory.Create(child_surface_id); | 342 child_factory.Create(child_local_frame_id); |
| 335 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 343 child_factory.SubmitCompositorFrame(child_local_frame_id, |
| 344 std::move(child_frame), |
| 336 SurfaceFactory::DrawCallback()); | 345 SurfaceFactory::DrawCallback()); |
| 337 | 346 |
| 338 TestCase tests[] = { | 347 TestCase tests[] = { |
| 339 { | 348 { |
| 340 root_surface_id, | 349 root_surface_id, |
| 341 gfx::Point(10, 10), | 350 gfx::Point(10, 10), |
| 342 root_surface_id, | 351 root_surface_id, |
| 343 gfx::Point(10, 10) | 352 gfx::Point(10, 10) |
| 344 }, | 353 }, |
| 345 { | 354 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 369 { | 378 { |
| 370 root_surface_id, | 379 root_surface_id, |
| 371 gfx::Point(290, 290), | 380 gfx::Point(290, 290), |
| 372 root_surface_id, | 381 root_surface_id, |
| 373 gfx::Point(290, 290) | 382 gfx::Point(290, 290) |
| 374 } | 383 } |
| 375 }; | 384 }; |
| 376 | 385 |
| 377 RunTests(nullptr, &manager, tests, arraysize(tests)); | 386 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 378 | 387 |
| 379 root_factory.Destroy(root_surface_id); | 388 root_factory.Destroy(root_local_frame_id); |
| 380 child_factory.Destroy(child_surface_id); | 389 child_factory.Destroy(child_local_frame_id); |
| 381 } | 390 } |
| 382 | 391 |
| 383 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { | 392 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { |
| 384 SurfaceManager manager; | 393 SurfaceManager manager; |
| 385 EmptySurfaceFactoryClient client; | 394 EmptySurfaceFactoryClient client; |
| 386 SurfaceFactory factory(kArbitraryFrameSinkId, &manager, &client); | 395 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
| 396 SurfaceFactory factory(root_frame_sink_id, &manager, &client); |
| 387 | 397 |
| 388 // Create a CompostiorFrame with two RenderPasses. | 398 // Create a CompostiorFrame with two RenderPasses. |
| 389 gfx::Rect root_rect(300, 300); | 399 gfx::Rect root_rect(300, 300); |
| 390 RenderPassList render_pass_list; | 400 RenderPassList render_pass_list; |
| 391 | 401 |
| 392 // Create a child RenderPass. | 402 // Create a child RenderPass. |
| 393 RenderPassId child_render_pass_id(1, 3); | 403 RenderPassId child_render_pass_id(1, 3); |
| 394 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, | 404 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, |
| 395 0.0f, 1.0f, 0.0f, 50.0f, | 405 0.0f, 1.0f, 0.0f, 50.0f, |
| 396 0.0f, 0.0f, 1.0f, 0.0f, | 406 0.0f, 0.0f, 1.0f, 0.0f, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 421 // Add a solid quad in the child render pass. | 431 // Add a solid quad in the child render pass. |
| 422 RenderPass* child_render_pass = | 432 RenderPass* child_render_pass = |
| 423 root_frame.delegated_frame_data->render_pass_list.front().get(); | 433 root_frame.delegated_frame_data->render_pass_list.front().get(); |
| 424 gfx::Rect child_solid_quad_rect(100, 100); | 434 gfx::Rect child_solid_quad_rect(100, 100); |
| 425 CreateSolidColorDrawQuad(child_render_pass, | 435 CreateSolidColorDrawQuad(child_render_pass, |
| 426 gfx::Transform(), | 436 gfx::Transform(), |
| 427 gfx::Rect(100, 100), | 437 gfx::Rect(100, 100), |
| 428 child_solid_quad_rect); | 438 child_solid_quad_rect); |
| 429 | 439 |
| 430 // Submit the root frame. | 440 // Submit the root frame. |
| 431 SurfaceIdAllocator root_allocator(FrameSinkId(1, 1)); | 441 SurfaceIdAllocator root_allocator; |
| 432 SurfaceId root_surface_id = root_allocator.GenerateId(); | 442 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 433 factory.Create(root_surface_id); | 443 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 434 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 444 factory.Create(root_local_frame_id); |
| 445 factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 435 SurfaceFactory::DrawCallback()); | 446 SurfaceFactory::DrawCallback()); |
| 436 | 447 |
| 437 TestCase tests[] = { | 448 TestCase tests[] = { |
| 438 // These tests just miss the RenderPassDrawQuad. | 449 // These tests just miss the RenderPassDrawQuad. |
| 439 { | 450 { |
| 440 root_surface_id, | 451 root_surface_id, |
| 441 gfx::Point(49, 49), | 452 gfx::Point(49, 49), |
| 442 root_surface_id, | 453 root_surface_id, |
| 443 gfx::Point(49, 49) | 454 gfx::Point(49, 49) |
| 444 }, | 455 }, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 473 { | 484 { |
| 474 root_surface_id, | 485 root_surface_id, |
| 475 gfx::Point(100, 100), | 486 gfx::Point(100, 100), |
| 476 root_surface_id, | 487 root_surface_id, |
| 477 gfx::Point(100, 100) | 488 gfx::Point(100, 100) |
| 478 } | 489 } |
| 479 }; | 490 }; |
| 480 | 491 |
| 481 RunTests(nullptr, &manager, tests, arraysize(tests)); | 492 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 482 | 493 |
| 483 factory.Destroy(root_surface_id); | 494 factory.Destroy(root_local_frame_id); |
| 484 } | 495 } |
| 485 | 496 |
| 486 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { | 497 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { |
| 487 SurfaceManager manager; | 498 SurfaceManager manager; |
| 488 | 499 |
| 489 // Set up root FrameSink. | 500 // Set up root FrameSink. |
| 490 EmptySurfaceFactoryClient root_client; | 501 EmptySurfaceFactoryClient root_client; |
| 491 FrameSinkId root_frame_sink_id(1, 1); | 502 FrameSinkId root_frame_sink_id(1, 1); |
| 492 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 503 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 493 | 504 |
| 494 // Set up child FrameSink. | 505 // Set up child FrameSink. |
| 495 EmptySurfaceFactoryClient child_client; | 506 EmptySurfaceFactoryClient child_client; |
| 496 FrameSinkId child_frame_sink_id(2, 2); | 507 FrameSinkId child_frame_sink_id(2, 2); |
| 497 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); | 508 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); |
| 498 | 509 |
| 499 // Creates a root surface. | 510 // Creates a root surface. |
| 500 gfx::Rect root_rect(300, 300); | 511 gfx::Rect root_rect(300, 300); |
| 501 RenderPass* root_pass = nullptr; | 512 RenderPass* root_pass = nullptr; |
| 502 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 513 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 503 | 514 |
| 504 // Add a reference to the child surface on the root surface. | 515 // Add a reference to the child surface on the root surface. |
| 505 SurfaceIdAllocator child_allocator(child_frame_sink_id); | 516 SurfaceIdAllocator child_allocator; |
| 506 SurfaceId child_surface_id = child_allocator.GenerateId(); | 517 LocalFrameId child_local_frame_id = child_allocator.GenerateId(); |
| 518 SurfaceId child_surface_id(child_frame_sink_id, child_local_frame_id); |
| 507 gfx::Rect child_rect(200, 200); | 519 gfx::Rect child_rect(200, 200); |
| 508 CreateSurfaceDrawQuad( | 520 CreateSurfaceDrawQuad( |
| 509 root_pass, | 521 root_pass, |
| 510 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 522 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 511 0.0f, 1.0f, 0.0f, 50.0f, | 523 0.0f, 1.0f, 0.0f, 50.0f, |
| 512 0.0f, 0.0f, 1.0f, 0.0f, | 524 0.0f, 0.0f, 1.0f, 0.0f, |
| 513 0.0f, 0.0f, 0.0f, 1.0f), | 525 0.0f, 0.0f, 0.0f, 1.0f), |
| 514 root_rect, child_rect, child_surface_id); | 526 root_rect, child_rect, child_surface_id); |
| 515 | 527 |
| 516 // Submit the root frame. | 528 // Submit the root frame. |
| 517 SurfaceIdAllocator root_allocator(root_frame_sink_id); | 529 SurfaceIdAllocator root_allocator; |
| 518 SurfaceId root_surface_id = root_allocator.GenerateId(); | 530 LocalFrameId root_local_frame_id = root_allocator.GenerateId(); |
| 519 root_factory.Create(root_surface_id); | 531 SurfaceId root_surface_id(root_frame_sink_id, root_local_frame_id); |
| 520 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 532 root_factory.Create(root_local_frame_id); |
| 533 root_factory.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 521 SurfaceFactory::DrawCallback()); | 534 SurfaceFactory::DrawCallback()); |
| 522 | 535 |
| 523 // Creates a child surface. | 536 // Creates a child surface. |
| 524 RenderPass* child_pass = nullptr; | 537 RenderPass* child_pass = nullptr; |
| 525 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 538 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 526 | 539 |
| 527 // Add a solid quad in the child surface. | 540 // Add a solid quad in the child surface. |
| 528 gfx::Rect child_solid_quad_rect(190, 190); | 541 gfx::Rect child_solid_quad_rect(190, 190); |
| 529 CreateSolidColorDrawQuad( | 542 CreateSolidColorDrawQuad( |
| 530 child_pass, | 543 child_pass, |
| 531 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, | 544 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, |
| 532 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), | 545 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), |
| 533 root_rect, child_solid_quad_rect); | 546 root_rect, child_solid_quad_rect); |
| 534 | 547 |
| 535 // Submit the frame. | 548 // Submit the frame. |
| 536 child_factory.Create(child_surface_id); | 549 child_factory.Create(child_local_frame_id); |
| 537 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 550 child_factory.SubmitCompositorFrame(child_local_frame_id, |
| 551 std::move(child_frame), |
| 538 SurfaceFactory::DrawCallback()); | 552 SurfaceFactory::DrawCallback()); |
| 539 | 553 |
| 540 TestCase test_expectations_without_insets[] = { | 554 TestCase test_expectations_without_insets[] = { |
| 541 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, | 555 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, |
| 542 {root_surface_id, gfx::Point(60, 60), child_surface_id, | 556 {root_surface_id, gfx::Point(60, 60), child_surface_id, |
| 543 gfx::Point(10, 10)}, | 557 gfx::Point(10, 10)}, |
| 544 {root_surface_id, gfx::Point(239, 239), child_surface_id, | 558 {root_surface_id, gfx::Point(239, 239), child_surface_id, |
| 545 gfx::Point(189, 189)}, | 559 gfx::Point(189, 189)}, |
| 546 {root_surface_id, gfx::Point(244, 244), child_surface_id, | 560 {root_surface_id, gfx::Point(244, 244), child_surface_id, |
| 547 gfx::Point(194, 194)}, | 561 gfx::Point(194, 194)}, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 TestSurfaceHittestDelegate accept_delegate; | 621 TestSurfaceHittestDelegate accept_delegate; |
| 608 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, | 622 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, |
| 609 gfx::Insets(5, 5, 5, 5)); | 623 gfx::Insets(5, 5, 5, 5)); |
| 610 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, | 624 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, |
| 611 arraysize(test_expectations_with_accept_insets)); | 625 arraysize(test_expectations_with_accept_insets)); |
| 612 | 626 |
| 613 // Verify that insets have affected hit targeting. | 627 // Verify that insets have affected hit targeting. |
| 614 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 628 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
| 615 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 629 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
| 616 | 630 |
| 617 root_factory.Destroy(root_surface_id); | 631 root_factory.Destroy(root_local_frame_id); |
| 618 child_factory.Destroy(child_surface_id); | 632 child_factory.Destroy(child_local_frame_id); |
| 619 } | 633 } |
| 620 | 634 |
| 621 } // namespace cc | 635 } // namespace cc |
| OLD | NEW |