| 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" |
| 11 #include "ui/accelerated_widget_mac/ca_layer_tree_mac.h" | 11 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" |
| 12 #include "ui/gfx/geometry/dip_util.h" | 12 #include "ui/gfx/geometry/dip_util.h" |
| 13 #include "ui/gfx/mac/io_surface.h" | 13 #include "ui/gfx/mac/io_surface.h" |
| 14 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 | 16 |
| 17 class CALayerTreeTest : public testing::Test { | 17 class CALayerTreeTest : public testing::Test { |
| 18 protected: | 18 protected: |
| 19 void SetUp() override { | 19 void SetUp() override { |
| 20 superlayer_.reset([[CALayer alloc] init]); | 20 superlayer_.reset([[CALayer alloc] init]); |
| 21 } | 21 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 gfx::Transform transform; | 33 gfx::Transform transform; |
| 34 transform.Translate(10, 20); | 34 transform.Translate(10, 20); |
| 35 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f); | 35 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f); |
| 36 gfx::Rect rect(16, 32, 64, 128); | 36 gfx::Rect rect(16, 32, 64, 128); |
| 37 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 37 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 38 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 38 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 39 float opacity = 0.5f; | 39 float opacity = 0.5f; |
| 40 float scale_factor = 1.0f; | 40 float scale_factor = 1.0f; |
| 41 bool result = false; | 41 bool result = false; |
| 42 | 42 |
| 43 std::unique_ptr<ui::CALayerTree> ca_layer_tree; | 43 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 44 CALayer* root_layer = nil; | 44 CALayer* root_layer = nil; |
| 45 CALayer* clip_and_sorting_layer = nil; | 45 CALayer* clip_and_sorting_layer = nil; |
| 46 CALayer* transform_layer = nil; | 46 CALayer* transform_layer = nil; |
| 47 CALayer* content_layer = nil; | 47 CALayer* content_layer = nil; |
| 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::CARendererLayerTree> new_ca_layer_tree( |
| 52 new ui::CARendererLayerTree); |
| 52 result = new_ca_layer_tree->ScheduleCALayer( | 53 result = new_ca_layer_tree->ScheduleCALayer( |
| 53 is_clipped, | 54 is_clipped, |
| 54 clip_rect, | 55 clip_rect, |
| 55 sorting_context_id, | 56 sorting_context_id, |
| 56 transform, | 57 transform, |
| 57 io_surface, | 58 io_surface, |
| 58 nullptr, | 59 nullptr, |
| 59 contents_rect, | 60 contents_rect, |
| 60 rect, | 61 rect, |
| 61 background_color, | 62 background_color, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); | 101 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); |
| 101 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); | 102 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); |
| 102 EXPECT_EQ(opacity, [content_layer opacity]); | 103 EXPECT_EQ(opacity, [content_layer opacity]); |
| 103 if ([content_layer respondsToSelector:(@selector(contentsScale))]) | 104 if ([content_layer respondsToSelector:(@selector(contentsScale))]) |
| 104 EXPECT_EQ(scale_factor, [content_layer contentsScale]); | 105 EXPECT_EQ(scale_factor, [content_layer contentsScale]); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // Update just the clip rect and re-commit. | 108 // Update just the clip rect and re-commit. |
| 108 { | 109 { |
| 109 clip_rect = gfx::Rect(4, 8, 16, 32); | 110 clip_rect = gfx::Rect(4, 8, 16, 32); |
| 110 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 111 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 112 new ui::CARendererLayerTree); |
| 111 result = new_ca_layer_tree->ScheduleCALayer( | 113 result = new_ca_layer_tree->ScheduleCALayer( |
| 112 is_clipped, | 114 is_clipped, |
| 113 clip_rect, | 115 clip_rect, |
| 114 sorting_context_id, | 116 sorting_context_id, |
| 115 transform, | 117 transform, |
| 116 io_surface, | 118 io_surface, |
| 117 nullptr, | 119 nullptr, |
| 118 contents_rect, | 120 contents_rect, |
| 119 rect, | 121 rect, |
| 120 background_color, | 122 background_color, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 142 gfx::Point([clip_and_sorting_layer position])); | 144 gfx::Point([clip_and_sorting_layer position])); |
| 143 EXPECT_EQ(-clip_rect.origin().x(), | 145 EXPECT_EQ(-clip_rect.origin().x(), |
| 144 [clip_and_sorting_layer sublayerTransform].m41); | 146 [clip_and_sorting_layer sublayerTransform].m41); |
| 145 EXPECT_EQ(-clip_rect.origin().y(), | 147 EXPECT_EQ(-clip_rect.origin().y(), |
| 146 [clip_and_sorting_layer sublayerTransform].m42); | 148 [clip_and_sorting_layer sublayerTransform].m42); |
| 147 } | 149 } |
| 148 | 150 |
| 149 // Disable clipping and re-commit. | 151 // Disable clipping and re-commit. |
| 150 { | 152 { |
| 151 is_clipped = false; | 153 is_clipped = false; |
| 152 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 154 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 155 new ui::CARendererLayerTree); |
| 153 result = new_ca_layer_tree->ScheduleCALayer( | 156 result = new_ca_layer_tree->ScheduleCALayer( |
| 154 is_clipped, | 157 is_clipped, |
| 155 clip_rect, | 158 clip_rect, |
| 156 sorting_context_id, | 159 sorting_context_id, |
| 157 transform, | 160 transform, |
| 158 io_surface, | 161 io_surface, |
| 159 nullptr, | 162 nullptr, |
| 160 contents_rect, | 163 contents_rect, |
| 161 rect, | 164 rect, |
| 162 background_color, | 165 background_color, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 181 EXPECT_EQ(gfx::Rect(), gfx::Rect([clip_and_sorting_layer bounds])); | 184 EXPECT_EQ(gfx::Rect(), gfx::Rect([clip_and_sorting_layer bounds])); |
| 182 EXPECT_EQ(gfx::Point(), gfx::Point([clip_and_sorting_layer position])); | 185 EXPECT_EQ(gfx::Point(), gfx::Point([clip_and_sorting_layer position])); |
| 183 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m41); | 186 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m41); |
| 184 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m42); | 187 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m42); |
| 185 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 188 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 186 } | 189 } |
| 187 | 190 |
| 188 // Change the transform and re-commit. | 191 // Change the transform and re-commit. |
| 189 { | 192 { |
| 190 transform.Translate(5, 5); | 193 transform.Translate(5, 5); |
| 191 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 194 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 195 new ui::CARendererLayerTree); |
| 192 result = new_ca_layer_tree->ScheduleCALayer( | 196 result = new_ca_layer_tree->ScheduleCALayer( |
| 193 is_clipped, | 197 is_clipped, |
| 194 clip_rect, | 198 clip_rect, |
| 195 sorting_context_id, | 199 sorting_context_id, |
| 196 transform, | 200 transform, |
| 197 io_surface, | 201 io_surface, |
| 198 nullptr, | 202 nullptr, |
| 199 contents_rect, | 203 contents_rect, |
| 200 rect, | 204 rect, |
| 201 background_color, | 205 background_color, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 218 // Validate the transform layer. | 222 // Validate the transform layer. |
| 219 EXPECT_EQ(transform.matrix().get(3, 0), | 223 EXPECT_EQ(transform.matrix().get(3, 0), |
| 220 [transform_layer sublayerTransform].m41); | 224 [transform_layer sublayerTransform].m41); |
| 221 EXPECT_EQ(transform.matrix().get(3, 1), | 225 EXPECT_EQ(transform.matrix().get(3, 1), |
| 222 [transform_layer sublayerTransform].m42); | 226 [transform_layer sublayerTransform].m42); |
| 223 } | 227 } |
| 224 | 228 |
| 225 // Change the edge antialiasing mask and commit. | 229 // Change the edge antialiasing mask and commit. |
| 226 { | 230 { |
| 227 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM; | 231 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM; |
| 228 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 232 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 233 new ui::CARendererLayerTree); |
| 229 result = new_ca_layer_tree->ScheduleCALayer( | 234 result = new_ca_layer_tree->ScheduleCALayer( |
| 230 is_clipped, | 235 is_clipped, |
| 231 clip_rect, | 236 clip_rect, |
| 232 sorting_context_id, | 237 sorting_context_id, |
| 233 transform, | 238 transform, |
| 234 io_surface, | 239 io_surface, |
| 235 nullptr, | 240 nullptr, |
| 236 contents_rect, | 241 contents_rect, |
| 237 rect, | 242 rect, |
| 238 background_color, | 243 background_color, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 253 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); | 258 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| 254 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 259 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 255 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 260 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 256 | 261 |
| 257 // Validate the content layer. Note that top and bottom edges flip. | 262 // Validate the content layer. Note that top and bottom edges flip. |
| 258 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); | 263 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); |
| 259 } | 264 } |
| 260 | 265 |
| 261 // Change the contents and commit. | 266 // Change the contents and commit. |
| 262 { | 267 { |
| 263 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 268 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 269 new ui::CARendererLayerTree); |
| 264 result = new_ca_layer_tree->ScheduleCALayer( | 270 result = new_ca_layer_tree->ScheduleCALayer( |
| 265 is_clipped, | 271 is_clipped, |
| 266 clip_rect, | 272 clip_rect, |
| 267 sorting_context_id, | 273 sorting_context_id, |
| 268 transform, | 274 transform, |
| 269 nullptr, | 275 nullptr, |
| 270 nullptr, | 276 nullptr, |
| 271 contents_rect, | 277 contents_rect, |
| 272 rect, | 278 rect, |
| 273 background_color, | 279 background_color, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 290 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 296 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 291 | 297 |
| 292 // Validate the content layer. Note that edge anti-aliasing no longer flips. | 298 // Validate the content layer. Note that edge anti-aliasing no longer flips. |
| 293 EXPECT_EQ(nil, [content_layer contents]); | 299 EXPECT_EQ(nil, [content_layer contents]); |
| 294 EXPECT_EQ(kCALayerTopEdge, [content_layer edgeAntialiasingMask]); | 300 EXPECT_EQ(kCALayerTopEdge, [content_layer edgeAntialiasingMask]); |
| 295 } | 301 } |
| 296 | 302 |
| 297 // Change the rect size. | 303 // Change the rect size. |
| 298 { | 304 { |
| 299 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16)); | 305 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16)); |
| 300 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 306 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 307 new ui::CARendererLayerTree); |
| 301 result = new_ca_layer_tree->ScheduleCALayer( | 308 result = new_ca_layer_tree->ScheduleCALayer( |
| 302 is_clipped, | 309 is_clipped, |
| 303 clip_rect, | 310 clip_rect, |
| 304 sorting_context_id, | 311 sorting_context_id, |
| 305 transform, | 312 transform, |
| 306 nullptr, | 313 nullptr, |
| 307 nullptr, | 314 nullptr, |
| 308 contents_rect, | 315 contents_rect, |
| 309 rect, | 316 rect, |
| 310 background_color, | 317 background_color, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 327 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 334 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 328 | 335 |
| 329 // Validate the content layer. | 336 // Validate the content layer. |
| 330 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); | 337 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); |
| 331 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); | 338 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); |
| 332 } | 339 } |
| 333 | 340 |
| 334 // Change the rect position. | 341 // Change the rect position. |
| 335 { | 342 { |
| 336 rect = gfx::Rect(gfx::Point(16, 4), rect.size()); | 343 rect = gfx::Rect(gfx::Point(16, 4), rect.size()); |
| 337 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 344 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 345 new ui::CARendererLayerTree); |
| 338 result = new_ca_layer_tree->ScheduleCALayer( | 346 result = new_ca_layer_tree->ScheduleCALayer( |
| 339 is_clipped, | 347 is_clipped, |
| 340 clip_rect, | 348 clip_rect, |
| 341 sorting_context_id, | 349 sorting_context_id, |
| 342 transform, | 350 transform, |
| 343 nullptr, | 351 nullptr, |
| 344 nullptr, | 352 nullptr, |
| 345 contents_rect, | 353 contents_rect, |
| 346 rect, | 354 rect, |
| 347 background_color, | 355 background_color, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 364 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 372 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 365 | 373 |
| 366 // Validate the content layer. | 374 // Validate the content layer. |
| 367 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); | 375 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); |
| 368 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); | 376 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); |
| 369 } | 377 } |
| 370 | 378 |
| 371 // Change the opacity. | 379 // Change the opacity. |
| 372 { | 380 { |
| 373 opacity = 1.0f; | 381 opacity = 1.0f; |
| 374 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 382 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 383 new ui::CARendererLayerTree); |
| 375 result = new_ca_layer_tree->ScheduleCALayer( | 384 result = new_ca_layer_tree->ScheduleCALayer( |
| 376 is_clipped, | 385 is_clipped, |
| 377 clip_rect, | 386 clip_rect, |
| 378 sorting_context_id, | 387 sorting_context_id, |
| 379 transform, | 388 transform, |
| 380 nullptr, | 389 nullptr, |
| 381 nullptr, | 390 nullptr, |
| 382 contents_rect, | 391 contents_rect, |
| 383 rect, | 392 rect, |
| 384 background_color, | 393 background_color, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 400 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 409 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 401 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 410 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 402 | 411 |
| 403 // Validate the content layer. | 412 // Validate the content layer. |
| 404 EXPECT_EQ(opacity, [content_layer opacity]); | 413 EXPECT_EQ(opacity, [content_layer opacity]); |
| 405 } | 414 } |
| 406 | 415 |
| 407 // Add the clipping and IOSurface contents back. | 416 // Add the clipping and IOSurface contents back. |
| 408 { | 417 { |
| 409 is_clipped = true; | 418 is_clipped = true; |
| 410 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 419 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 420 new ui::CARendererLayerTree); |
| 411 result = new_ca_layer_tree->ScheduleCALayer( | 421 result = new_ca_layer_tree->ScheduleCALayer( |
| 412 is_clipped, | 422 is_clipped, |
| 413 clip_rect, | 423 clip_rect, |
| 414 sorting_context_id, | 424 sorting_context_id, |
| 415 transform, | 425 transform, |
| 416 io_surface, | 426 io_surface, |
| 417 nullptr, | 427 nullptr, |
| 418 contents_rect, | 428 contents_rect, |
| 419 rect, | 429 rect, |
| 420 background_color, | 430 background_color, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 437 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 447 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 438 | 448 |
| 439 // Validate the content layer. | 449 // Validate the content layer. |
| 440 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]); | 450 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]); |
| 441 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); | 451 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); |
| 442 } | 452 } |
| 443 | 453 |
| 444 // Change the scale factor. This should result in a new tree being created. | 454 // Change the scale factor. This should result in a new tree being created. |
| 445 { | 455 { |
| 446 scale_factor = 2.0f; | 456 scale_factor = 2.0f; |
| 447 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 457 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 458 new ui::CARendererLayerTree); |
| 448 result = new_ca_layer_tree->ScheduleCALayer( | 459 result = new_ca_layer_tree->ScheduleCALayer( |
| 449 is_clipped, | 460 is_clipped, |
| 450 clip_rect, | 461 clip_rect, |
| 451 sorting_context_id, | 462 sorting_context_id, |
| 452 transform, | 463 transform, |
| 453 io_surface, | 464 io_surface, |
| 454 nullptr, | 465 nullptr, |
| 455 contents_rect, | 466 contents_rect, |
| 456 rect, | 467 rect, |
| 457 background_color, | 468 background_color, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // * 1 non-flat (new sorting context layer) | 543 // * 1 non-flat (new sorting context layer) |
| 533 // * 2 flat and the same (new sorting context layer, 1 transform layer) | 544 // * 2 flat and the same (new sorting context layer, 1 transform layer) |
| 534 gfx::Transform transforms[5]; | 545 gfx::Transform transforms[5]; |
| 535 transforms[0].Translate(10, 10); | 546 transforms[0].Translate(10, 10); |
| 536 transforms[1].RotateAboutZAxis(45.0f); | 547 transforms[1].RotateAboutZAxis(45.0f); |
| 537 transforms[2].RotateAboutYAxis(45.0f); | 548 transforms[2].RotateAboutYAxis(45.0f); |
| 538 transforms[3].Translate(10, 10); | 549 transforms[3].Translate(10, 10); |
| 539 transforms[4].Translate(10, 10); | 550 transforms[4].Translate(10, 10); |
| 540 | 551 |
| 541 // Schedule and commit the layers. | 552 // Schedule and commit the layers. |
| 542 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); | 553 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 554 new ui::CARendererLayerTree); |
| 543 for (size_t i = 0; i < 5; ++i) { | 555 for (size_t i = 0; i < 5; ++i) { |
| 544 bool result = ca_layer_tree->ScheduleCALayer( | 556 bool result = ca_layer_tree->ScheduleCALayer( |
| 545 is_clipped, | 557 is_clipped, |
| 546 clip_rect, | 558 clip_rect, |
| 547 sorting_context_id, | 559 sorting_context_id, |
| 548 transforms[i], | 560 transforms[i], |
| 549 io_surfaces[i], | 561 io_surfaces[i], |
| 550 nullptr, | 562 nullptr, |
| 551 contents_rect, | 563 contents_rect, |
| 552 rect, | 564 rect, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 float scale_factor = 1.0f; | 630 float scale_factor = 1.0f; |
| 619 | 631 |
| 620 // We'll use the IOSurface contents to identify the content layers. | 632 // We'll use the IOSurface contents to identify the content layers. |
| 621 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; | 633 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; |
| 622 for (size_t i = 0; i < 3; ++i) { | 634 for (size_t i = 0; i < 3; ++i) { |
| 623 io_surfaces[i].reset(gfx::CreateIOSurface( | 635 io_surfaces[i].reset(gfx::CreateIOSurface( |
| 624 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 636 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); |
| 625 } | 637 } |
| 626 | 638 |
| 627 // Schedule and commit the layers. | 639 // Schedule and commit the layers. |
| 628 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); | 640 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 641 new ui::CARendererLayerTree); |
| 629 for (size_t i = 0; i < 3; ++i) { | 642 for (size_t i = 0; i < 3; ++i) { |
| 630 bool result = ca_layer_tree->ScheduleCALayer( | 643 bool result = ca_layer_tree->ScheduleCALayer( |
| 631 is_clipped, | 644 is_clipped, |
| 632 clip_rect, | 645 clip_rect, |
| 633 sorting_context_ids[i], | 646 sorting_context_ids[i], |
| 634 transform, | 647 transform, |
| 635 io_surfaces[i], | 648 io_surfaces[i], |
| 636 nullptr, | 649 nullptr, |
| 637 contents_rect, | 650 contents_rect, |
| 638 rect, | 651 rect, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 float opacity = 1.0f; | 702 float opacity = 1.0f; |
| 690 | 703 |
| 691 // Vary the clipping parameters within sorting contexts. | 704 // Vary the clipping parameters within sorting contexts. |
| 692 bool is_clippeds[3] = { true, true, false}; | 705 bool is_clippeds[3] = { true, true, false}; |
| 693 gfx::Rect clip_rects[3] = { | 706 gfx::Rect clip_rects[3] = { |
| 694 gfx::Rect(0, 0, 16, 16), | 707 gfx::Rect(0, 0, 16, 16), |
| 695 gfx::Rect(4, 8, 16, 32), | 708 gfx::Rect(4, 8, 16, 32), |
| 696 gfx::Rect(0, 0, 16, 16) | 709 gfx::Rect(0, 0, 16, 16) |
| 697 }; | 710 }; |
| 698 | 711 |
| 699 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree); | 712 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 713 new ui::CARendererLayerTree); |
| 700 // First send the various clip parameters to sorting context zero. This is | 714 // First send the various clip parameters to sorting context zero. This is |
| 701 // legitimate. | 715 // legitimate. |
| 702 for (size_t i = 0; i < 3; ++i) { | 716 for (size_t i = 0; i < 3; ++i) { |
| 703 int sorting_context_id = 0; | 717 int sorting_context_id = 0; |
| 704 bool result = ca_layer_tree->ScheduleCALayer( | 718 bool result = ca_layer_tree->ScheduleCALayer( |
| 705 is_clippeds[i], | 719 is_clippeds[i], |
| 706 clip_rects[i], | 720 clip_rects[i], |
| 707 sorting_context_id, | 721 sorting_context_id, |
| 708 transform, | 722 transform, |
| 709 io_surface, | 723 io_surface, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 int sorting_context_id = 0; | 779 int sorting_context_id = 0; |
| 766 gfx::Transform transform; | 780 gfx::Transform transform; |
| 767 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); | 781 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); |
| 768 gfx::Rect rect(16, 32, 64, 128); | 782 gfx::Rect rect(16, 32, 64, 128); |
| 769 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 783 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 770 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 784 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 771 float opacity = 0.5f; | 785 float opacity = 0.5f; |
| 772 float scale_factor = 1.0f; | 786 float scale_factor = 1.0f; |
| 773 bool result = false; | 787 bool result = false; |
| 774 | 788 |
| 775 std::unique_ptr<ui::CALayerTree> ca_layer_tree; | 789 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 776 CALayer* root_layer = nil; | 790 CALayer* root_layer = nil; |
| 777 CALayer* clip_and_sorting_layer = nil; | 791 CALayer* clip_and_sorting_layer = nil; |
| 778 CALayer* transform_layer = nil; | 792 CALayer* transform_layer = nil; |
| 779 CALayer* content_layer1 = nil; | 793 CALayer* content_layer1 = nil; |
| 780 CALayer* content_layer2 = nil; | 794 CALayer* content_layer2 = nil; |
| 781 CALayer* content_layer3 = nil; | 795 CALayer* content_layer3 = nil; |
| 782 | 796 |
| 783 // Validate the initial values. | 797 // Validate the initial values. |
| 784 { | 798 { |
| 785 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 799 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 800 new ui::CARendererLayerTree); |
| 786 result = new_ca_layer_tree->ScheduleCALayer( | 801 result = new_ca_layer_tree->ScheduleCALayer( |
| 787 is_clipped, | 802 is_clipped, |
| 788 clip_rect, | 803 clip_rect, |
| 789 sorting_context_id, | 804 sorting_context_id, |
| 790 transform, | 805 transform, |
| 791 io_surface, | 806 io_surface, |
| 792 nullptr, | 807 nullptr, |
| 793 contents_rect, | 808 contents_rect, |
| 794 rect, background_color, | 809 rect, background_color, |
| 795 edge_aa_mask, | 810 edge_aa_mask, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 812 // Validate the content layer. | 827 // Validate the content layer. |
| 813 EXPECT_FALSE([content_layer1 | 828 EXPECT_FALSE([content_layer1 |
| 814 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 829 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 815 } | 830 } |
| 816 | 831 |
| 817 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), | 832 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 818 gfx::BufferFormat::YUV_420_BIPLANAR)); | 833 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 819 | 834 |
| 820 // Pass another frame. | 835 // Pass another frame. |
| 821 { | 836 { |
| 822 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 837 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 838 new ui::CARendererLayerTree); |
| 823 result = new_ca_layer_tree->ScheduleCALayer( | 839 result = new_ca_layer_tree->ScheduleCALayer( |
| 824 is_clipped, | 840 is_clipped, |
| 825 clip_rect, | 841 clip_rect, |
| 826 sorting_context_id, | 842 sorting_context_id, |
| 827 transform, | 843 transform, |
| 828 io_surface, | 844 io_surface, |
| 829 nullptr, | 845 nullptr, |
| 830 contents_rect, | 846 contents_rect, |
| 831 rect, | 847 rect, |
| 832 background_color, | 848 background_color, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 854 } | 870 } |
| 855 | 871 |
| 856 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), | 872 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 857 gfx::BufferFormat::YUV_420_BIPLANAR)); | 873 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 858 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; | 874 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; |
| 859 CVPixelBufferCreateWithIOSurface( | 875 CVPixelBufferCreateWithIOSurface( |
| 860 nullptr, io_surface, nullptr, cv_pixel_buffer.InitializeInto()); | 876 nullptr, io_surface, nullptr, cv_pixel_buffer.InitializeInto()); |
| 861 | 877 |
| 862 // Pass a frame with a CVPixelBuffer | 878 // Pass a frame with a CVPixelBuffer |
| 863 { | 879 { |
| 864 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 880 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 881 new ui::CARendererLayerTree); |
| 865 result = new_ca_layer_tree->ScheduleCALayer( | 882 result = new_ca_layer_tree->ScheduleCALayer( |
| 866 is_clipped, | 883 is_clipped, |
| 867 clip_rect, | 884 clip_rect, |
| 868 sorting_context_id, | 885 sorting_context_id, |
| 869 transform, | 886 transform, |
| 870 io_surface, | 887 io_surface, |
| 871 cv_pixel_buffer, | 888 cv_pixel_buffer, |
| 872 contents_rect, | 889 contents_rect, |
| 873 rect, | 890 rect, |
| 874 background_color, | 891 background_color, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 895 EXPECT_NE(content_layer2, content_layer1); | 912 EXPECT_NE(content_layer2, content_layer1); |
| 896 } | 913 } |
| 897 | 914 |
| 898 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), | 915 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), |
| 899 gfx::BufferFormat::YUV_420_BIPLANAR)); | 916 gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 900 cv_pixel_buffer.reset(); | 917 cv_pixel_buffer.reset(); |
| 901 | 918 |
| 902 // Pass a frame that is clipped. | 919 // Pass a frame that is clipped. |
| 903 contents_rect = gfx::RectF(0, 0, 1, 0.9); | 920 contents_rect = gfx::RectF(0, 0, 1, 0.9); |
| 904 { | 921 { |
| 905 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree); | 922 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 923 new ui::CARendererLayerTree); |
| 906 result = new_ca_layer_tree->ScheduleCALayer( | 924 result = new_ca_layer_tree->ScheduleCALayer( |
| 907 is_clipped, | 925 is_clipped, |
| 908 clip_rect, | 926 clip_rect, |
| 909 sorting_context_id, | 927 sorting_context_id, |
| 910 transform, | 928 transform, |
| 911 io_surface, | 929 io_surface, |
| 912 nullptr, | 930 nullptr, |
| 913 contents_rect, | 931 contents_rect, |
| 914 rect, | 932 rect, |
| 915 background_color, | 933 background_color, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 931 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; | 949 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; |
| 932 | 950 |
| 933 // Validate the content layer. | 951 // Validate the content layer. |
| 934 EXPECT_FALSE([content_layer3 | 952 EXPECT_FALSE([content_layer3 |
| 935 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 953 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 936 EXPECT_NE(content_layer3, content_layer2); | 954 EXPECT_NE(content_layer3, content_layer2); |
| 937 } | 955 } |
| 938 } | 956 } |
| 939 | 957 |
| 940 } // namespace gpu | 958 } // namespace gpu |
| OLD | NEW |