| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/mac/sdk_forward_declarations.h" | 7 #include "base/mac/sdk_forward_declarations.h" |
| 8 #include "gpu/GLES2/gl2extchromium.h" | 8 #include "gpu/GLES2/gl2extchromium.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // Validate the initial values. | 49 // Validate the initial values. |
| 50 { | 50 { |
| 51 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 51 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 52 result = new_ca_layer_tree->ScheduleCALayer( | 52 result = new_ca_layer_tree->ScheduleCALayer( |
| 53 is_clipped, | 53 is_clipped, |
| 54 clip_rect, | 54 clip_rect, |
| 55 sorting_context_id, | 55 sorting_context_id, |
| 56 transform, | 56 transform, |
| 57 io_surface, | 57 io_surface, |
| 58 nullptr, |
| 58 contents_rect, | 59 contents_rect, |
| 59 rect, | 60 rect, |
| 60 background_color, | 61 background_color, |
| 61 edge_aa_mask, | 62 edge_aa_mask, |
| 62 opacity); | 63 opacity); |
| 63 EXPECT_TRUE(result); | 64 EXPECT_TRUE(result); |
| 64 new_ca_layer_tree->CommitScheduledCALayers( | 65 new_ca_layer_tree->CommitScheduledCALayers( |
| 65 superlayer_, std::move(ca_layer_tree), scale_factor); | 66 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 66 std::swap(new_ca_layer_tree, ca_layer_tree); | 67 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 67 | 68 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Update just the clip rect and re-commit. | 107 // Update just the clip rect and re-commit. |
| 107 { | 108 { |
| 108 clip_rect = gfx::Rect(4, 8, 16, 32); | 109 clip_rect = gfx::Rect(4, 8, 16, 32); |
| 109 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 110 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 110 result = new_ca_layer_tree->ScheduleCALayer( | 111 result = new_ca_layer_tree->ScheduleCALayer( |
| 111 is_clipped, | 112 is_clipped, |
| 112 clip_rect, | 113 clip_rect, |
| 113 sorting_context_id, | 114 sorting_context_id, |
| 114 transform, | 115 transform, |
| 115 io_surface, | 116 io_surface, |
| 117 nullptr, |
| 116 contents_rect, | 118 contents_rect, |
| 117 rect, | 119 rect, |
| 118 background_color, | 120 background_color, |
| 119 edge_aa_mask, | 121 edge_aa_mask, |
| 120 opacity); | 122 opacity); |
| 121 EXPECT_TRUE(result); | 123 EXPECT_TRUE(result); |
| 122 new_ca_layer_tree->CommitScheduledCALayers( | 124 new_ca_layer_tree->CommitScheduledCALayers( |
| 123 superlayer_, std::move(ca_layer_tree), scale_factor); | 125 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 124 std::swap(new_ca_layer_tree, ca_layer_tree); | 126 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 125 | 127 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 147 // Disable clipping and re-commit. | 149 // Disable clipping and re-commit. |
| 148 { | 150 { |
| 149 is_clipped = false; | 151 is_clipped = false; |
| 150 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 152 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 151 result = new_ca_layer_tree->ScheduleCALayer( | 153 result = new_ca_layer_tree->ScheduleCALayer( |
| 152 is_clipped, | 154 is_clipped, |
| 153 clip_rect, | 155 clip_rect, |
| 154 sorting_context_id, | 156 sorting_context_id, |
| 155 transform, | 157 transform, |
| 156 io_surface, | 158 io_surface, |
| 159 nullptr, |
| 157 contents_rect, | 160 contents_rect, |
| 158 rect, | 161 rect, |
| 159 background_color, | 162 background_color, |
| 160 edge_aa_mask, | 163 edge_aa_mask, |
| 161 opacity); | 164 opacity); |
| 162 EXPECT_TRUE(result); | 165 EXPECT_TRUE(result); |
| 163 new_ca_layer_tree->CommitScheduledCALayers( | 166 new_ca_layer_tree->CommitScheduledCALayers( |
| 164 superlayer_, std::move(ca_layer_tree), scale_factor); | 167 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 165 std::swap(new_ca_layer_tree, ca_layer_tree); | 168 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 166 | 169 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 185 // Change the transform and re-commit. | 188 // Change the transform and re-commit. |
| 186 { | 189 { |
| 187 transform.Translate(5, 5); | 190 transform.Translate(5, 5); |
| 188 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 191 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 189 result = new_ca_layer_tree->ScheduleCALayer( | 192 result = new_ca_layer_tree->ScheduleCALayer( |
| 190 is_clipped, | 193 is_clipped, |
| 191 clip_rect, | 194 clip_rect, |
| 192 sorting_context_id, | 195 sorting_context_id, |
| 193 transform, | 196 transform, |
| 194 io_surface, | 197 io_surface, |
| 198 nullptr, |
| 195 contents_rect, | 199 contents_rect, |
| 196 rect, | 200 rect, |
| 197 background_color, | 201 background_color, |
| 198 edge_aa_mask, | 202 edge_aa_mask, |
| 199 opacity); | 203 opacity); |
| 200 EXPECT_TRUE(result); | 204 EXPECT_TRUE(result); |
| 201 new_ca_layer_tree->CommitScheduledCALayers( | 205 new_ca_layer_tree->CommitScheduledCALayers( |
| 202 superlayer_, std::move(ca_layer_tree), scale_factor); | 206 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 203 std::swap(new_ca_layer_tree, ca_layer_tree); | 207 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 204 | 208 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 221 // Change the edge antialiasing mask and commit. | 225 // Change the edge antialiasing mask and commit. |
| 222 { | 226 { |
| 223 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM; | 227 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM; |
| 224 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 228 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 225 result = new_ca_layer_tree->ScheduleCALayer( | 229 result = new_ca_layer_tree->ScheduleCALayer( |
| 226 is_clipped, | 230 is_clipped, |
| 227 clip_rect, | 231 clip_rect, |
| 228 sorting_context_id, | 232 sorting_context_id, |
| 229 transform, | 233 transform, |
| 230 io_surface, | 234 io_surface, |
| 235 nullptr, |
| 231 contents_rect, | 236 contents_rect, |
| 232 rect, | 237 rect, |
| 233 background_color, | 238 background_color, |
| 234 edge_aa_mask, | 239 edge_aa_mask, |
| 235 opacity); | 240 opacity); |
| 236 EXPECT_TRUE(result); | 241 EXPECT_TRUE(result); |
| 237 new_ca_layer_tree->CommitScheduledCALayers( | 242 new_ca_layer_tree->CommitScheduledCALayers( |
| 238 superlayer_, std::move(ca_layer_tree), scale_factor); | 243 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 239 std::swap(new_ca_layer_tree, ca_layer_tree); | 244 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 240 | 245 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 255 | 260 |
| 256 // Change the contents and commit. | 261 // Change the contents and commit. |
| 257 { | 262 { |
| 258 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 263 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 259 result = new_ca_layer_tree->ScheduleCALayer( | 264 result = new_ca_layer_tree->ScheduleCALayer( |
| 260 is_clipped, | 265 is_clipped, |
| 261 clip_rect, | 266 clip_rect, |
| 262 sorting_context_id, | 267 sorting_context_id, |
| 263 transform, | 268 transform, |
| 264 nullptr, | 269 nullptr, |
| 270 nullptr, |
| 265 contents_rect, | 271 contents_rect, |
| 266 rect, | 272 rect, |
| 267 background_color, | 273 background_color, |
| 268 edge_aa_mask, | 274 edge_aa_mask, |
| 269 opacity); | 275 opacity); |
| 270 EXPECT_TRUE(result); | 276 EXPECT_TRUE(result); |
| 271 new_ca_layer_tree->CommitScheduledCALayers( | 277 new_ca_layer_tree->CommitScheduledCALayers( |
| 272 superlayer_, std::move(ca_layer_tree), scale_factor); | 278 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 273 std::swap(new_ca_layer_tree, ca_layer_tree); | 279 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 274 | 280 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 291 // Change the rect size. | 297 // Change the rect size. |
| 292 { | 298 { |
| 293 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16)); | 299 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16)); |
| 294 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 300 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 295 result = new_ca_layer_tree->ScheduleCALayer( | 301 result = new_ca_layer_tree->ScheduleCALayer( |
| 296 is_clipped, | 302 is_clipped, |
| 297 clip_rect, | 303 clip_rect, |
| 298 sorting_context_id, | 304 sorting_context_id, |
| 299 transform, | 305 transform, |
| 300 nullptr, | 306 nullptr, |
| 307 nullptr, |
| 301 contents_rect, | 308 contents_rect, |
| 302 rect, | 309 rect, |
| 303 background_color, | 310 background_color, |
| 304 edge_aa_mask, | 311 edge_aa_mask, |
| 305 opacity); | 312 opacity); |
| 306 EXPECT_TRUE(result); | 313 EXPECT_TRUE(result); |
| 307 new_ca_layer_tree->CommitScheduledCALayers( | 314 new_ca_layer_tree->CommitScheduledCALayers( |
| 308 superlayer_, std::move(ca_layer_tree), scale_factor); | 315 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 309 std::swap(new_ca_layer_tree, ca_layer_tree); | 316 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 310 | 317 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 327 // Change the rect position. | 334 // Change the rect position. |
| 328 { | 335 { |
| 329 rect = gfx::Rect(gfx::Point(16, 4), rect.size()); | 336 rect = gfx::Rect(gfx::Point(16, 4), rect.size()); |
| 330 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 337 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 331 result = new_ca_layer_tree->ScheduleCALayer( | 338 result = new_ca_layer_tree->ScheduleCALayer( |
| 332 is_clipped, | 339 is_clipped, |
| 333 clip_rect, | 340 clip_rect, |
| 334 sorting_context_id, | 341 sorting_context_id, |
| 335 transform, | 342 transform, |
| 336 nullptr, | 343 nullptr, |
| 344 nullptr, |
| 337 contents_rect, | 345 contents_rect, |
| 338 rect, | 346 rect, |
| 339 background_color, | 347 background_color, |
| 340 edge_aa_mask, | 348 edge_aa_mask, |
| 341 opacity); | 349 opacity); |
| 342 EXPECT_TRUE(result); | 350 EXPECT_TRUE(result); |
| 343 new_ca_layer_tree->CommitScheduledCALayers( | 351 new_ca_layer_tree->CommitScheduledCALayers( |
| 344 superlayer_, std::move(ca_layer_tree), scale_factor); | 352 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 345 std::swap(new_ca_layer_tree, ca_layer_tree); | 353 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 346 | 354 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 363 // Change the opacity. | 371 // Change the opacity. |
| 364 { | 372 { |
| 365 opacity = 1.0f; | 373 opacity = 1.0f; |
| 366 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 374 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 367 result = new_ca_layer_tree->ScheduleCALayer( | 375 result = new_ca_layer_tree->ScheduleCALayer( |
| 368 is_clipped, | 376 is_clipped, |
| 369 clip_rect, | 377 clip_rect, |
| 370 sorting_context_id, | 378 sorting_context_id, |
| 371 transform, | 379 transform, |
| 372 nullptr, | 380 nullptr, |
| 381 nullptr, |
| 373 contents_rect, | 382 contents_rect, |
| 374 rect, | 383 rect, |
| 375 background_color, | 384 background_color, |
| 376 edge_aa_mask, | 385 edge_aa_mask, |
| 377 opacity); | 386 opacity); |
| 378 EXPECT_TRUE(result); | 387 EXPECT_TRUE(result); |
| 379 new_ca_layer_tree->CommitScheduledCALayers( | 388 new_ca_layer_tree->CommitScheduledCALayers( |
| 380 superlayer_, std::move(ca_layer_tree), scale_factor); | 389 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 381 std::swap(new_ca_layer_tree, ca_layer_tree); | 390 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 382 | 391 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 398 // Add the clipping and IOSurface contents back. | 407 // Add the clipping and IOSurface contents back. |
| 399 { | 408 { |
| 400 is_clipped = true; | 409 is_clipped = true; |
| 401 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 410 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 402 result = new_ca_layer_tree->ScheduleCALayer( | 411 result = new_ca_layer_tree->ScheduleCALayer( |
| 403 is_clipped, | 412 is_clipped, |
| 404 clip_rect, | 413 clip_rect, |
| 405 sorting_context_id, | 414 sorting_context_id, |
| 406 transform, | 415 transform, |
| 407 io_surface, | 416 io_surface, |
| 417 nullptr, |
| 408 contents_rect, | 418 contents_rect, |
| 409 rect, | 419 rect, |
| 410 background_color, | 420 background_color, |
| 411 edge_aa_mask, | 421 edge_aa_mask, |
| 412 opacity); | 422 opacity); |
| 413 EXPECT_TRUE(result); | 423 EXPECT_TRUE(result); |
| 414 new_ca_layer_tree->CommitScheduledCALayers( | 424 new_ca_layer_tree->CommitScheduledCALayers( |
| 415 superlayer_, std::move(ca_layer_tree), scale_factor); | 425 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 416 std::swap(new_ca_layer_tree, ca_layer_tree); | 426 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 417 | 427 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 434 // Change the scale factor. This should result in a new tree being created. | 444 // Change the scale factor. This should result in a new tree being created. |
| 435 { | 445 { |
| 436 scale_factor = 2.0f; | 446 scale_factor = 2.0f; |
| 437 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 447 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 438 result = new_ca_layer_tree->ScheduleCALayer( | 448 result = new_ca_layer_tree->ScheduleCALayer( |
| 439 is_clipped, | 449 is_clipped, |
| 440 clip_rect, | 450 clip_rect, |
| 441 sorting_context_id, | 451 sorting_context_id, |
| 442 transform, | 452 transform, |
| 443 io_surface, | 453 io_surface, |
| 454 nullptr, |
| 444 contents_rect, | 455 contents_rect, |
| 445 rect, | 456 rect, |
| 446 background_color, | 457 background_color, |
| 447 edge_aa_mask, | 458 edge_aa_mask, |
| 448 opacity); | 459 opacity); |
| 449 EXPECT_TRUE(result); | 460 EXPECT_TRUE(result); |
| 450 new_ca_layer_tree->CommitScheduledCALayers( | 461 new_ca_layer_tree->CommitScheduledCALayers( |
| 451 superlayer_, std::move(ca_layer_tree), scale_factor); | 462 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 452 std::swap(new_ca_layer_tree, ca_layer_tree); | 463 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 453 | 464 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 540 |
| 530 // Schedule and commit the layers. | 541 // Schedule and commit the layers. |
| 531 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); | 542 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); |
| 532 for (size_t i = 0; i < 5; ++i) { | 543 for (size_t i = 0; i < 5; ++i) { |
| 533 bool result = ca_layer_tree->ScheduleCALayer( | 544 bool result = ca_layer_tree->ScheduleCALayer( |
| 534 is_clipped, | 545 is_clipped, |
| 535 clip_rect, | 546 clip_rect, |
| 536 sorting_context_id, | 547 sorting_context_id, |
| 537 transforms[i], | 548 transforms[i], |
| 538 io_surfaces[i], | 549 io_surfaces[i], |
| 550 nullptr, |
| 539 contents_rect, | 551 contents_rect, |
| 540 rect, | 552 rect, |
| 541 background_color, | 553 background_color, |
| 542 edge_aa_mask, | 554 edge_aa_mask, |
| 543 opacity); | 555 opacity); |
| 544 EXPECT_TRUE(result); | 556 EXPECT_TRUE(result); |
| 545 } | 557 } |
| 546 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); | 558 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); |
| 547 | 559 |
| 548 // Validate the root layer. | 560 // Validate the root layer. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 626 |
| 615 // Schedule and commit the layers. | 627 // Schedule and commit the layers. |
| 616 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); | 628 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); |
| 617 for (size_t i = 0; i < 3; ++i) { | 629 for (size_t i = 0; i < 3; ++i) { |
| 618 bool result = ca_layer_tree->ScheduleCALayer( | 630 bool result = ca_layer_tree->ScheduleCALayer( |
| 619 is_clipped, | 631 is_clipped, |
| 620 clip_rect, | 632 clip_rect, |
| 621 sorting_context_ids[i], | 633 sorting_context_ids[i], |
| 622 transform, | 634 transform, |
| 623 io_surfaces[i], | 635 io_surfaces[i], |
| 636 nullptr, |
| 624 contents_rect, | 637 contents_rect, |
| 625 rect, | 638 rect, |
| 626 background_color, | 639 background_color, |
| 627 edge_aa_mask, | 640 edge_aa_mask, |
| 628 opacity); | 641 opacity); |
| 629 EXPECT_TRUE(result); | 642 EXPECT_TRUE(result); |
| 630 } | 643 } |
| 631 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); | 644 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); |
| 632 | 645 |
| 633 // Validate the root layer. | 646 // Validate the root layer. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // First send the various clip parameters to sorting context zero. This is | 700 // First send the various clip parameters to sorting context zero. This is |
| 688 // legitimate. | 701 // legitimate. |
| 689 for (size_t i = 0; i < 3; ++i) { | 702 for (size_t i = 0; i < 3; ++i) { |
| 690 int sorting_context_id = 0; | 703 int sorting_context_id = 0; |
| 691 bool result = ca_layer_tree->ScheduleCALayer( | 704 bool result = ca_layer_tree->ScheduleCALayer( |
| 692 is_clippeds[i], | 705 is_clippeds[i], |
| 693 clip_rects[i], | 706 clip_rects[i], |
| 694 sorting_context_id, | 707 sorting_context_id, |
| 695 transform, | 708 transform, |
| 696 io_surface, | 709 io_surface, |
| 710 nullptr, |
| 697 contents_rect, | 711 contents_rect, |
| 698 rect, | 712 rect, |
| 699 background_color, | 713 background_color, |
| 700 edge_aa_mask, | 714 edge_aa_mask, |
| 701 opacity); | 715 opacity); |
| 702 EXPECT_TRUE(result); | 716 EXPECT_TRUE(result); |
| 703 } | 717 } |
| 704 // Next send the various clip parameters to a non-zero sorting context. This | 718 // Next send the various clip parameters to a non-zero sorting context. This |
| 705 // will fail when we try to change the clip within the sorting context. | 719 // will fail when we try to change the clip within the sorting context. |
| 706 for (size_t i = 0; i < 3; ++i) { | 720 for (size_t i = 0; i < 3; ++i) { |
| 707 int sorting_context_id = 3; | 721 int sorting_context_id = 3; |
| 708 bool result = ca_layer_tree->ScheduleCALayer( | 722 bool result = ca_layer_tree->ScheduleCALayer( |
| 709 is_clippeds[i], | 723 is_clippeds[i], |
| 710 clip_rects[i], | 724 clip_rects[i], |
| 711 sorting_context_id, | 725 sorting_context_id, |
| 712 transform, | 726 transform, |
| 713 io_surface, | 727 io_surface, |
| 728 nullptr, |
| 714 contents_rect, | 729 contents_rect, |
| 715 rect, | 730 rect, |
| 716 background_color, | 731 background_color, |
| 717 edge_aa_mask, | 732 edge_aa_mask, |
| 718 opacity); | 733 opacity); |
| 719 if (i == 0) | 734 if (i == 0) |
| 720 EXPECT_TRUE(result); | 735 EXPECT_TRUE(result); |
| 721 else | 736 else |
| 722 EXPECT_FALSE(result); | 737 EXPECT_FALSE(result); |
| 723 } | 738 } |
| 724 // Try once more with the original clip and verify it works. | 739 // Try once more with the original clip and verify it works. |
| 725 { | 740 { |
| 726 int sorting_context_id = 3; | 741 int sorting_context_id = 3; |
| 727 bool result = ca_layer_tree->ScheduleCALayer( | 742 bool result = ca_layer_tree->ScheduleCALayer( |
| 728 is_clippeds[0], | 743 is_clippeds[0], |
| 729 clip_rects[0], | 744 clip_rects[0], |
| 730 sorting_context_id, | 745 sorting_context_id, |
| 731 transform, | 746 transform, |
| 732 io_surface, | 747 io_surface, |
| 748 nullptr, |
| 733 contents_rect, | 749 contents_rect, |
| 734 rect, | 750 rect, |
| 735 background_color, | 751 background_color, |
| 736 edge_aa_mask, | 752 edge_aa_mask, |
| 737 opacity); | 753 opacity); |
| 738 EXPECT_TRUE(result); | 754 EXPECT_TRUE(result); |
| 739 } | 755 } |
| 740 } | 756 } |
| 741 | 757 |
| 742 // Test updating each layer's properties. | 758 // Test updating each layer's properties. |
| 743 TEST_F(CALayerTreeTest, AVLayer) { | 759 TEST_F(CALayerTreeTest, AVLayer) { |
| 744 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(gfx::CreateIOSurface( | 760 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(gfx::CreateIOSurface( |
| 745 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 761 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 762 |
| 746 bool is_clipped = true; | 763 bool is_clipped = true; |
| 747 gfx::Rect clip_rect(2, 4, 8, 16); | 764 gfx::Rect clip_rect(2, 4, 8, 16); |
| 748 int sorting_context_id = 0; | 765 int sorting_context_id = 0; |
| 749 gfx::Transform transform; | 766 gfx::Transform transform; |
| 750 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); | 767 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); |
| 751 gfx::Rect rect(16, 32, 64, 128); | 768 gfx::Rect rect(16, 32, 64, 128); |
| 752 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 769 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 753 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 770 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 754 float opacity = 0.5f; | 771 float opacity = 0.5f; |
| 755 float scale_factor = 1.0f; | 772 float scale_factor = 1.0f; |
| 756 bool result = false; | 773 bool result = false; |
| 757 | 774 |
| 758 std::unique_ptr<ui::CALayerTree> ca_layer_tree; | 775 std::unique_ptr<ui::CALayerTree> ca_layer_tree; |
| 759 CALayer* root_layer = nil; | 776 CALayer* root_layer = nil; |
| 760 CALayer* clip_and_sorting_layer = nil; | 777 CALayer* clip_and_sorting_layer = nil; |
| 761 CALayer* transform_layer = nil; | 778 CALayer* transform_layer = nil; |
| 762 CALayer* content_layer1 = nil; | 779 CALayer* content_layer1 = nil; |
| 763 CALayer* content_layer2 = nil; | 780 CALayer* content_layer2 = nil; |
| 764 CALayer* content_layer3 = nil; | 781 CALayer* content_layer3 = nil; |
| 765 | 782 |
| 766 // Validate the initial values. | 783 // Validate the initial values. |
| 767 { | 784 { |
| 768 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 785 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 769 result = new_ca_layer_tree->ScheduleCALayer( | 786 result = new_ca_layer_tree->ScheduleCALayer( |
| 770 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 787 is_clipped, |
| 771 contents_rect, rect, background_color, edge_aa_mask, opacity); | 788 clip_rect, |
| 789 sorting_context_id, |
| 790 transform, |
| 791 io_surface, |
| 792 nullptr, |
| 793 contents_rect, |
| 794 rect, background_color, |
| 795 edge_aa_mask, |
| 796 opacity); |
| 772 EXPECT_TRUE(result); | 797 EXPECT_TRUE(result); |
| 773 new_ca_layer_tree->CommitScheduledCALayers( | 798 new_ca_layer_tree->CommitScheduledCALayers( |
| 774 superlayer_, std::move(ca_layer_tree), scale_factor); | 799 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 775 std::swap(new_ca_layer_tree, ca_layer_tree); | 800 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 776 | 801 |
| 777 // Validate the tree structure. | 802 // Validate the tree structure. |
| 778 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 803 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 779 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 804 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 780 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 805 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 781 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 806 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 782 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 807 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 783 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 808 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 784 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 809 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 785 content_layer1 = [[transform_layer sublayers] objectAtIndex:0]; | 810 content_layer1 = [[transform_layer sublayers] objectAtIndex:0]; |
| 786 | 811 |
| 787 // Validate the content layer. | 812 // Validate the content layer. |
| 788 EXPECT_FALSE([content_layer1 | 813 EXPECT_FALSE([content_layer1 |
| 789 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 814 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 790 } | 815 } |
| 791 | 816 |
| 792 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), | 817 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 793 gfx::BufferFormat::YUV_420_BIPLANAR)); | 818 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 794 | 819 |
| 795 // Pass another frame. | 820 // Pass another frame. |
| 796 { | 821 { |
| 797 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 822 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 798 result = new_ca_layer_tree->ScheduleCALayer( | 823 result = new_ca_layer_tree->ScheduleCALayer( |
| 799 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 824 is_clipped, |
| 800 contents_rect, rect, background_color, edge_aa_mask, opacity); | 825 clip_rect, |
| 826 sorting_context_id, |
| 827 transform, |
| 828 io_surface, |
| 829 nullptr, |
| 830 contents_rect, |
| 831 rect, |
| 832 background_color, |
| 833 edge_aa_mask, |
| 834 opacity); |
| 801 EXPECT_TRUE(result); | 835 EXPECT_TRUE(result); |
| 802 new_ca_layer_tree->CommitScheduledCALayers( | 836 new_ca_layer_tree->CommitScheduledCALayers( |
| 803 superlayer_, std::move(ca_layer_tree), scale_factor); | 837 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 804 std::swap(new_ca_layer_tree, ca_layer_tree); | 838 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 805 | 839 |
| 806 // Validate the tree structure. | 840 // Validate the tree structure. |
| 807 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 841 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 808 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 842 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 809 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 843 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 810 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 844 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 811 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 845 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 812 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 846 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 813 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 847 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 814 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; | 848 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; |
| 815 | 849 |
| 816 // Validate the content layer. | 850 // Validate the content layer. |
| 817 EXPECT_FALSE([content_layer2 | 851 EXPECT_FALSE([content_layer2 |
| 818 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 852 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 819 EXPECT_EQ(content_layer2, content_layer1); | 853 EXPECT_EQ(content_layer2, content_layer1); |
| 820 } | 854 } |
| 821 | 855 |
| 822 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), | 856 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 823 gfx::BufferFormat::YUV_420_BIPLANAR)); | 857 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 858 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; |
| 859 CVPixelBufferCreateWithIOSurface( |
| 860 nullptr, io_surface, nullptr, cv_pixel_buffer.InitializeInto()); |
| 861 |
| 862 // Pass a frame with a CVPixelBuffer |
| 863 { |
| 864 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 865 result = new_ca_layer_tree->ScheduleCALayer( |
| 866 is_clipped, |
| 867 clip_rect, |
| 868 sorting_context_id, |
| 869 transform, |
| 870 io_surface, |
| 871 cv_pixel_buffer, |
| 872 contents_rect, |
| 873 rect, |
| 874 background_color, |
| 875 edge_aa_mask, |
| 876 opacity); |
| 877 EXPECT_TRUE(result); |
| 878 new_ca_layer_tree->CommitScheduledCALayers( |
| 879 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 880 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 881 |
| 882 // Validate the tree structure. |
| 883 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 884 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 885 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 886 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 887 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 888 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 889 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 890 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; |
| 891 |
| 892 // Validate the content layer. |
| 893 EXPECT_TRUE([content_layer2 |
| 894 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 895 EXPECT_NE(content_layer2, content_layer1); |
| 896 } |
| 897 |
| 898 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 899 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 900 cv_pixel_buffer.reset(); |
| 824 | 901 |
| 825 // Pass a frame that is clipped. | 902 // Pass a frame that is clipped. |
| 826 contents_rect = gfx::RectF(0, 0, 1, 0.9); | 903 contents_rect = gfx::RectF(0, 0, 1, 0.9); |
| 827 { | 904 { |
| 828 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 905 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); |
| 829 result = new_ca_layer_tree->ScheduleCALayer( | 906 result = new_ca_layer_tree->ScheduleCALayer( |
| 830 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 907 is_clipped, |
| 831 contents_rect, rect, background_color, edge_aa_mask, opacity); | 908 clip_rect, |
| 909 sorting_context_id, |
| 910 transform, |
| 911 io_surface, |
| 912 nullptr, |
| 913 contents_rect, |
| 914 rect, |
| 915 background_color, |
| 916 edge_aa_mask, |
| 917 opacity); |
| 832 EXPECT_TRUE(result); | 918 EXPECT_TRUE(result); |
| 833 new_ca_layer_tree->CommitScheduledCALayers( | 919 new_ca_layer_tree->CommitScheduledCALayers( |
| 834 superlayer_, std::move(ca_layer_tree), scale_factor); | 920 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 835 std::swap(new_ca_layer_tree, ca_layer_tree); | 921 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 836 | 922 |
| 837 // Validate the tree structure. | 923 // Validate the tree structure. |
| 838 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 924 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 839 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 925 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 840 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 926 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 841 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 927 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 842 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 928 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 843 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 929 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 844 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 930 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 845 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; | 931 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; |
| 846 | 932 |
| 847 // Validate the content layer. | 933 // Validate the content layer. |
| 848 EXPECT_FALSE([content_layer3 | 934 EXPECT_FALSE([content_layer3 |
| 849 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 935 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 850 EXPECT_EQ(content_layer3, content_layer2); | 936 EXPECT_NE(content_layer3, content_layer2); |
| 851 } | 937 } |
| 852 } | 938 } |
| 853 | 939 |
| 854 } // namespace gpu | 940 } // namespace gpu |
| OLD | NEW |