| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // This test verifies that hit testing on a surface that does not exist does | 59 // This test verifies that hit testing on a surface that does not exist does |
| 60 // not crash. | 60 // not crash. |
| 61 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { | 61 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { |
| 62 SurfaceManager manager; | 62 SurfaceManager manager; |
| 63 EmptySurfaceFactoryClient client; | 63 EmptySurfaceFactoryClient client; |
| 64 SurfaceFactory factory(&manager, &client); | 64 SurfaceFactory factory(&manager, &client); |
| 65 | 65 |
| 66 // Creates a root surface. | 66 // Creates a root surface. |
| 67 gfx::Rect root_rect(300, 300); | 67 gfx::Rect root_rect(300, 300); |
| 68 RenderPass* root_pass = nullptr; | 68 RenderPass* root_pass = nullptr; |
| 69 std::unique_ptr<CompositorFrame> root_frame = | 69 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 70 CreateCompositorFrame(root_rect, &root_pass); | |
| 71 | 70 |
| 72 // Add a reference to a non-existant child surface on the root surface. | 71 // Add a reference to a non-existant child surface on the root surface. |
| 73 SurfaceId child_surface_id(3, 0xdeadbeef, 0); | 72 SurfaceId child_surface_id(3, 0xdeadbeef, 0); |
| 74 gfx::Rect child_rect(200, 200); | 73 gfx::Rect child_rect(200, 200); |
| 75 CreateSurfaceDrawQuad(root_pass, | 74 CreateSurfaceDrawQuad(root_pass, |
| 76 gfx::Transform(), | 75 gfx::Transform(), |
| 77 root_rect, | 76 root_rect, |
| 78 child_rect, | 77 child_rect, |
| 79 child_surface_id); | 78 child_surface_id); |
| 80 | 79 |
| 81 // Submit the root frame. | 80 // Submit the root frame. |
| 82 SurfaceIdAllocator root_allocator(2); | 81 SurfaceIdAllocator root_allocator(2); |
| 83 SurfaceId root_surface_id = root_allocator.GenerateId(); | 82 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 84 factory.Create(root_surface_id); | 83 factory.Create(root_surface_id); |
| 85 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 84 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 85 *root_frame_copy = std::move(root_frame); |
| 86 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 86 SurfaceFactory::DrawCallback()); | 87 SurfaceFactory::DrawCallback()); |
| 87 | 88 |
| 88 { | 89 { |
| 89 SurfaceHittest hittest(nullptr, &manager); | 90 SurfaceHittest hittest(nullptr, &manager); |
| 90 // It is expected this test will complete without crashes. | 91 // It is expected this test will complete without crashes. |
| 91 gfx::Transform transform; | 92 gfx::Transform transform; |
| 92 EXPECT_EQ(root_surface_id, | 93 EXPECT_EQ(root_surface_id, |
| 93 hittest.GetTargetSurfaceAtPoint( | 94 hittest.GetTargetSurfaceAtPoint( |
| 94 root_surface_id, gfx::Point(100, 100), &transform)); | 95 root_surface_id, gfx::Point(100, 100), &transform)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 factory.Destroy(root_surface_id); | 98 factory.Destroy(root_surface_id); |
| 98 } | 99 } |
| 99 | 100 |
| 100 TEST(SurfaceHittestTest, Hittest_SingleSurface) { | 101 TEST(SurfaceHittestTest, Hittest_SingleSurface) { |
| 101 SurfaceManager manager; | 102 SurfaceManager manager; |
| 102 EmptySurfaceFactoryClient client; | 103 EmptySurfaceFactoryClient client; |
| 103 SurfaceFactory factory(&manager, &client); | 104 SurfaceFactory factory(&manager, &client); |
| 104 | 105 |
| 105 // Creates a root surface. | 106 // Creates a root surface. |
| 106 gfx::Rect root_rect(300, 300); | 107 gfx::Rect root_rect(300, 300); |
| 107 RenderPass* root_pass = nullptr; | 108 RenderPass* root_pass = nullptr; |
| 108 std::unique_ptr<CompositorFrame> root_frame = | 109 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 109 CreateCompositorFrame(root_rect, &root_pass); | |
| 110 | 110 |
| 111 // Submit the root frame. | 111 // Submit the root frame. |
| 112 SurfaceIdAllocator root_allocator(2); | 112 SurfaceIdAllocator root_allocator(2); |
| 113 SurfaceId root_surface_id = root_allocator.GenerateId(); | 113 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 114 factory.Create(root_surface_id); | 114 factory.Create(root_surface_id); |
| 115 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 115 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 116 *root_frame_copy = std::move(root_frame); |
| 117 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 116 SurfaceFactory::DrawCallback()); | 118 SurfaceFactory::DrawCallback()); |
| 117 TestCase tests[] = { | 119 TestCase tests[] = { |
| 118 { | 120 { |
| 119 root_surface_id, | 121 root_surface_id, |
| 120 gfx::Point(100, 100), | 122 gfx::Point(100, 100), |
| 121 root_surface_id, | 123 root_surface_id, |
| 122 gfx::Point(100, 100) | 124 gfx::Point(100, 100) |
| 123 }, | 125 }, |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 RunTests(nullptr, &manager, tests, arraysize(tests)); | 128 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 127 | 129 |
| 128 factory.Destroy(root_surface_id); | 130 factory.Destroy(root_surface_id); |
| 129 } | 131 } |
| 130 | 132 |
| 131 TEST(SurfaceHittestTest, Hittest_ChildSurface) { | 133 TEST(SurfaceHittestTest, Hittest_ChildSurface) { |
| 132 SurfaceManager manager; | 134 SurfaceManager manager; |
| 133 EmptySurfaceFactoryClient client; | 135 EmptySurfaceFactoryClient client; |
| 134 SurfaceFactory factory(&manager, &client); | 136 SurfaceFactory factory(&manager, &client); |
| 135 | 137 |
| 136 // Creates a root surface. | 138 // Creates a root surface. |
| 137 gfx::Rect root_rect(300, 300); | 139 gfx::Rect root_rect(300, 300); |
| 138 RenderPass* root_pass = nullptr; | 140 RenderPass* root_pass = nullptr; |
| 139 std::unique_ptr<CompositorFrame> root_frame = | 141 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 140 CreateCompositorFrame(root_rect, &root_pass); | |
| 141 | 142 |
| 142 // Add a reference to the child surface on the root surface. | 143 // Add a reference to the child surface on the root surface. |
| 143 SurfaceIdAllocator child_allocator(3); | 144 SurfaceIdAllocator child_allocator(3); |
| 144 SurfaceId child_surface_id = child_allocator.GenerateId(); | 145 SurfaceId child_surface_id = child_allocator.GenerateId(); |
| 145 gfx::Rect child_rect(200, 200); | 146 gfx::Rect child_rect(200, 200); |
| 146 CreateSurfaceDrawQuad(root_pass, | 147 CreateSurfaceDrawQuad(root_pass, |
| 147 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 148 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 148 0.0f, 1.0f, 0.0f, 50.0f, | 149 0.0f, 1.0f, 0.0f, 50.0f, |
| 149 0.0f, 0.0f, 1.0f, 0.0f, | 150 0.0f, 0.0f, 1.0f, 0.0f, |
| 150 0.0f, 0.0f, 0.0f, 1.0f), | 151 0.0f, 0.0f, 0.0f, 1.0f), |
| 151 root_rect, | 152 root_rect, |
| 152 child_rect, | 153 child_rect, |
| 153 child_surface_id); | 154 child_surface_id); |
| 154 | 155 |
| 155 // Submit the root frame. | 156 // Submit the root frame. |
| 156 SurfaceIdAllocator root_allocator(2); | 157 SurfaceIdAllocator root_allocator(2); |
| 157 SurfaceId root_surface_id = root_allocator.GenerateId(); | 158 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 158 factory.Create(root_surface_id); | 159 factory.Create(root_surface_id); |
| 159 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 160 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 161 *root_frame_copy = std::move(root_frame); |
| 162 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 160 SurfaceFactory::DrawCallback()); | 163 SurfaceFactory::DrawCallback()); |
| 161 | 164 |
| 162 // Creates a child surface. | 165 // Creates a child surface. |
| 163 RenderPass* child_pass = nullptr; | 166 RenderPass* child_pass = nullptr; |
| 164 std::unique_ptr<CompositorFrame> child_frame = | 167 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 165 CreateCompositorFrame(child_rect, &child_pass); | |
| 166 | 168 |
| 167 // Add a solid quad in the child surface. | 169 // Add a solid quad in the child surface. |
| 168 gfx::Rect child_solid_quad_rect(100, 100); | 170 gfx::Rect child_solid_quad_rect(100, 100); |
| 169 CreateSolidColorDrawQuad( | 171 CreateSolidColorDrawQuad( |
| 170 child_pass, | 172 child_pass, |
| 171 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 173 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 172 0.0f, 1.0f, 0.0f, 50.0f, | 174 0.0f, 1.0f, 0.0f, 50.0f, |
| 173 0.0f, 0.0f, 1.0f, 0.0f, | 175 0.0f, 0.0f, 1.0f, 0.0f, |
| 174 0.0f, 0.0f, 0.0f, 1.0f), | 176 0.0f, 0.0f, 0.0f, 1.0f), |
| 175 root_rect, child_solid_quad_rect); | 177 root_rect, child_solid_quad_rect); |
| 176 | 178 |
| 177 // Submit the frame. | 179 // Submit the frame. |
| 178 factory.Create(child_surface_id); | 180 factory.Create(child_surface_id); |
| 179 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 181 std::unique_ptr<CompositorFrame> child_frame_copy(new CompositorFrame); |
| 182 *child_frame_copy = std::move(child_frame); |
| 183 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame_copy), |
| 180 SurfaceFactory::DrawCallback()); | 184 SurfaceFactory::DrawCallback()); |
| 181 | 185 |
| 182 TestCase tests[] = { | 186 TestCase tests[] = { |
| 183 { | 187 { |
| 184 root_surface_id, | 188 root_surface_id, |
| 185 gfx::Point(10, 10), | 189 gfx::Point(10, 10), |
| 186 root_surface_id, | 190 root_surface_id, |
| 187 gfx::Point(10, 10) | 191 gfx::Point(10, 10) |
| 188 }, | 192 }, |
| 189 { | 193 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Submit another root frame, with a slightly perturbed child Surface. | 227 // Submit another root frame, with a slightly perturbed child Surface. |
| 224 root_frame = CreateCompositorFrame(root_rect, &root_pass); | 228 root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 225 CreateSurfaceDrawQuad(root_pass, | 229 CreateSurfaceDrawQuad(root_pass, |
| 226 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, | 230 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, |
| 227 0.0f, 1.0f, 0.0f, 75.0f, | 231 0.0f, 1.0f, 0.0f, 75.0f, |
| 228 0.0f, 0.0f, 1.0f, 0.0f, | 232 0.0f, 0.0f, 1.0f, 0.0f, |
| 229 0.0f, 0.0f, 0.0f, 1.0f), | 233 0.0f, 0.0f, 0.0f, 1.0f), |
| 230 root_rect, | 234 root_rect, |
| 231 child_rect, | 235 child_rect, |
| 232 child_surface_id); | 236 child_surface_id); |
| 233 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 237 root_frame_copy.reset(new CompositorFrame); |
| 238 *root_frame_copy = std::move(root_frame); |
| 239 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 234 SurfaceFactory::DrawCallback()); | 240 SurfaceFactory::DrawCallback()); |
| 235 | 241 |
| 236 // Verify that point (100, 100) no longer falls on the child surface. | 242 // Verify that point (100, 100) no longer falls on the child surface. |
| 237 // Verify that the transform to the child surface's space has also shifted. | 243 // Verify that the transform to the child surface's space has also shifted. |
| 238 { | 244 { |
| 239 SurfaceHittest hittest(nullptr, &manager); | 245 SurfaceHittest hittest(nullptr, &manager); |
| 240 | 246 |
| 241 gfx::Point point(100, 100); | 247 gfx::Point point(100, 100); |
| 242 gfx::Transform transform; | 248 gfx::Transform transform; |
| 243 EXPECT_EQ(root_surface_id, | 249 EXPECT_EQ(root_surface_id, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 262 // This test verifies that hit testing will progress to the next quad if it | 268 // This test verifies that hit testing will progress to the next quad if it |
| 263 // encounters an invalid RenderPassDrawQuad for whatever reason. | 269 // encounters an invalid RenderPassDrawQuad for whatever reason. |
| 264 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { | 270 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { |
| 265 SurfaceManager manager; | 271 SurfaceManager manager; |
| 266 EmptySurfaceFactoryClient client; | 272 EmptySurfaceFactoryClient client; |
| 267 SurfaceFactory factory(&manager, &client); | 273 SurfaceFactory factory(&manager, &client); |
| 268 | 274 |
| 269 // Creates a root surface. | 275 // Creates a root surface. |
| 270 gfx::Rect root_rect(300, 300); | 276 gfx::Rect root_rect(300, 300); |
| 271 RenderPass* root_pass = nullptr; | 277 RenderPass* root_pass = nullptr; |
| 272 std::unique_ptr<CompositorFrame> root_frame = | 278 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 273 CreateCompositorFrame(root_rect, &root_pass); | |
| 274 | 279 |
| 275 // Create a RenderPassDrawQuad to a non-existant RenderPass. | 280 // Create a RenderPassDrawQuad to a non-existant RenderPass. |
| 276 CreateRenderPassDrawQuad(root_pass, | 281 CreateRenderPassDrawQuad(root_pass, |
| 277 gfx::Transform(), | 282 gfx::Transform(), |
| 278 root_rect, | 283 root_rect, |
| 279 root_rect, | 284 root_rect, |
| 280 RenderPassId(1337, 1337)); | 285 RenderPassId(1337, 1337)); |
| 281 | 286 |
| 282 // Add a reference to the child surface on the root surface. | 287 // Add a reference to the child surface on the root surface. |
| 283 SurfaceIdAllocator child_allocator(3); | 288 SurfaceIdAllocator child_allocator(3); |
| 284 SurfaceId child_surface_id = child_allocator.GenerateId(); | 289 SurfaceId child_surface_id = child_allocator.GenerateId(); |
| 285 gfx::Rect child_rect(200, 200); | 290 gfx::Rect child_rect(200, 200); |
| 286 CreateSurfaceDrawQuad(root_pass, | 291 CreateSurfaceDrawQuad(root_pass, |
| 287 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 292 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 288 0.0f, 1.0f, 0.0f, 50.0f, | 293 0.0f, 1.0f, 0.0f, 50.0f, |
| 289 0.0f, 0.0f, 1.0f, 0.0f, | 294 0.0f, 0.0f, 1.0f, 0.0f, |
| 290 0.0f, 0.0f, 0.0f, 1.0f), | 295 0.0f, 0.0f, 0.0f, 1.0f), |
| 291 root_rect, | 296 root_rect, |
| 292 child_rect, | 297 child_rect, |
| 293 child_surface_id); | 298 child_surface_id); |
| 294 | 299 |
| 295 // Submit the root frame. | 300 // Submit the root frame. |
| 296 SurfaceIdAllocator root_allocator(2); | 301 SurfaceIdAllocator root_allocator(2); |
| 297 SurfaceId root_surface_id = root_allocator.GenerateId(); | 302 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 298 factory.Create(root_surface_id); | 303 factory.Create(root_surface_id); |
| 299 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 304 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 305 *root_frame_copy = std::move(root_frame); |
| 306 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 300 SurfaceFactory::DrawCallback()); | 307 SurfaceFactory::DrawCallback()); |
| 301 | 308 |
| 302 // Creates a child surface. | 309 // Creates a child surface. |
| 303 RenderPass* child_pass = nullptr; | 310 RenderPass* child_pass = nullptr; |
| 304 std::unique_ptr<CompositorFrame> child_frame = | 311 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 305 CreateCompositorFrame(child_rect, &child_pass); | |
| 306 | 312 |
| 307 // Add a solid quad in the child surface. | 313 // Add a solid quad in the child surface. |
| 308 gfx::Rect child_solid_quad_rect(100, 100); | 314 gfx::Rect child_solid_quad_rect(100, 100); |
| 309 CreateSolidColorDrawQuad(child_pass, | 315 CreateSolidColorDrawQuad(child_pass, |
| 310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 316 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 311 0.0f, 1.0f, 0.0f, 50.0f, | 317 0.0f, 1.0f, 0.0f, 50.0f, |
| 312 0.0f, 0.0f, 1.0f, 0.0f, | 318 0.0f, 0.0f, 1.0f, 0.0f, |
| 313 0.0f, 0.0f, 0.0f, 1.0f), | 319 0.0f, 0.0f, 0.0f, 1.0f), |
| 314 root_rect, | 320 root_rect, |
| 315 child_solid_quad_rect); | 321 child_solid_quad_rect); |
| 316 | 322 |
| 317 // Submit the frame. | 323 // Submit the frame. |
| 318 factory.Create(child_surface_id); | 324 factory.Create(child_surface_id); |
| 319 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 325 std::unique_ptr<CompositorFrame> child_frame_copy(new CompositorFrame); |
| 326 *child_frame_copy = std::move(child_frame); |
| 327 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame_copy), |
| 320 SurfaceFactory::DrawCallback()); | 328 SurfaceFactory::DrawCallback()); |
| 321 | 329 |
| 322 TestCase tests[] = { | 330 TestCase tests[] = { |
| 323 { | 331 { |
| 324 root_surface_id, | 332 root_surface_id, |
| 325 gfx::Point(10, 10), | 333 gfx::Point(10, 10), |
| 326 root_surface_id, | 334 root_surface_id, |
| 327 gfx::Point(10, 10) | 335 gfx::Point(10, 10) |
| 328 }, | 336 }, |
| 329 { | 337 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 gfx::Rect(100, 100), | 391 gfx::Rect(100, 100), |
| 384 transform_to_root_target, | 392 transform_to_root_target, |
| 385 &render_pass_list); | 393 &render_pass_list); |
| 386 | 394 |
| 387 // Create the root RenderPass. | 395 // Create the root RenderPass. |
| 388 RenderPassId root_render_pass_id(1, 2); | 396 RenderPassId root_render_pass_id(1, 2); |
| 389 CreateRenderPass(root_render_pass_id, root_rect, gfx::Transform(), | 397 CreateRenderPass(root_render_pass_id, root_rect, gfx::Transform(), |
| 390 &render_pass_list); | 398 &render_pass_list); |
| 391 | 399 |
| 392 RenderPass* root_pass = nullptr; | 400 RenderPass* root_pass = nullptr; |
| 393 std::unique_ptr<CompositorFrame> root_frame = | 401 CompositorFrame root_frame = |
| 394 CreateCompositorFrameWithRenderPassList(&render_pass_list); | 402 CreateCompositorFrameWithRenderPassList(&render_pass_list); |
| 395 root_pass = root_frame->delegated_frame_data->render_pass_list.back().get(); | 403 root_pass = root_frame.delegated_frame_data->render_pass_list.back().get(); |
| 396 | 404 |
| 397 // Create a RenderPassDrawQuad. | 405 // Create a RenderPassDrawQuad. |
| 398 gfx::Rect render_pass_quad_rect(100, 100); | 406 gfx::Rect render_pass_quad_rect(100, 100); |
| 399 CreateRenderPassDrawQuad(root_pass, | 407 CreateRenderPassDrawQuad(root_pass, |
| 400 transform_to_root_target, | 408 transform_to_root_target, |
| 401 root_rect, | 409 root_rect, |
| 402 render_pass_quad_rect, | 410 render_pass_quad_rect, |
| 403 child_render_pass_id); | 411 child_render_pass_id); |
| 404 | 412 |
| 405 // Add a solid quad in the child render pass. | 413 // Add a solid quad in the child render pass. |
| 406 RenderPass* child_render_pass = | 414 RenderPass* child_render_pass = |
| 407 root_frame->delegated_frame_data->render_pass_list.front().get(); | 415 root_frame.delegated_frame_data->render_pass_list.front().get(); |
| 408 gfx::Rect child_solid_quad_rect(100, 100); | 416 gfx::Rect child_solid_quad_rect(100, 100); |
| 409 CreateSolidColorDrawQuad(child_render_pass, | 417 CreateSolidColorDrawQuad(child_render_pass, |
| 410 gfx::Transform(), | 418 gfx::Transform(), |
| 411 gfx::Rect(100, 100), | 419 gfx::Rect(100, 100), |
| 412 child_solid_quad_rect); | 420 child_solid_quad_rect); |
| 413 | 421 |
| 414 // Submit the root frame. | 422 // Submit the root frame. |
| 415 SurfaceIdAllocator root_allocator(1); | 423 SurfaceIdAllocator root_allocator(1); |
| 416 SurfaceId root_surface_id = root_allocator.GenerateId(); | 424 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 417 factory.Create(root_surface_id); | 425 factory.Create(root_surface_id); |
| 418 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 426 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 427 *root_frame_copy = std::move(root_frame); |
| 428 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 419 SurfaceFactory::DrawCallback()); | 429 SurfaceFactory::DrawCallback()); |
| 420 | 430 |
| 421 TestCase tests[] = { | 431 TestCase tests[] = { |
| 422 // These tests just miss the RenderPassDrawQuad. | 432 // These tests just miss the RenderPassDrawQuad. |
| 423 { | 433 { |
| 424 root_surface_id, | 434 root_surface_id, |
| 425 gfx::Point(49, 49), | 435 gfx::Point(49, 49), |
| 426 root_surface_id, | 436 root_surface_id, |
| 427 gfx::Point(49, 49) | 437 gfx::Point(49, 49) |
| 428 }, | 438 }, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 478 } |
| 469 | 479 |
| 470 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { | 480 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { |
| 471 SurfaceManager manager; | 481 SurfaceManager manager; |
| 472 EmptySurfaceFactoryClient client; | 482 EmptySurfaceFactoryClient client; |
| 473 SurfaceFactory factory(&manager, &client); | 483 SurfaceFactory factory(&manager, &client); |
| 474 | 484 |
| 475 // Creates a root surface. | 485 // Creates a root surface. |
| 476 gfx::Rect root_rect(300, 300); | 486 gfx::Rect root_rect(300, 300); |
| 477 RenderPass* root_pass = nullptr; | 487 RenderPass* root_pass = nullptr; |
| 478 std::unique_ptr<CompositorFrame> root_frame = | 488 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 479 CreateCompositorFrame(root_rect, &root_pass); | |
| 480 | 489 |
| 481 // Add a reference to the child surface on the root surface. | 490 // Add a reference to the child surface on the root surface. |
| 482 SurfaceIdAllocator child_allocator(3); | 491 SurfaceIdAllocator child_allocator(3); |
| 483 SurfaceId child_surface_id = child_allocator.GenerateId(); | 492 SurfaceId child_surface_id = child_allocator.GenerateId(); |
| 484 gfx::Rect child_rect(200, 200); | 493 gfx::Rect child_rect(200, 200); |
| 485 CreateSurfaceDrawQuad( | 494 CreateSurfaceDrawQuad( |
| 486 root_pass, | 495 root_pass, |
| 487 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 496 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 488 0.0f, 1.0f, 0.0f, 50.0f, | 497 0.0f, 1.0f, 0.0f, 50.0f, |
| 489 0.0f, 0.0f, 1.0f, 0.0f, | 498 0.0f, 0.0f, 1.0f, 0.0f, |
| 490 0.0f, 0.0f, 0.0f, 1.0f), | 499 0.0f, 0.0f, 0.0f, 1.0f), |
| 491 root_rect, child_rect, child_surface_id); | 500 root_rect, child_rect, child_surface_id); |
| 492 | 501 |
| 493 // Submit the root frame. | 502 // Submit the root frame. |
| 494 SurfaceIdAllocator root_allocator(2); | 503 SurfaceIdAllocator root_allocator(2); |
| 495 SurfaceId root_surface_id = root_allocator.GenerateId(); | 504 SurfaceId root_surface_id = root_allocator.GenerateId(); |
| 496 factory.Create(root_surface_id); | 505 factory.Create(root_surface_id); |
| 497 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 506 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); |
| 507 *root_frame_copy = std::move(root_frame); |
| 508 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy), |
| 498 SurfaceFactory::DrawCallback()); | 509 SurfaceFactory::DrawCallback()); |
| 499 | 510 |
| 500 // Creates a child surface. | 511 // Creates a child surface. |
| 501 RenderPass* child_pass = nullptr; | 512 RenderPass* child_pass = nullptr; |
| 502 std::unique_ptr<CompositorFrame> child_frame = | 513 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 503 CreateCompositorFrame(child_rect, &child_pass); | |
| 504 | 514 |
| 505 // Add a solid quad in the child surface. | 515 // Add a solid quad in the child surface. |
| 506 gfx::Rect child_solid_quad_rect(190, 190); | 516 gfx::Rect child_solid_quad_rect(190, 190); |
| 507 CreateSolidColorDrawQuad( | 517 CreateSolidColorDrawQuad( |
| 508 child_pass, | 518 child_pass, |
| 509 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, | 519 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, |
| 510 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), | 520 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), |
| 511 root_rect, child_solid_quad_rect); | 521 root_rect, child_solid_quad_rect); |
| 512 | 522 |
| 513 // Submit the frame. | 523 // Submit the frame. |
| 514 factory.Create(child_surface_id); | 524 factory.Create(child_surface_id); |
| 515 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 525 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame); |
| 526 *frame_copy = std::move(child_frame); |
| 527 factory.SubmitCompositorFrame(child_surface_id, std::move(frame_copy), |
| 516 SurfaceFactory::DrawCallback()); | 528 SurfaceFactory::DrawCallback()); |
| 517 | 529 |
| 518 TestCase test_expectations_without_insets[] = { | 530 TestCase test_expectations_without_insets[] = { |
| 519 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, | 531 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, |
| 520 {root_surface_id, gfx::Point(60, 60), child_surface_id, | 532 {root_surface_id, gfx::Point(60, 60), child_surface_id, |
| 521 gfx::Point(10, 10)}, | 533 gfx::Point(10, 10)}, |
| 522 {root_surface_id, gfx::Point(239, 239), child_surface_id, | 534 {root_surface_id, gfx::Point(239, 239), child_surface_id, |
| 523 gfx::Point(189, 189)}, | 535 gfx::Point(189, 189)}, |
| 524 {root_surface_id, gfx::Point(244, 244), child_surface_id, | 536 {root_surface_id, gfx::Point(244, 244), child_surface_id, |
| 525 gfx::Point(194, 194)}, | 537 gfx::Point(194, 194)}, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 arraysize(test_expectations_with_accept_insets)); | 601 arraysize(test_expectations_with_accept_insets)); |
| 590 | 602 |
| 591 // Verify that insets have affected hit targeting. | 603 // Verify that insets have affected hit targeting. |
| 592 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 604 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
| 593 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 605 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
| 594 | 606 |
| 595 factory.Destroy(root_surface_id); | 607 factory.Destroy(root_surface_id); |
| 596 } | 608 } |
| 597 | 609 |
| 598 } // namespace cc | 610 } // namespace cc |
| OLD | NEW |