| 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 <AVFoundation/AVFoundation.h> | 5 #include <AVFoundation/AVFoundation.h> |
| 6 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "base/mac/sdk_forward_declarations.h" | 8 #include "base/mac/sdk_forward_declarations.h" |
| 9 #include "gpu/GLES2/gl2extchromium.h" | 9 #include "gpu/GLES2/gl2extchromium.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/gtest_mac.h" | 11 #include "testing/gtest_mac.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" | 13 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" |
| 14 #include "ui/gfx/geometry/dip_util.h" | 14 #include "ui/gfx/geometry/dip_util.h" |
| 15 #include "ui/gfx/mac/io_surface.h" | 15 #include "ui/gfx/mac/io_surface.h" |
| 16 #include "ui/gl/ca_renderer_layer_params.h" |
| 17 #include "ui/gl/gl_image_io_surface.h" |
| 16 | 18 |
| 17 namespace gpu { | 19 namespace gpu { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 struct CALayerProperties { | 23 struct CALayerProperties { |
| 24 CALayerProperties() {} |
| 25 ~CALayerProperties() { |
| 26 if (gl_image) |
| 27 gl_image->Destroy(true); |
| 28 } |
| 29 |
| 22 bool is_clipped = true; | 30 bool is_clipped = true; |
| 23 gfx::Rect clip_rect; | 31 gfx::Rect clip_rect; |
| 24 int sorting_context_id = 0; | 32 int sorting_context_id = 0; |
| 25 gfx::Transform transform; | 33 gfx::Transform transform; |
| 26 gfx::RectF contents_rect = gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f); | 34 gfx::RectF contents_rect = gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f); |
| 27 gfx::Rect rect = gfx::Rect(0, 0, 256, 256); | 35 gfx::Rect rect = gfx::Rect(0, 0, 256, 256); |
| 28 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); | 36 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); |
| 29 unsigned edge_aa_mask = 0; | 37 unsigned edge_aa_mask = 0; |
| 30 float opacity = 1.0f; | 38 float opacity = 1.0f; |
| 31 float scale_factor = 1.0f; | 39 float scale_factor = 1.0f; |
| 32 unsigned filter = GL_LINEAR; | 40 unsigned filter = GL_LINEAR; |
| 33 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; | 41 scoped_refptr<gl::GLImageIOSurface> gl_image; |
| 34 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | |
| 35 }; | 42 }; |
| 36 | 43 |
| 44 scoped_refptr<gl::GLImageIOSurface> CreateGLImage(const gfx::Size& size, |
| 45 gfx::BufferFormat format, |
| 46 bool video) { |
| 47 scoped_refptr<gl::GLImageIOSurface> gl_image( |
| 48 new gl::GLImageIOSurface(size, GL_RGBA)); |
| 49 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
| 50 gfx::CreateIOSurface(size, format)); |
| 51 if (video) { |
| 52 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; |
| 53 CVPixelBufferCreateWithIOSurface(nullptr, io_surface, nullptr, |
| 54 cv_pixel_buffer.InitializeInto()); |
| 55 gl_image->InitializeWithCVPixelBuffer(cv_pixel_buffer, |
| 56 gfx::GenericSharedMemoryId(), format); |
| 57 } else { |
| 58 gl_image->Initialize(io_surface, gfx::GenericSharedMemoryId(), format); |
| 59 } |
| 60 return gl_image; |
| 61 } |
| 62 |
| 37 bool ScheduleCALayer(ui::CARendererLayerTree* tree, | 63 bool ScheduleCALayer(ui::CARendererLayerTree* tree, |
| 38 CALayerProperties* properties) { | 64 CALayerProperties* properties) { |
| 39 return tree->ScheduleCALayer( | 65 return tree->ScheduleCALayer(ui::CARendererLayerParams( |
| 40 properties->is_clipped, properties->clip_rect, | 66 properties->is_clipped, properties->clip_rect, |
| 41 properties->sorting_context_id, properties->transform, | 67 properties->sorting_context_id, properties->transform, |
| 42 properties->io_surface, properties->cv_pixel_buffer, | 68 properties->gl_image.get(), properties->contents_rect, properties->rect, |
| 43 properties->contents_rect, properties->rect, properties->background_color, | 69 properties->background_color, properties->edge_aa_mask, |
| 44 properties->edge_aa_mask, properties->opacity, properties->filter); | 70 properties->opacity, properties->filter)); |
| 45 } | 71 } |
| 46 | 72 |
| 47 void UpdateCALayerTree(std::unique_ptr<ui::CARendererLayerTree>& ca_layer_tree, | 73 void UpdateCALayerTree(std::unique_ptr<ui::CARendererLayerTree>& ca_layer_tree, |
| 48 CALayerProperties* properties, | 74 CALayerProperties* properties, |
| 49 CALayer* superlayer) { | 75 CALayer* superlayer) { |
| 50 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 76 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 51 new ui::CARendererLayerTree); | 77 new ui::CARendererLayerTree); |
| 52 bool result = ScheduleCALayer(new_ca_layer_tree.get(), properties); | 78 bool result = ScheduleCALayer(new_ca_layer_tree.get(), properties); |
| 53 EXPECT_TRUE(result); | 79 EXPECT_TRUE(result); |
| 54 new_ca_layer_tree->CommitScheduledCALayers( | 80 new_ca_layer_tree->CommitScheduledCALayers( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 73 // Test updating each layer's properties. | 99 // Test updating each layer's properties. |
| 74 TEST_F(CALayerTreeTest, PropertyUpdates) { | 100 TEST_F(CALayerTreeTest, PropertyUpdates) { |
| 75 CALayerProperties properties; | 101 CALayerProperties properties; |
| 76 properties.clip_rect = gfx::Rect(2, 4, 8, 16); | 102 properties.clip_rect = gfx::Rect(2, 4, 8, 16); |
| 77 properties.transform.Translate(10, 20); | 103 properties.transform.Translate(10, 20); |
| 78 properties.contents_rect = gfx::RectF(0.0f, 0.25f, 0.5f, 0.75f); | 104 properties.contents_rect = gfx::RectF(0.0f, 0.25f, 0.5f, 0.75f); |
| 79 properties.rect = gfx::Rect(16, 32, 64, 128); | 105 properties.rect = gfx::Rect(16, 32, 64, 128); |
| 80 properties.background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 106 properties.background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 81 properties.edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 107 properties.edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 82 properties.opacity = 0.5f; | 108 properties.opacity = 0.5f; |
| 83 properties.io_surface.reset( | 109 properties.gl_image = |
| 84 gfx::CreateIOSurface(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 110 CreateGLImage(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888, false); |
| 85 | 111 |
| 86 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 112 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 87 CALayer* root_layer = nil; | 113 CALayer* root_layer = nil; |
| 88 CALayer* clip_and_sorting_layer = nil; | 114 CALayer* clip_and_sorting_layer = nil; |
| 89 CALayer* transform_layer = nil; | 115 CALayer* transform_layer = nil; |
| 90 CALayer* content_layer = nil; | 116 CALayer* content_layer = nil; |
| 91 | 117 |
| 92 // Validate the initial values. | 118 // Validate the initial values. |
| 93 { | 119 { |
| 94 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 120 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 EXPECT_EQ(-properties.clip_rect.origin().y(), | 143 EXPECT_EQ(-properties.clip_rect.origin().y(), |
| 118 [clip_and_sorting_layer sublayerTransform].m42); | 144 [clip_and_sorting_layer sublayerTransform].m42); |
| 119 | 145 |
| 120 // Validate the transform layer. | 146 // Validate the transform layer. |
| 121 EXPECT_EQ(properties.transform.matrix().get(3, 0), | 147 EXPECT_EQ(properties.transform.matrix().get(3, 0), |
| 122 [transform_layer sublayerTransform].m41); | 148 [transform_layer sublayerTransform].m41); |
| 123 EXPECT_EQ(properties.transform.matrix().get(3, 1), | 149 EXPECT_EQ(properties.transform.matrix().get(3, 1), |
| 124 [transform_layer sublayerTransform].m42); | 150 [transform_layer sublayerTransform].m42); |
| 125 | 151 |
| 126 // Validate the content layer. | 152 // Validate the content layer. |
| 127 EXPECT_EQ(static_cast<id>(properties.io_surface.get()), | 153 EXPECT_EQ(static_cast<id>(properties.gl_image->io_surface().get()), |
| 128 [content_layer contents]); | 154 [content_layer contents]); |
| 129 EXPECT_EQ(properties.contents_rect, | 155 EXPECT_EQ(properties.contents_rect, |
| 130 gfx::RectF([content_layer contentsRect])); | 156 gfx::RectF([content_layer contentsRect])); |
| 131 EXPECT_EQ(properties.rect.origin(), gfx::Point([content_layer position])); | 157 EXPECT_EQ(properties.rect.origin(), gfx::Point([content_layer position])); |
| 132 EXPECT_EQ(gfx::Rect(properties.rect.size()), | 158 EXPECT_EQ(gfx::Rect(properties.rect.size()), |
| 133 gfx::Rect([content_layer bounds])); | 159 gfx::Rect([content_layer bounds])); |
| 134 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); | 160 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); |
| 135 EXPECT_EQ(properties.opacity, [content_layer opacity]); | 161 EXPECT_EQ(properties.opacity, [content_layer opacity]); |
| 136 EXPECT_NSEQ(kCAFilterLinear, [content_layer minificationFilter]); | 162 EXPECT_NSEQ(kCAFilterLinear, [content_layer minificationFilter]); |
| 137 EXPECT_NSEQ(kCAFilterLinear, [content_layer magnificationFilter]); | 163 EXPECT_NSEQ(kCAFilterLinear, [content_layer magnificationFilter]); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); | 250 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| 225 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 251 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 226 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 252 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 227 | 253 |
| 228 // Validate the content layer. Note that top and bottom edges flip. | 254 // Validate the content layer. Note that top and bottom edges flip. |
| 229 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); | 255 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); |
| 230 } | 256 } |
| 231 | 257 |
| 232 // Change the contents and commit. | 258 // Change the contents and commit. |
| 233 { | 259 { |
| 234 properties.io_surface.reset(); | 260 properties.gl_image->Destroy(true); |
| 261 properties.gl_image = nullptr; |
| 235 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 262 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 236 | 263 |
| 237 // Validate the tree structure. | 264 // Validate the tree structure. |
| 238 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 265 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 239 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 266 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 240 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 267 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 241 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 268 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| 242 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 269 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 243 EXPECT_EQ(transform_layer, | 270 EXPECT_EQ(transform_layer, |
| 244 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); | 271 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 358 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 332 | 359 |
| 333 // Validate the content layer. | 360 // Validate the content layer. |
| 334 EXPECT_NSEQ(kCAFilterNearest, [content_layer minificationFilter]); | 361 EXPECT_NSEQ(kCAFilterNearest, [content_layer minificationFilter]); |
| 335 EXPECT_NSEQ(kCAFilterNearest, [content_layer magnificationFilter]); | 362 EXPECT_NSEQ(kCAFilterNearest, [content_layer magnificationFilter]); |
| 336 } | 363 } |
| 337 | 364 |
| 338 // Add the clipping and IOSurface contents back. | 365 // Add the clipping and IOSurface contents back. |
| 339 { | 366 { |
| 340 properties.is_clipped = true; | 367 properties.is_clipped = true; |
| 341 properties.io_surface.reset( | 368 properties.gl_image = |
| 342 gfx::CreateIOSurface(gfx::Size(256, 256), | 369 CreateGLImage(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888, false); |
| 343 gfx::BufferFormat::BGRA_8888)); | |
| 344 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 370 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 345 | 371 |
| 346 // Validate the tree structure. | 372 // Validate the tree structure. |
| 347 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 373 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 348 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 374 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 349 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 375 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 350 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 376 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| 351 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 377 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 352 EXPECT_EQ(transform_layer, | 378 EXPECT_EQ(transform_layer, |
| 353 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); | 379 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| 354 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 380 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 355 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 381 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 356 | 382 |
| 357 // Validate the content layer. | 383 // Validate the content layer. |
| 358 EXPECT_EQ(static_cast<id>(properties.io_surface.get()), | 384 EXPECT_EQ(static_cast<id>(properties.gl_image->io_surface().get()), |
| 359 [content_layer contents]); | 385 [content_layer contents]); |
| 360 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); | 386 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); |
| 361 } | 387 } |
| 362 | 388 |
| 363 // Change the scale factor. This should result in a new tree being created. | 389 // Change the scale factor. This should result in a new tree being created. |
| 364 { | 390 { |
| 365 properties.scale_factor = 2.0f; | 391 properties.scale_factor = 2.0f; |
| 366 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 392 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 367 | 393 |
| 368 // Validate the tree structure. | 394 // Validate the tree structure. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 393 EXPECT_EQ(-properties.clip_rect.origin().y() / properties.scale_factor, | 419 EXPECT_EQ(-properties.clip_rect.origin().y() / properties.scale_factor, |
| 394 [clip_and_sorting_layer sublayerTransform].m42); | 420 [clip_and_sorting_layer sublayerTransform].m42); |
| 395 | 421 |
| 396 // Validate the transform layer. | 422 // Validate the transform layer. |
| 397 EXPECT_EQ(properties.transform.matrix().get(3, 0) / properties.scale_factor, | 423 EXPECT_EQ(properties.transform.matrix().get(3, 0) / properties.scale_factor, |
| 398 [transform_layer sublayerTransform].m41); | 424 [transform_layer sublayerTransform].m41); |
| 399 EXPECT_EQ(properties.transform.matrix().get(3, 1) / properties.scale_factor, | 425 EXPECT_EQ(properties.transform.matrix().get(3, 1) / properties.scale_factor, |
| 400 [transform_layer sublayerTransform].m42); | 426 [transform_layer sublayerTransform].m42); |
| 401 | 427 |
| 402 // Validate the content layer. | 428 // Validate the content layer. |
| 403 EXPECT_EQ(static_cast<id>(properties.io_surface.get()), | 429 EXPECT_EQ(static_cast<id>(properties.gl_image->io_surface().get()), |
| 404 [content_layer contents]); | 430 [content_layer contents]); |
| 405 EXPECT_EQ(properties.contents_rect, | 431 EXPECT_EQ(properties.contents_rect, |
| 406 gfx::RectF([content_layer contentsRect])); | 432 gfx::RectF([content_layer contentsRect])); |
| 407 EXPECT_EQ(gfx::ConvertPointToDIP(properties.scale_factor, | 433 EXPECT_EQ(gfx::ConvertPointToDIP(properties.scale_factor, |
| 408 properties.rect.origin()), | 434 properties.rect.origin()), |
| 409 gfx::Point([content_layer position])); | 435 gfx::Point([content_layer position])); |
| 410 EXPECT_EQ(gfx::ConvertRectToDIP(properties.scale_factor, | 436 EXPECT_EQ(gfx::ConvertRectToDIP(properties.scale_factor, |
| 411 gfx::Rect(properties.rect.size())), | 437 gfx::Rect(properties.rect.size())), |
| 412 gfx::Rect([content_layer bounds])); | 438 gfx::Rect([content_layer bounds])); |
| 413 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); | 439 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); |
| 414 EXPECT_EQ(properties.opacity, [content_layer opacity]); | 440 EXPECT_EQ(properties.opacity, [content_layer opacity]); |
| 415 if ([content_layer respondsToSelector:(@selector(contentsScale))]) | 441 if ([content_layer respondsToSelector:(@selector(contentsScale))]) |
| 416 EXPECT_EQ(properties.scale_factor, [content_layer contentsScale]); | 442 EXPECT_EQ(properties.scale_factor, [content_layer contentsScale]); |
| 417 } | 443 } |
| 444 |
| 445 properties.gl_image->Destroy(true); |
| 418 } | 446 } |
| 419 | 447 |
| 420 // Verify that sorting context zero is split at non-flat transforms. | 448 // Verify that sorting context zero is split at non-flat transforms. |
| 421 TEST_F(CALayerTreeTest, SplitSortingContextZero) { | 449 TEST_F(CALayerTreeTest, SplitSortingContextZero) { |
| 422 CALayerProperties properties; | 450 CALayerProperties properties; |
| 423 properties.is_clipped = false; | 451 properties.is_clipped = false; |
| 424 properties.clip_rect = gfx::Rect(); | 452 properties.clip_rect = gfx::Rect(); |
| 425 properties.rect = gfx::Rect(0, 0, 256, 256); | 453 properties.rect = gfx::Rect(0, 0, 256, 256); |
| 426 | 454 |
| 427 // We'll use the IOSurface contents to identify the content layers. | 455 // We'll use the IOSurface contents to identify the content layers. |
| 428 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[5]; | 456 scoped_refptr<gl::GLImageIOSurface> gl_images[5]; |
| 429 for (size_t i = 0; i < 5; ++i) { | 457 for (size_t i = 0; i < 5; ++i) { |
| 430 io_surfaces[i].reset(gfx::CreateIOSurface( | 458 gl_images[i] = |
| 431 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 459 CreateGLImage(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888, false); |
| 432 } | 460 } |
| 433 | 461 |
| 434 // Have 5 transforms: | 462 // Have 5 transforms: |
| 435 // * 2 flat but different (1 sorting context layer, 2 transform layers) | 463 // * 2 flat but different (1 sorting context layer, 2 transform layers) |
| 436 // * 1 non-flat (new sorting context layer) | 464 // * 1 non-flat (new sorting context layer) |
| 437 // * 2 flat and the same (new sorting context layer, 1 transform layer) | 465 // * 2 flat and the same (new sorting context layer, 1 transform layer) |
| 438 gfx::Transform transforms[5]; | 466 gfx::Transform transforms[5]; |
| 439 transforms[0].Translate(10, 10); | 467 transforms[0].Translate(10, 10); |
| 440 transforms[1].RotateAboutZAxis(45.0f); | 468 transforms[1].RotateAboutZAxis(45.0f); |
| 441 transforms[2].RotateAboutYAxis(45.0f); | 469 transforms[2].RotateAboutYAxis(45.0f); |
| 442 transforms[3].Translate(10, 10); | 470 transforms[3].Translate(10, 10); |
| 443 transforms[4].Translate(10, 10); | 471 transforms[4].Translate(10, 10); |
| 444 | 472 |
| 445 // Schedule and commit the layers. | 473 // Schedule and commit the layers. |
| 446 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( | 474 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 447 new ui::CARendererLayerTree); | 475 new ui::CARendererLayerTree); |
| 448 for (size_t i = 0; i < 5; ++i) { | 476 for (size_t i = 0; i < 5; ++i) { |
| 449 properties.io_surface = io_surfaces[i]; | 477 properties.gl_image = gl_images[i]; |
| 450 properties.transform = transforms[i]; | 478 properties.transform = transforms[i]; |
| 451 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); | 479 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); |
| 452 EXPECT_TRUE(result); | 480 EXPECT_TRUE(result); |
| 453 } | 481 } |
| 454 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, | 482 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, |
| 455 properties.scale_factor); | 483 properties.scale_factor); |
| 456 | 484 |
| 457 // Validate the root layer. | 485 // Validate the root layer. |
| 458 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 486 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 459 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 487 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 487 // Validate that the third sorting context has 1 transform layer with two | 515 // Validate that the third sorting context has 1 transform layer with two |
| 488 // content layers. | 516 // content layers. |
| 489 EXPECT_EQ(1u, [[clip_and_sorting_layer_2 sublayers] count]); | 517 EXPECT_EQ(1u, [[clip_and_sorting_layer_2 sublayers] count]); |
| 490 CALayer* transform_layer_2_0 = | 518 CALayer* transform_layer_2_0 = |
| 491 [[clip_and_sorting_layer_2 sublayers] objectAtIndex:0]; | 519 [[clip_and_sorting_layer_2 sublayers] objectAtIndex:0]; |
| 492 EXPECT_EQ(2u, [[transform_layer_2_0 sublayers] count]); | 520 EXPECT_EQ(2u, [[transform_layer_2_0 sublayers] count]); |
| 493 CALayer* content_layer_3 = [[transform_layer_2_0 sublayers] objectAtIndex:0]; | 521 CALayer* content_layer_3 = [[transform_layer_2_0 sublayers] objectAtIndex:0]; |
| 494 CALayer* content_layer_4 = [[transform_layer_2_0 sublayers] objectAtIndex:1]; | 522 CALayer* content_layer_4 = [[transform_layer_2_0 sublayers] objectAtIndex:1]; |
| 495 | 523 |
| 496 // Validate that the layers come out in order. | 524 // Validate that the layers come out in order. |
| 497 EXPECT_EQ(static_cast<id>(io_surfaces[0].get()), [content_layer_0 contents]); | 525 EXPECT_EQ(static_cast<id>(gl_images[0]->io_surface().get()), |
| 498 EXPECT_EQ(static_cast<id>(io_surfaces[1].get()), [content_layer_1 contents]); | 526 [content_layer_0 contents]); |
| 499 EXPECT_EQ(static_cast<id>(io_surfaces[2].get()), [content_layer_2 contents]); | 527 EXPECT_EQ(static_cast<id>(gl_images[1]->io_surface().get()), |
| 500 EXPECT_EQ(static_cast<id>(io_surfaces[3].get()), [content_layer_3 contents]); | 528 [content_layer_1 contents]); |
| 501 EXPECT_EQ(static_cast<id>(io_surfaces[4].get()), [content_layer_4 contents]); | 529 EXPECT_EQ(static_cast<id>(gl_images[2]->io_surface().get()), |
| 530 [content_layer_2 contents]); |
| 531 EXPECT_EQ(static_cast<id>(gl_images[3]->io_surface().get()), |
| 532 [content_layer_3 contents]); |
| 533 EXPECT_EQ(static_cast<id>(gl_images[4]->io_surface().get()), |
| 534 [content_layer_4 contents]); |
| 535 |
| 536 for (size_t i = 0; i < 5; ++i) |
| 537 gl_images[i]->Destroy(true); |
| 502 } | 538 } |
| 503 | 539 |
| 504 // Verify that sorting contexts are allocated appropriately. | 540 // Verify that sorting contexts are allocated appropriately. |
| 505 TEST_F(CALayerTreeTest, SortingContexts) { | 541 TEST_F(CALayerTreeTest, SortingContexts) { |
| 506 CALayerProperties properties; | 542 CALayerProperties properties; |
| 507 properties.is_clipped = false; | 543 properties.is_clipped = false; |
| 508 properties.clip_rect = gfx::Rect(); | 544 properties.clip_rect = gfx::Rect(); |
| 509 properties.rect = gfx::Rect(0, 0, 256, 256); | 545 properties.rect = gfx::Rect(0, 0, 256, 256); |
| 510 | 546 |
| 511 // We'll use the IOSurface contents to identify the content layers. | 547 // We'll use the IOSurface contents to identify the content layers. |
| 512 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; | 548 scoped_refptr<gl::GLImageIOSurface> gl_images[3]; |
| 513 for (size_t i = 0; i < 3; ++i) { | 549 for (size_t i = 0; i < 3; ++i) { |
| 514 io_surfaces[i].reset(gfx::CreateIOSurface( | 550 gl_images[i] = |
| 515 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 551 CreateGLImage(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888, false); |
| 516 } | 552 } |
| 517 | 553 |
| 518 int sorting_context_ids[3] = {3, -1, 0}; | 554 int sorting_context_ids[3] = {3, -1, 0}; |
| 519 | 555 |
| 520 // Schedule and commit the layers. | 556 // Schedule and commit the layers. |
| 521 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( | 557 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 522 new ui::CARendererLayerTree); | 558 new ui::CARendererLayerTree); |
| 523 for (size_t i = 0; i < 3; ++i) { | 559 for (size_t i = 0; i < 3; ++i) { |
| 524 properties.sorting_context_id = sorting_context_ids[i]; | 560 properties.sorting_context_id = sorting_context_ids[i]; |
| 525 properties.io_surface = io_surfaces[i]; | 561 properties.gl_image = gl_images[i]; |
| 526 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); | 562 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); |
| 527 EXPECT_TRUE(result); | 563 EXPECT_TRUE(result); |
| 528 } | 564 } |
| 529 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, | 565 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, |
| 530 properties.scale_factor); | 566 properties.scale_factor); |
| 531 | 567 |
| 532 // Validate the root layer. | 568 // Validate the root layer. |
| 533 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 569 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 534 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 570 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 535 | 571 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 552 | 588 |
| 553 // Validate that each transform has 1 content layer. | 589 // Validate that each transform has 1 content layer. |
| 554 EXPECT_EQ(1u, [[transform_layer_0 sublayers] count]); | 590 EXPECT_EQ(1u, [[transform_layer_0 sublayers] count]); |
| 555 CALayer* content_layer_0 = [[transform_layer_0 sublayers] objectAtIndex:0]; | 591 CALayer* content_layer_0 = [[transform_layer_0 sublayers] objectAtIndex:0]; |
| 556 EXPECT_EQ(1u, [[transform_layer_1 sublayers] count]); | 592 EXPECT_EQ(1u, [[transform_layer_1 sublayers] count]); |
| 557 CALayer* content_layer_1 = [[transform_layer_1 sublayers] objectAtIndex:0]; | 593 CALayer* content_layer_1 = [[transform_layer_1 sublayers] objectAtIndex:0]; |
| 558 EXPECT_EQ(1u, [[transform_layer_2 sublayers] count]); | 594 EXPECT_EQ(1u, [[transform_layer_2 sublayers] count]); |
| 559 CALayer* content_layer_2 = [[transform_layer_2 sublayers] objectAtIndex:0]; | 595 CALayer* content_layer_2 = [[transform_layer_2 sublayers] objectAtIndex:0]; |
| 560 | 596 |
| 561 // Validate that the layers come out in order. | 597 // Validate that the layers come out in order. |
| 562 EXPECT_EQ(static_cast<id>(io_surfaces[0].get()), [content_layer_0 contents]); | 598 EXPECT_EQ(static_cast<id>(gl_images[0]->io_surface().get()), |
| 563 EXPECT_EQ(static_cast<id>(io_surfaces[1].get()), [content_layer_1 contents]); | 599 [content_layer_0 contents]); |
| 564 EXPECT_EQ(static_cast<id>(io_surfaces[2].get()), [content_layer_2 contents]); | 600 EXPECT_EQ(static_cast<id>(gl_images[1]->io_surface().get()), |
| 601 [content_layer_1 contents]); |
| 602 EXPECT_EQ(static_cast<id>(gl_images[2]->io_surface().get()), |
| 603 [content_layer_2 contents]); |
| 604 |
| 605 for (size_t i = 0; i < 3; ++i) |
| 606 gl_images[i]->Destroy(true); |
| 565 } | 607 } |
| 566 | 608 |
| 567 // Verify that sorting contexts must all have the same clipping properties. | 609 // Verify that sorting contexts must all have the same clipping properties. |
| 568 TEST_F(CALayerTreeTest, SortingContextMustHaveConsistentClip) { | 610 TEST_F(CALayerTreeTest, SortingContextMustHaveConsistentClip) { |
| 569 CALayerProperties properties; | 611 CALayerProperties properties; |
| 570 | 612 |
| 571 // Vary the clipping parameters within sorting contexts. | 613 // Vary the clipping parameters within sorting contexts. |
| 572 bool is_clippeds[3] = { true, true, false}; | 614 bool is_clippeds[3] = { true, true, false}; |
| 573 gfx::Rect clip_rects[3] = { | 615 gfx::Rect clip_rects[3] = { |
| 574 gfx::Rect(0, 0, 16, 16), | 616 gfx::Rect(0, 0, 16, 16), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 properties.clip_rect = clip_rects[0]; | 649 properties.clip_rect = clip_rects[0]; |
| 608 | 650 |
| 609 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); | 651 bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); |
| 610 EXPECT_TRUE(result); | 652 EXPECT_TRUE(result); |
| 611 } | 653 } |
| 612 } | 654 } |
| 613 | 655 |
| 614 // Test updating each layer's properties. | 656 // Test updating each layer's properties. |
| 615 TEST_F(CALayerTreeTest, AVLayer) { | 657 TEST_F(CALayerTreeTest, AVLayer) { |
| 616 CALayerProperties properties; | 658 CALayerProperties properties; |
| 617 properties.io_surface.reset(gfx::CreateIOSurface( | 659 properties.gl_image = |
| 618 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 660 CreateGLImage(gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888, false); |
| 619 | 661 |
| 620 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 662 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 621 CALayer* root_layer = nil; | 663 CALayer* root_layer = nil; |
| 622 CALayer* clip_and_sorting_layer = nil; | 664 CALayer* clip_and_sorting_layer = nil; |
| 623 CALayer* transform_layer = nil; | 665 CALayer* transform_layer = nil; |
| 624 CALayer* content_layer1 = nil; | 666 CALayer* content_layer1 = nil; |
| 625 CALayer* content_layer2 = nil; | 667 CALayer* content_layer2 = nil; |
| 626 CALayer* content_layer3 = nil; | 668 CALayer* content_layer3 = nil; |
| 669 CALayer* content_layer4 = nil; |
| 627 | 670 |
| 628 // Validate the initial values. | 671 // Validate the initial values. |
| 629 { | 672 { |
| 630 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 673 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 631 | 674 |
| 632 // Validate the tree structure. | 675 // Validate the tree structure. |
| 633 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 676 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 634 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 677 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 635 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 678 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 636 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 679 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 637 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 680 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 638 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 681 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 639 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 682 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 640 content_layer1 = [[transform_layer sublayers] objectAtIndex:0]; | 683 content_layer1 = [[transform_layer sublayers] objectAtIndex:0]; |
| 641 | 684 |
| 642 // Validate the content layer. | 685 // Validate the content layer. |
| 643 EXPECT_FALSE([content_layer1 | 686 EXPECT_FALSE([content_layer1 |
| 644 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 687 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 645 } | 688 } |
| 646 | 689 |
| 647 properties.io_surface.reset(gfx::CreateIOSurface( | 690 properties.gl_image->Destroy(true); |
| 648 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 691 properties.gl_image = CreateGLImage( |
| 692 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR, false); |
| 649 | 693 |
| 650 // Pass another frame. | 694 // Pass another frame. This will automatically create a CVPixelBuffer |
| 695 // behind the scenes, because the underlying buffer is YUV 420. |
| 651 { | 696 { |
| 652 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 697 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 653 | 698 |
| 654 // Validate the tree structure. | 699 // Validate the tree structure. |
| 655 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 700 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 656 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 701 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 657 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 702 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 658 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 703 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 659 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 704 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 660 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 705 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 661 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 706 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 662 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; | 707 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; |
| 663 | 708 |
| 664 // Validate the content layer. | 709 // Validate the content layer. |
| 665 EXPECT_FALSE([content_layer2 | 710 EXPECT_TRUE([content_layer2 |
| 666 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 711 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 667 EXPECT_EQ(content_layer2, content_layer1); | 712 EXPECT_NE(content_layer2, content_layer1); |
| 668 } | 713 } |
| 669 | 714 |
| 670 properties.io_surface.reset(gfx::CreateIOSurface( | 715 properties.gl_image->Destroy(true); |
| 671 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 716 properties.gl_image = CreateGLImage( |
| 672 CVPixelBufferCreateWithIOSurface(nullptr, properties.io_surface, nullptr, | 717 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR, true); |
| 673 properties.cv_pixel_buffer.InitializeInto()); | |
| 674 | 718 |
| 675 // Pass a frame with a CVPixelBuffer | 719 // Pass a frame with a CVPixelBuffer. |
| 676 { | 720 { |
| 677 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 721 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 678 | 722 |
| 679 // Validate the tree structure. | 723 // Validate the tree structure. |
| 680 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 724 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 681 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 725 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 682 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 726 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 683 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 727 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 684 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 728 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 685 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 729 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 686 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 730 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 687 content_layer2 = [[transform_layer sublayers] objectAtIndex:0]; | 731 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; |
| 688 | 732 |
| 689 // Validate the content layer. | 733 // Validate the content layer. |
| 690 EXPECT_TRUE([content_layer2 | 734 EXPECT_TRUE([content_layer3 |
| 691 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 735 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 692 EXPECT_NE(content_layer2, content_layer1); | 736 EXPECT_EQ(content_layer3, content_layer2); |
| 693 } | 737 } |
| 694 | 738 |
| 695 properties.io_surface.reset(gfx::CreateIOSurface( | 739 properties.gl_image->Destroy(true); |
| 696 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 740 properties.gl_image = CreateGLImage( |
| 697 properties.cv_pixel_buffer.reset(); | 741 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR, false); |
| 698 | 742 |
| 699 // Pass a frame that is clipped. | 743 // Pass a frame that is clipped. |
| 700 properties.contents_rect = gfx::RectF(0, 0, 1, 0.9); | 744 properties.contents_rect = gfx::RectF(0, 0, 1, 0.9); |
| 701 { | 745 { |
| 702 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); | 746 UpdateCALayerTree(ca_layer_tree, &properties, superlayer_); |
| 703 | 747 |
| 704 // Validate the tree structure. | 748 // Validate the tree structure. |
| 705 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 749 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 706 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 750 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 707 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 751 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 708 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 752 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 709 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 753 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 710 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 754 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 711 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 755 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 712 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; | 756 content_layer4 = [[transform_layer sublayers] objectAtIndex:0]; |
| 713 | 757 |
| 714 // Validate the content layer. | 758 // Validate the content layer. |
| 715 EXPECT_FALSE([content_layer3 | 759 EXPECT_FALSE([content_layer4 |
| 716 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 760 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 717 EXPECT_NE(content_layer3, content_layer2); | 761 EXPECT_NE(content_layer4, content_layer3); |
| 718 } | 762 } |
| 719 } | 763 } |
| 720 | 764 |
| 721 // Test fullscreen low power detection. | 765 // Test fullscreen low power detection. |
| 722 TEST_F(CALayerTreeTest, FullscreenLowPower) { | 766 TEST_F(CALayerTreeTest, FullscreenLowPower) { |
| 723 CALayerProperties properties; | 767 CALayerProperties properties; |
| 724 properties.io_surface.reset(gfx::CreateIOSurface( | 768 properties.gl_image = CreateGLImage( |
| 725 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 769 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR, true); |
| 726 properties.is_clipped = false; | 770 properties.is_clipped = false; |
| 727 CVPixelBufferCreateWithIOSurface(nullptr, properties.io_surface, nullptr, | |
| 728 properties.cv_pixel_buffer.InitializeInto()); | |
| 729 | 771 |
| 730 CALayerProperties properties_black; | 772 CALayerProperties properties_black; |
| 731 properties_black.is_clipped = false; | 773 properties_black.is_clipped = false; |
| 732 properties_black.background_color = SK_ColorBLACK; | 774 properties_black.background_color = SK_ColorBLACK; |
| 733 CALayerProperties properties_white; | 775 CALayerProperties properties_white; |
| 734 properties_white.is_clipped = false; | 776 properties_white.is_clipped = false; |
| 735 properties_white.background_color = SK_ColorWHITE; | 777 properties_white.background_color = SK_ColorWHITE; |
| 736 | 778 |
| 737 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 779 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 738 | 780 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 CALayer* content_layer = [[transform_layer sublayers] objectAtIndex:0]; | 899 CALayer* content_layer = [[transform_layer sublayers] objectAtIndex:0]; |
| 858 | 900 |
| 859 // Validate the content layer and fullscreen low power mode. | 901 // Validate the content layer and fullscreen low power mode. |
| 860 EXPECT_TRUE([content_layer | 902 EXPECT_TRUE([content_layer |
| 861 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 903 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 862 EXPECT_FALSE(fullscreen_low_power_valid); | 904 EXPECT_FALSE(fullscreen_low_power_valid); |
| 863 } | 905 } |
| 864 } | 906 } |
| 865 | 907 |
| 866 } // namespace gpu | 908 } // namespace gpu |
| OLD | NEW |