| 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 "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" | 13 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" |
| 13 #include "ui/gfx/geometry/dip_util.h" | 14 #include "ui/gfx/geometry/dip_util.h" |
| 14 #include "ui/gfx/mac/io_surface.h" | 15 #include "ui/gfx/mac/io_surface.h" |
| 15 | 16 |
| 16 namespace gpu { | 17 namespace gpu { |
| 17 | 18 |
| 18 class CALayerTreeTest : public testing::Test { | 19 class CALayerTreeTest : public testing::Test { |
| 19 protected: | 20 protected: |
| 20 void SetUp() override { | 21 void SetUp() override { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 bool is_clipped = true; | 35 bool is_clipped = true; |
| 35 gfx::Rect clip_rect(2, 4, 8, 16); | 36 gfx::Rect clip_rect(2, 4, 8, 16); |
| 36 int sorting_context_id = 0; | 37 int sorting_context_id = 0; |
| 37 gfx::Transform transform; | 38 gfx::Transform transform; |
| 38 transform.Translate(10, 20); | 39 transform.Translate(10, 20); |
| 39 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f); | 40 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f); |
| 40 gfx::Rect rect(16, 32, 64, 128); | 41 gfx::Rect rect(16, 32, 64, 128); |
| 41 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 42 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 42 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 43 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 43 float opacity = 0.5f; | 44 float opacity = 0.5f; |
| 45 unsigned filter = GL_LINEAR; |
| 44 float scale_factor = 1.0f; | 46 float scale_factor = 1.0f; |
| 45 bool result = false; | 47 bool result = false; |
| 46 | 48 |
| 47 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 49 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 48 CALayer* root_layer = nil; | 50 CALayer* root_layer = nil; |
| 49 CALayer* clip_and_sorting_layer = nil; | 51 CALayer* clip_and_sorting_layer = nil; |
| 50 CALayer* transform_layer = nil; | 52 CALayer* transform_layer = nil; |
| 51 CALayer* content_layer = nil; | 53 CALayer* content_layer = nil; |
| 52 | 54 |
| 53 // Validate the initial values. | 55 // Validate the initial values. |
| 54 { | 56 { |
| 55 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 57 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 56 new ui::CARendererLayerTree); | 58 new ui::CARendererLayerTree); |
| 57 result = new_ca_layer_tree->ScheduleCALayer( | 59 result = new_ca_layer_tree->ScheduleCALayer( |
| 58 is_clipped, | 60 is_clipped, |
| 59 clip_rect, | 61 clip_rect, |
| 60 sorting_context_id, | 62 sorting_context_id, |
| 61 transform, | 63 transform, |
| 62 io_surface, | 64 io_surface, |
| 63 nullptr, | 65 nullptr, |
| 64 contents_rect, | 66 contents_rect, |
| 65 rect, | 67 rect, |
| 66 background_color, | 68 background_color, |
| 67 edge_aa_mask, | 69 edge_aa_mask, |
| 68 opacity); | 70 opacity, |
| 71 filter); |
| 69 EXPECT_TRUE(result); | 72 EXPECT_TRUE(result); |
| 70 new_ca_layer_tree->CommitScheduledCALayers( | 73 new_ca_layer_tree->CommitScheduledCALayers( |
| 71 superlayer_, std::move(ca_layer_tree), scale_factor); | 74 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 72 std::swap(new_ca_layer_tree, ca_layer_tree); | 75 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 73 | 76 |
| 74 // Validate the tree structure. | 77 // Validate the tree structure. |
| 75 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 78 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 76 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 79 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 77 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 80 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 78 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 81 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 EXPECT_EQ(transform.matrix().get(3, 1), | 101 EXPECT_EQ(transform.matrix().get(3, 1), |
| 99 [transform_layer sublayerTransform].m42); | 102 [transform_layer sublayerTransform].m42); |
| 100 | 103 |
| 101 // Validate the content layer. | 104 // Validate the content layer. |
| 102 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]); | 105 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]); |
| 103 EXPECT_EQ(contents_rect, gfx::RectF([content_layer contentsRect])); | 106 EXPECT_EQ(contents_rect, gfx::RectF([content_layer contentsRect])); |
| 104 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); | 107 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); |
| 105 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); | 108 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); |
| 106 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); | 109 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); |
| 107 EXPECT_EQ(opacity, [content_layer opacity]); | 110 EXPECT_EQ(opacity, [content_layer opacity]); |
| 111 EXPECT_NSEQ(kCAFilterLinear, [content_layer minificationFilter]); |
| 112 EXPECT_NSEQ(kCAFilterLinear, [content_layer magnificationFilter]); |
| 108 if ([content_layer respondsToSelector:(@selector(contentsScale))]) | 113 if ([content_layer respondsToSelector:(@selector(contentsScale))]) |
| 109 EXPECT_EQ(scale_factor, [content_layer contentsScale]); | 114 EXPECT_EQ(scale_factor, [content_layer contentsScale]); |
| 110 } | 115 } |
| 111 | 116 |
| 112 // Update just the clip rect and re-commit. | 117 // Update just the clip rect and re-commit. |
| 113 { | 118 { |
| 114 clip_rect = gfx::Rect(4, 8, 16, 32); | 119 clip_rect = gfx::Rect(4, 8, 16, 32); |
| 115 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 120 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 116 new ui::CARendererLayerTree); | 121 new ui::CARendererLayerTree); |
| 117 result = new_ca_layer_tree->ScheduleCALayer( | 122 result = new_ca_layer_tree->ScheduleCALayer( |
| 118 is_clipped, | 123 is_clipped, |
| 119 clip_rect, | 124 clip_rect, |
| 120 sorting_context_id, | 125 sorting_context_id, |
| 121 transform, | 126 transform, |
| 122 io_surface, | 127 io_surface, |
| 123 nullptr, | 128 nullptr, |
| 124 contents_rect, | 129 contents_rect, |
| 125 rect, | 130 rect, |
| 126 background_color, | 131 background_color, |
| 127 edge_aa_mask, | 132 edge_aa_mask, |
| 128 opacity); | 133 opacity, |
| 134 filter); |
| 129 EXPECT_TRUE(result); | 135 EXPECT_TRUE(result); |
| 130 new_ca_layer_tree->CommitScheduledCALayers( | 136 new_ca_layer_tree->CommitScheduledCALayers( |
| 131 superlayer_, std::move(ca_layer_tree), scale_factor); | 137 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 132 std::swap(new_ca_layer_tree, ca_layer_tree); | 138 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 133 | 139 |
| 134 // Validate the tree structure | 140 // Validate the tree structure |
| 135 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 141 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 136 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 142 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 137 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 143 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 138 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 144 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 161 is_clipped, | 167 is_clipped, |
| 162 clip_rect, | 168 clip_rect, |
| 163 sorting_context_id, | 169 sorting_context_id, |
| 164 transform, | 170 transform, |
| 165 io_surface, | 171 io_surface, |
| 166 nullptr, | 172 nullptr, |
| 167 contents_rect, | 173 contents_rect, |
| 168 rect, | 174 rect, |
| 169 background_color, | 175 background_color, |
| 170 edge_aa_mask, | 176 edge_aa_mask, |
| 171 opacity); | 177 opacity, |
| 178 filter); |
| 172 EXPECT_TRUE(result); | 179 EXPECT_TRUE(result); |
| 173 new_ca_layer_tree->CommitScheduledCALayers( | 180 new_ca_layer_tree->CommitScheduledCALayers( |
| 174 superlayer_, std::move(ca_layer_tree), scale_factor); | 181 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 175 std::swap(new_ca_layer_tree, ca_layer_tree); | 182 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 176 | 183 |
| 177 // Validate the tree structure | 184 // Validate the tree structure |
| 178 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 185 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 179 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 186 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 180 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 187 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 181 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 188 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 201 is_clipped, | 208 is_clipped, |
| 202 clip_rect, | 209 clip_rect, |
| 203 sorting_context_id, | 210 sorting_context_id, |
| 204 transform, | 211 transform, |
| 205 io_surface, | 212 io_surface, |
| 206 nullptr, | 213 nullptr, |
| 207 contents_rect, | 214 contents_rect, |
| 208 rect, | 215 rect, |
| 209 background_color, | 216 background_color, |
| 210 edge_aa_mask, | 217 edge_aa_mask, |
| 211 opacity); | 218 opacity, |
| 219 filter); |
| 212 EXPECT_TRUE(result); | 220 EXPECT_TRUE(result); |
| 213 new_ca_layer_tree->CommitScheduledCALayers( | 221 new_ca_layer_tree->CommitScheduledCALayers( |
| 214 superlayer_, std::move(ca_layer_tree), scale_factor); | 222 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 215 std::swap(new_ca_layer_tree, ca_layer_tree); | 223 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 216 | 224 |
| 217 // Validate the tree structure. | 225 // Validate the tree structure. |
| 218 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 226 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 219 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 227 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 220 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 228 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 221 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 229 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 239 is_clipped, | 247 is_clipped, |
| 240 clip_rect, | 248 clip_rect, |
| 241 sorting_context_id, | 249 sorting_context_id, |
| 242 transform, | 250 transform, |
| 243 io_surface, | 251 io_surface, |
| 244 nullptr, | 252 nullptr, |
| 245 contents_rect, | 253 contents_rect, |
| 246 rect, | 254 rect, |
| 247 background_color, | 255 background_color, |
| 248 edge_aa_mask, | 256 edge_aa_mask, |
| 249 opacity); | 257 opacity, |
| 258 filter); |
| 250 EXPECT_TRUE(result); | 259 EXPECT_TRUE(result); |
| 251 new_ca_layer_tree->CommitScheduledCALayers( | 260 new_ca_layer_tree->CommitScheduledCALayers( |
| 252 superlayer_, std::move(ca_layer_tree), scale_factor); | 261 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 253 std::swap(new_ca_layer_tree, ca_layer_tree); | 262 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 254 | 263 |
| 255 // Validate the tree structure. | 264 // Validate the tree structure. |
| 256 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 265 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 257 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 266 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 258 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 267 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 259 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 268 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 275 is_clipped, | 284 is_clipped, |
| 276 clip_rect, | 285 clip_rect, |
| 277 sorting_context_id, | 286 sorting_context_id, |
| 278 transform, | 287 transform, |
| 279 nullptr, | 288 nullptr, |
| 280 nullptr, | 289 nullptr, |
| 281 contents_rect, | 290 contents_rect, |
| 282 rect, | 291 rect, |
| 283 background_color, | 292 background_color, |
| 284 edge_aa_mask, | 293 edge_aa_mask, |
| 285 opacity); | 294 opacity, |
| 295 filter); |
| 286 EXPECT_TRUE(result); | 296 EXPECT_TRUE(result); |
| 287 new_ca_layer_tree->CommitScheduledCALayers( | 297 new_ca_layer_tree->CommitScheduledCALayers( |
| 288 superlayer_, std::move(ca_layer_tree), scale_factor); | 298 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 289 std::swap(new_ca_layer_tree, ca_layer_tree); | 299 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 290 | 300 |
| 291 // Validate the tree structure. | 301 // Validate the tree structure. |
| 292 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 302 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 293 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 303 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 294 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 304 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 295 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 305 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 313 is_clipped, | 323 is_clipped, |
| 314 clip_rect, | 324 clip_rect, |
| 315 sorting_context_id, | 325 sorting_context_id, |
| 316 transform, | 326 transform, |
| 317 nullptr, | 327 nullptr, |
| 318 nullptr, | 328 nullptr, |
| 319 contents_rect, | 329 contents_rect, |
| 320 rect, | 330 rect, |
| 321 background_color, | 331 background_color, |
| 322 edge_aa_mask, | 332 edge_aa_mask, |
| 323 opacity); | 333 opacity, |
| 334 filter); |
| 324 EXPECT_TRUE(result); | 335 EXPECT_TRUE(result); |
| 325 new_ca_layer_tree->CommitScheduledCALayers( | 336 new_ca_layer_tree->CommitScheduledCALayers( |
| 326 superlayer_, std::move(ca_layer_tree), scale_factor); | 337 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 327 std::swap(new_ca_layer_tree, ca_layer_tree); | 338 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 328 | 339 |
| 329 // Validate the tree structure. | 340 // Validate the tree structure. |
| 330 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 341 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 331 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 342 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 332 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 343 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 333 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 344 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 351 is_clipped, | 362 is_clipped, |
| 352 clip_rect, | 363 clip_rect, |
| 353 sorting_context_id, | 364 sorting_context_id, |
| 354 transform, | 365 transform, |
| 355 nullptr, | 366 nullptr, |
| 356 nullptr, | 367 nullptr, |
| 357 contents_rect, | 368 contents_rect, |
| 358 rect, | 369 rect, |
| 359 background_color, | 370 background_color, |
| 360 edge_aa_mask, | 371 edge_aa_mask, |
| 361 opacity); | 372 opacity, |
| 373 filter); |
| 362 EXPECT_TRUE(result); | 374 EXPECT_TRUE(result); |
| 363 new_ca_layer_tree->CommitScheduledCALayers( | 375 new_ca_layer_tree->CommitScheduledCALayers( |
| 364 superlayer_, std::move(ca_layer_tree), scale_factor); | 376 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 365 std::swap(new_ca_layer_tree, ca_layer_tree); | 377 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 366 | 378 |
| 367 // Validate the tree structure. | 379 // Validate the tree structure. |
| 368 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 380 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 369 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 381 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 370 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 382 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 371 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 383 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 389 is_clipped, | 401 is_clipped, |
| 390 clip_rect, | 402 clip_rect, |
| 391 sorting_context_id, | 403 sorting_context_id, |
| 392 transform, | 404 transform, |
| 393 nullptr, | 405 nullptr, |
| 394 nullptr, | 406 nullptr, |
| 395 contents_rect, | 407 contents_rect, |
| 396 rect, | 408 rect, |
| 397 background_color, | 409 background_color, |
| 398 edge_aa_mask, | 410 edge_aa_mask, |
| 399 opacity); | 411 opacity, |
| 412 filter); |
| 400 EXPECT_TRUE(result); | 413 EXPECT_TRUE(result); |
| 401 new_ca_layer_tree->CommitScheduledCALayers( | 414 new_ca_layer_tree->CommitScheduledCALayers( |
| 402 superlayer_, std::move(ca_layer_tree), scale_factor); | 415 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 403 std::swap(new_ca_layer_tree, ca_layer_tree); | 416 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 404 | 417 |
| 405 // Validate the tree structure. | 418 // Validate the tree structure. |
| 406 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 419 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 407 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 420 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 408 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 421 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 409 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 422 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| 410 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 423 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 411 EXPECT_EQ(transform_layer, | 424 EXPECT_EQ(transform_layer, |
| 412 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); | 425 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| 413 EXPECT_EQ(1u, [[transform_layer sublayers] count]); | 426 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 414 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); | 427 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 415 | 428 |
| 416 // Validate the content layer. | 429 // Validate the content layer. |
| 417 EXPECT_EQ(opacity, [content_layer opacity]); | 430 EXPECT_EQ(opacity, [content_layer opacity]); |
| 418 } | 431 } |
| 419 | 432 |
| 433 // Change the filter. |
| 434 { |
| 435 filter = GL_NEAREST; |
| 436 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 437 new ui::CARendererLayerTree); |
| 438 result = new_ca_layer_tree->ScheduleCALayer( |
| 439 is_clipped, |
| 440 clip_rect, |
| 441 sorting_context_id, |
| 442 transform, |
| 443 nullptr, |
| 444 nullptr, |
| 445 contents_rect, |
| 446 rect, |
| 447 background_color, |
| 448 edge_aa_mask, |
| 449 opacity, |
| 450 filter); |
| 451 EXPECT_TRUE(result); |
| 452 new_ca_layer_tree->CommitScheduledCALayers( |
| 453 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 454 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 455 |
| 456 // Validate the tree structure. |
| 457 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 458 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 459 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 460 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| 461 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 462 EXPECT_EQ(transform_layer, |
| 463 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); |
| 464 EXPECT_EQ(1u, [[transform_layer sublayers] count]); |
| 465 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); |
| 466 |
| 467 // Validate the content layer. |
| 468 EXPECT_NSEQ(kCAFilterNearest, [content_layer minificationFilter]); |
| 469 EXPECT_NSEQ(kCAFilterNearest, [content_layer magnificationFilter]); |
| 470 } |
| 471 |
| 420 // Add the clipping and IOSurface contents back. | 472 // Add the clipping and IOSurface contents back. |
| 421 { | 473 { |
| 422 is_clipped = true; | 474 is_clipped = true; |
| 423 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 475 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 424 new ui::CARendererLayerTree); | 476 new ui::CARendererLayerTree); |
| 425 result = new_ca_layer_tree->ScheduleCALayer( | 477 result = new_ca_layer_tree->ScheduleCALayer( |
| 426 is_clipped, | 478 is_clipped, |
| 427 clip_rect, | 479 clip_rect, |
| 428 sorting_context_id, | 480 sorting_context_id, |
| 429 transform, | 481 transform, |
| 430 io_surface, | 482 io_surface, |
| 431 nullptr, | 483 nullptr, |
| 432 contents_rect, | 484 contents_rect, |
| 433 rect, | 485 rect, |
| 434 background_color, | 486 background_color, |
| 435 edge_aa_mask, | 487 edge_aa_mask, |
| 436 opacity); | 488 opacity, |
| 489 filter); |
| 437 EXPECT_TRUE(result); | 490 EXPECT_TRUE(result); |
| 438 new_ca_layer_tree->CommitScheduledCALayers( | 491 new_ca_layer_tree->CommitScheduledCALayers( |
| 439 superlayer_, std::move(ca_layer_tree), scale_factor); | 492 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 440 std::swap(new_ca_layer_tree, ca_layer_tree); | 493 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 441 | 494 |
| 442 // Validate the tree structure. | 495 // Validate the tree structure. |
| 443 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 496 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 444 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 497 EXPECT_EQ(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 445 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 498 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 446 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); | 499 EXPECT_EQ(clip_and_sorting_layer, [[root_layer sublayers] objectAtIndex:0]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 464 is_clipped, | 517 is_clipped, |
| 465 clip_rect, | 518 clip_rect, |
| 466 sorting_context_id, | 519 sorting_context_id, |
| 467 transform, | 520 transform, |
| 468 io_surface, | 521 io_surface, |
| 469 nullptr, | 522 nullptr, |
| 470 contents_rect, | 523 contents_rect, |
| 471 rect, | 524 rect, |
| 472 background_color, | 525 background_color, |
| 473 edge_aa_mask, | 526 edge_aa_mask, |
| 474 opacity); | 527 opacity, |
| 528 filter); |
| 475 EXPECT_TRUE(result); | 529 EXPECT_TRUE(result); |
| 476 new_ca_layer_tree->CommitScheduledCALayers( | 530 new_ca_layer_tree->CommitScheduledCALayers( |
| 477 superlayer_, std::move(ca_layer_tree), scale_factor); | 531 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 478 std::swap(new_ca_layer_tree, ca_layer_tree); | 532 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 479 | 533 |
| 480 // Validate the tree structure. | 534 // Validate the tree structure. |
| 481 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 535 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 482 EXPECT_NE(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); | 536 EXPECT_NE(root_layer, [[superlayer_ sublayers] objectAtIndex:0]); |
| 483 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 537 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 484 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 538 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 TEST_F(CALayerTreeTest, SplitSortingContextZero) { | 581 TEST_F(CALayerTreeTest, SplitSortingContextZero) { |
| 528 bool is_clipped = false; | 582 bool is_clipped = false; |
| 529 gfx::Rect clip_rect; | 583 gfx::Rect clip_rect; |
| 530 int sorting_context_id = 0; | 584 int sorting_context_id = 0; |
| 531 gfx::RectF contents_rect(0, 0, 1, 1); | 585 gfx::RectF contents_rect(0, 0, 1, 1); |
| 532 gfx::Rect rect(0, 0, 256, 256); | 586 gfx::Rect rect(0, 0, 256, 256); |
| 533 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); | 587 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); |
| 534 unsigned edge_aa_mask = 0; | 588 unsigned edge_aa_mask = 0; |
| 535 float opacity = 1.0f; | 589 float opacity = 1.0f; |
| 536 float scale_factor = 1.0f; | 590 float scale_factor = 1.0f; |
| 591 unsigned filter = GL_LINEAR; |
| 537 | 592 |
| 538 // We'll use the IOSurface contents to identify the content layers. | 593 // We'll use the IOSurface contents to identify the content layers. |
| 539 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[5]; | 594 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[5]; |
| 540 for (size_t i = 0; i < 5; ++i) { | 595 for (size_t i = 0; i < 5; ++i) { |
| 541 io_surfaces[i].reset(gfx::CreateIOSurface( | 596 io_surfaces[i].reset(gfx::CreateIOSurface( |
| 542 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 597 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); |
| 543 } | 598 } |
| 544 | 599 |
| 545 // Have 5 transforms: | 600 // Have 5 transforms: |
| 546 // * 2 flat but different (1 sorting context layer, 2 transform layers) | 601 // * 2 flat but different (1 sorting context layer, 2 transform layers) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 561 is_clipped, | 616 is_clipped, |
| 562 clip_rect, | 617 clip_rect, |
| 563 sorting_context_id, | 618 sorting_context_id, |
| 564 transforms[i], | 619 transforms[i], |
| 565 io_surfaces[i], | 620 io_surfaces[i], |
| 566 nullptr, | 621 nullptr, |
| 567 contents_rect, | 622 contents_rect, |
| 568 rect, | 623 rect, |
| 569 background_color, | 624 background_color, |
| 570 edge_aa_mask, | 625 edge_aa_mask, |
| 571 opacity); | 626 opacity, |
| 627 filter); |
| 572 EXPECT_TRUE(result); | 628 EXPECT_TRUE(result); |
| 573 } | 629 } |
| 574 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); | 630 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); |
| 575 | 631 |
| 576 // Validate the root layer. | 632 // Validate the root layer. |
| 577 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 633 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 578 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 634 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 579 | 635 |
| 580 // Validate that we have 3 sorting context layers. | 636 // Validate that we have 3 sorting context layers. |
| 581 EXPECT_EQ(3u, [[root_layer sublayers] count]); | 637 EXPECT_EQ(3u, [[root_layer sublayers] count]); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 bool is_clipped = false; | 681 bool is_clipped = false; |
| 626 gfx::Rect clip_rect; | 682 gfx::Rect clip_rect; |
| 627 int sorting_context_ids[3] = {3, -1, 0}; | 683 int sorting_context_ids[3] = {3, -1, 0}; |
| 628 gfx::RectF contents_rect(0, 0, 1, 1); | 684 gfx::RectF contents_rect(0, 0, 1, 1); |
| 629 gfx::Rect rect(0, 0, 256, 256); | 685 gfx::Rect rect(0, 0, 256, 256); |
| 630 gfx::Transform transform; | 686 gfx::Transform transform; |
| 631 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); | 687 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); |
| 632 unsigned edge_aa_mask = 0; | 688 unsigned edge_aa_mask = 0; |
| 633 float opacity = 1.0f; | 689 float opacity = 1.0f; |
| 634 float scale_factor = 1.0f; | 690 float scale_factor = 1.0f; |
| 691 unsigned filter = GL_LINEAR; |
| 635 | 692 |
| 636 // We'll use the IOSurface contents to identify the content layers. | 693 // We'll use the IOSurface contents to identify the content layers. |
| 637 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; | 694 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; |
| 638 for (size_t i = 0; i < 3; ++i) { | 695 for (size_t i = 0; i < 3; ++i) { |
| 639 io_surfaces[i].reset(gfx::CreateIOSurface( | 696 io_surfaces[i].reset(gfx::CreateIOSurface( |
| 640 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); | 697 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); |
| 641 } | 698 } |
| 642 | 699 |
| 643 // Schedule and commit the layers. | 700 // Schedule and commit the layers. |
| 644 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( | 701 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 645 new ui::CARendererLayerTree); | 702 new ui::CARendererLayerTree); |
| 646 for (size_t i = 0; i < 3; ++i) { | 703 for (size_t i = 0; i < 3; ++i) { |
| 647 bool result = ca_layer_tree->ScheduleCALayer( | 704 bool result = ca_layer_tree->ScheduleCALayer( |
| 648 is_clipped, | 705 is_clipped, |
| 649 clip_rect, | 706 clip_rect, |
| 650 sorting_context_ids[i], | 707 sorting_context_ids[i], |
| 651 transform, | 708 transform, |
| 652 io_surfaces[i], | 709 io_surfaces[i], |
| 653 nullptr, | 710 nullptr, |
| 654 contents_rect, | 711 contents_rect, |
| 655 rect, | 712 rect, |
| 656 background_color, | 713 background_color, |
| 657 edge_aa_mask, | 714 edge_aa_mask, |
| 658 opacity); | 715 opacity, |
| 716 filter); |
| 659 EXPECT_TRUE(result); | 717 EXPECT_TRUE(result); |
| 660 } | 718 } |
| 661 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); | 719 ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, scale_factor); |
| 662 | 720 |
| 663 // Validate the root layer. | 721 // Validate the root layer. |
| 664 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 722 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 665 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 723 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 666 | 724 |
| 667 // Validate that we have 3 sorting context layers. | 725 // Validate that we have 3 sorting context layers. |
| 668 EXPECT_EQ(3u, [[root_layer sublayers] count]); | 726 EXPECT_EQ(3u, [[root_layer sublayers] count]); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 697 | 755 |
| 698 // Verify that sorting contexts must all have the same clipping properties. | 756 // Verify that sorting contexts must all have the same clipping properties. |
| 699 TEST_F(CALayerTreeTest, SortingContextMustHaveConsistentClip) { | 757 TEST_F(CALayerTreeTest, SortingContextMustHaveConsistentClip) { |
| 700 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | 758 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; |
| 701 gfx::RectF contents_rect(0, 0, 1, 1); | 759 gfx::RectF contents_rect(0, 0, 1, 1); |
| 702 gfx::Rect rect(0, 0, 256, 256); | 760 gfx::Rect rect(0, 0, 256, 256); |
| 703 gfx::Transform transform; | 761 gfx::Transform transform; |
| 704 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); | 762 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); |
| 705 unsigned edge_aa_mask = 0; | 763 unsigned edge_aa_mask = 0; |
| 706 float opacity = 1.0f; | 764 float opacity = 1.0f; |
| 765 unsigned filter = GL_LINEAR; |
| 707 | 766 |
| 708 // Vary the clipping parameters within sorting contexts. | 767 // Vary the clipping parameters within sorting contexts. |
| 709 bool is_clippeds[3] = { true, true, false}; | 768 bool is_clippeds[3] = { true, true, false}; |
| 710 gfx::Rect clip_rects[3] = { | 769 gfx::Rect clip_rects[3] = { |
| 711 gfx::Rect(0, 0, 16, 16), | 770 gfx::Rect(0, 0, 16, 16), |
| 712 gfx::Rect(4, 8, 16, 32), | 771 gfx::Rect(4, 8, 16, 32), |
| 713 gfx::Rect(0, 0, 16, 16) | 772 gfx::Rect(0, 0, 16, 16) |
| 714 }; | 773 }; |
| 715 | 774 |
| 716 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( | 775 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree( |
| 717 new ui::CARendererLayerTree); | 776 new ui::CARendererLayerTree); |
| 718 // First send the various clip parameters to sorting context zero. This is | 777 // First send the various clip parameters to sorting context zero. This is |
| 719 // legitimate. | 778 // legitimate. |
| 720 for (size_t i = 0; i < 3; ++i) { | 779 for (size_t i = 0; i < 3; ++i) { |
| 721 int sorting_context_id = 0; | 780 int sorting_context_id = 0; |
| 722 bool result = ca_layer_tree->ScheduleCALayer( | 781 bool result = ca_layer_tree->ScheduleCALayer( |
| 723 is_clippeds[i], | 782 is_clippeds[i], |
| 724 clip_rects[i], | 783 clip_rects[i], |
| 725 sorting_context_id, | 784 sorting_context_id, |
| 726 transform, | 785 transform, |
| 727 io_surface, | 786 io_surface, |
| 728 nullptr, | 787 nullptr, |
| 729 contents_rect, | 788 contents_rect, |
| 730 rect, | 789 rect, |
| 731 background_color, | 790 background_color, |
| 732 edge_aa_mask, | 791 edge_aa_mask, |
| 733 opacity); | 792 opacity, |
| 793 filter); |
| 734 EXPECT_TRUE(result); | 794 EXPECT_TRUE(result); |
| 735 } | 795 } |
| 736 // Next send the various clip parameters to a non-zero sorting context. This | 796 // Next send the various clip parameters to a non-zero sorting context. This |
| 737 // will fail when we try to change the clip within the sorting context. | 797 // will fail when we try to change the clip within the sorting context. |
| 738 for (size_t i = 0; i < 3; ++i) { | 798 for (size_t i = 0; i < 3; ++i) { |
| 739 int sorting_context_id = 3; | 799 int sorting_context_id = 3; |
| 740 bool result = ca_layer_tree->ScheduleCALayer( | 800 bool result = ca_layer_tree->ScheduleCALayer( |
| 741 is_clippeds[i], | 801 is_clippeds[i], |
| 742 clip_rects[i], | 802 clip_rects[i], |
| 743 sorting_context_id, | 803 sorting_context_id, |
| 744 transform, | 804 transform, |
| 745 io_surface, | 805 io_surface, |
| 746 nullptr, | 806 nullptr, |
| 747 contents_rect, | 807 contents_rect, |
| 748 rect, | 808 rect, |
| 749 background_color, | 809 background_color, |
| 750 edge_aa_mask, | 810 edge_aa_mask, |
| 751 opacity); | 811 opacity, |
| 812 filter); |
| 752 if (i == 0) | 813 if (i == 0) |
| 753 EXPECT_TRUE(result); | 814 EXPECT_TRUE(result); |
| 754 else | 815 else |
| 755 EXPECT_FALSE(result); | 816 EXPECT_FALSE(result); |
| 756 } | 817 } |
| 757 // Try once more with the original clip and verify it works. | 818 // Try once more with the original clip and verify it works. |
| 758 { | 819 { |
| 759 int sorting_context_id = 3; | 820 int sorting_context_id = 3; |
| 760 bool result = ca_layer_tree->ScheduleCALayer( | 821 bool result = ca_layer_tree->ScheduleCALayer( |
| 761 is_clippeds[0], | 822 is_clippeds[0], |
| 762 clip_rects[0], | 823 clip_rects[0], |
| 763 sorting_context_id, | 824 sorting_context_id, |
| 764 transform, | 825 transform, |
| 765 io_surface, | 826 io_surface, |
| 766 nullptr, | 827 nullptr, |
| 767 contents_rect, | 828 contents_rect, |
| 768 rect, | 829 rect, |
| 769 background_color, | 830 background_color, |
| 770 edge_aa_mask, | 831 edge_aa_mask, |
| 771 opacity); | 832 opacity, |
| 833 filter); |
| 772 EXPECT_TRUE(result); | 834 EXPECT_TRUE(result); |
| 773 } | 835 } |
| 774 } | 836 } |
| 775 | 837 |
| 776 // Test updating each layer's properties. | 838 // Test updating each layer's properties. |
| 777 TEST_F(CALayerTreeTest, AVLayer) { | 839 TEST_F(CALayerTreeTest, AVLayer) { |
| 778 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(gfx::CreateIOSurface( | 840 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(gfx::CreateIOSurface( |
| 779 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); | 841 gfx::Size(256, 256), gfx::BufferFormat::YUV_420_BIPLANAR)); |
| 780 | 842 |
| 781 bool is_clipped = true; | 843 bool is_clipped = true; |
| 782 gfx::Rect clip_rect(2, 4, 8, 16); | 844 gfx::Rect clip_rect(2, 4, 8, 16); |
| 783 int sorting_context_id = 0; | 845 int sorting_context_id = 0; |
| 784 gfx::Transform transform; | 846 gfx::Transform transform; |
| 785 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); | 847 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); |
| 786 gfx::Rect rect(16, 32, 64, 128); | 848 gfx::Rect rect(16, 32, 64, 128); |
| 787 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); | 849 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); |
| 788 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; | 850 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; |
| 789 float opacity = 0.5f; | 851 float opacity = 0.5f; |
| 790 float scale_factor = 1.0f; | 852 float scale_factor = 1.0f; |
| 791 bool result = false; | 853 bool result = false; |
| 854 unsigned filter = GL_LINEAR; |
| 792 | 855 |
| 793 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 856 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 794 CALayer* root_layer = nil; | 857 CALayer* root_layer = nil; |
| 795 CALayer* clip_and_sorting_layer = nil; | 858 CALayer* clip_and_sorting_layer = nil; |
| 796 CALayer* transform_layer = nil; | 859 CALayer* transform_layer = nil; |
| 797 CALayer* content_layer1 = nil; | 860 CALayer* content_layer1 = nil; |
| 798 CALayer* content_layer2 = nil; | 861 CALayer* content_layer2 = nil; |
| 799 CALayer* content_layer3 = nil; | 862 CALayer* content_layer3 = nil; |
| 800 | 863 |
| 801 // Validate the initial values. | 864 // Validate the initial values. |
| 802 { | 865 { |
| 803 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 866 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 804 new ui::CARendererLayerTree); | 867 new ui::CARendererLayerTree); |
| 805 result = new_ca_layer_tree->ScheduleCALayer( | 868 result = new_ca_layer_tree->ScheduleCALayer( |
| 806 is_clipped, | 869 is_clipped, |
| 807 clip_rect, | 870 clip_rect, |
| 808 sorting_context_id, | 871 sorting_context_id, |
| 809 transform, | 872 transform, |
| 810 io_surface, | 873 io_surface, |
| 811 nullptr, | 874 nullptr, |
| 812 contents_rect, | 875 contents_rect, |
| 813 rect, background_color, | 876 rect, background_color, |
| 814 edge_aa_mask, | 877 edge_aa_mask, |
| 815 opacity); | 878 opacity, |
| 879 filter); |
| 816 EXPECT_TRUE(result); | 880 EXPECT_TRUE(result); |
| 817 new_ca_layer_tree->CommitScheduledCALayers( | 881 new_ca_layer_tree->CommitScheduledCALayers( |
| 818 superlayer_, std::move(ca_layer_tree), scale_factor); | 882 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 819 std::swap(new_ca_layer_tree, ca_layer_tree); | 883 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 820 | 884 |
| 821 // Validate the tree structure. | 885 // Validate the tree structure. |
| 822 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 886 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 823 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 887 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 824 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 888 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 825 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 889 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 844 is_clipped, | 908 is_clipped, |
| 845 clip_rect, | 909 clip_rect, |
| 846 sorting_context_id, | 910 sorting_context_id, |
| 847 transform, | 911 transform, |
| 848 io_surface, | 912 io_surface, |
| 849 nullptr, | 913 nullptr, |
| 850 contents_rect, | 914 contents_rect, |
| 851 rect, | 915 rect, |
| 852 background_color, | 916 background_color, |
| 853 edge_aa_mask, | 917 edge_aa_mask, |
| 854 opacity); | 918 opacity, |
| 919 filter); |
| 855 EXPECT_TRUE(result); | 920 EXPECT_TRUE(result); |
| 856 new_ca_layer_tree->CommitScheduledCALayers( | 921 new_ca_layer_tree->CommitScheduledCALayers( |
| 857 superlayer_, std::move(ca_layer_tree), scale_factor); | 922 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 858 std::swap(new_ca_layer_tree, ca_layer_tree); | 923 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 859 | 924 |
| 860 // Validate the tree structure. | 925 // Validate the tree structure. |
| 861 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 926 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 862 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 927 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 863 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 928 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 864 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 929 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 887 is_clipped, | 952 is_clipped, |
| 888 clip_rect, | 953 clip_rect, |
| 889 sorting_context_id, | 954 sorting_context_id, |
| 890 transform, | 955 transform, |
| 891 io_surface, | 956 io_surface, |
| 892 cv_pixel_buffer, | 957 cv_pixel_buffer, |
| 893 contents_rect, | 958 contents_rect, |
| 894 rect, | 959 rect, |
| 895 background_color, | 960 background_color, |
| 896 edge_aa_mask, | 961 edge_aa_mask, |
| 897 opacity); | 962 opacity, |
| 963 filter); |
| 898 EXPECT_TRUE(result); | 964 EXPECT_TRUE(result); |
| 899 new_ca_layer_tree->CommitScheduledCALayers( | 965 new_ca_layer_tree->CommitScheduledCALayers( |
| 900 superlayer_, std::move(ca_layer_tree), scale_factor); | 966 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 901 std::swap(new_ca_layer_tree, ca_layer_tree); | 967 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 902 | 968 |
| 903 // Validate the tree structure. | 969 // Validate the tree structure. |
| 904 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 970 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 905 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 971 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 906 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 972 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 907 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 973 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 929 is_clipped, | 995 is_clipped, |
| 930 clip_rect, | 996 clip_rect, |
| 931 sorting_context_id, | 997 sorting_context_id, |
| 932 transform, | 998 transform, |
| 933 io_surface, | 999 io_surface, |
| 934 nullptr, | 1000 nullptr, |
| 935 contents_rect, | 1001 contents_rect, |
| 936 rect, | 1002 rect, |
| 937 background_color, | 1003 background_color, |
| 938 edge_aa_mask, | 1004 edge_aa_mask, |
| 939 opacity); | 1005 opacity, |
| 1006 filter); |
| 940 EXPECT_TRUE(result); | 1007 EXPECT_TRUE(result); |
| 941 new_ca_layer_tree->CommitScheduledCALayers( | 1008 new_ca_layer_tree->CommitScheduledCALayers( |
| 942 superlayer_, std::move(ca_layer_tree), scale_factor); | 1009 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 943 std::swap(new_ca_layer_tree, ca_layer_tree); | 1010 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 944 | 1011 |
| 945 // Validate the tree structure. | 1012 // Validate the tree structure. |
| 946 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 1013 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 947 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 1014 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 948 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 1015 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 949 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 1016 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 970 gfx::Transform transform; | 1037 gfx::Transform transform; |
| 971 transform.Translate(10, 20); | 1038 transform.Translate(10, 20); |
| 972 transform.Scale(0.5, 2.0); | 1039 transform.Scale(0.5, 2.0); |
| 973 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); | 1040 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); |
| 974 gfx::Rect rect(16, 32, 64, 128); | 1041 gfx::Rect rect(16, 32, 64, 128); |
| 975 unsigned background_color = SkColorSetARGB(0, 0, 0, 0); | 1042 unsigned background_color = SkColorSetARGB(0, 0, 0, 0); |
| 976 unsigned edge_aa_mask = 0; | 1043 unsigned edge_aa_mask = 0; |
| 977 float opacity = 1.0f; | 1044 float opacity = 1.0f; |
| 978 float scale_factor = 1.0f; | 1045 float scale_factor = 1.0f; |
| 979 bool result = false; | 1046 bool result = false; |
| 1047 unsigned filter = GL_LINEAR; |
| 980 | 1048 |
| 981 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; | 1049 std::unique_ptr<ui::CARendererLayerTree> ca_layer_tree; |
| 982 | 1050 |
| 983 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; | 1051 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer; |
| 984 CVPixelBufferCreateWithIOSurface(nullptr, io_surface, nullptr, | 1052 CVPixelBufferCreateWithIOSurface(nullptr, io_surface, nullptr, |
| 985 cv_pixel_buffer.InitializeInto()); | 1053 cv_pixel_buffer.InitializeInto()); |
| 986 | 1054 |
| 987 // Test a configuration with no background. | 1055 // Test a configuration with no background. |
| 988 { | 1056 { |
| 989 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 1057 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 990 new ui::CARendererLayerTree); | 1058 new ui::CARendererLayerTree); |
| 991 result = new_ca_layer_tree->ScheduleCALayer( | 1059 result = new_ca_layer_tree->ScheduleCALayer( |
| 992 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 1060 is_clipped, clip_rect, sorting_context_id, transform, io_surface, |
| 993 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, | 1061 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, |
| 994 opacity); | 1062 opacity, filter); |
| 995 EXPECT_TRUE(result); | 1063 EXPECT_TRUE(result); |
| 996 new_ca_layer_tree->CommitScheduledCALayers( | 1064 new_ca_layer_tree->CommitScheduledCALayers( |
| 997 superlayer_, std::move(ca_layer_tree), scale_factor); | 1065 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 998 bool fullscreen_low_power_valid = | 1066 bool fullscreen_low_power_valid = |
| 999 new_ca_layer_tree->CommitFullscreenLowPowerLayer( | 1067 new_ca_layer_tree->CommitFullscreenLowPowerLayer( |
| 1000 fullscreen_low_power_layer_); | 1068 fullscreen_low_power_layer_); |
| 1001 std::swap(new_ca_layer_tree, ca_layer_tree); | 1069 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 1002 | 1070 |
| 1003 // Validate the tree structure. | 1071 // Validate the tree structure. |
| 1004 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 1072 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1016 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 1084 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 1017 EXPECT_TRUE(fullscreen_low_power_valid); | 1085 EXPECT_TRUE(fullscreen_low_power_valid); |
| 1018 } | 1086 } |
| 1019 | 1087 |
| 1020 // Test a configuration with a black background. | 1088 // Test a configuration with a black background. |
| 1021 { | 1089 { |
| 1022 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 1090 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 1023 new ui::CARendererLayerTree); | 1091 new ui::CARendererLayerTree); |
| 1024 result = new_ca_layer_tree->ScheduleCALayer( | 1092 result = new_ca_layer_tree->ScheduleCALayer( |
| 1025 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, | 1093 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, |
| 1026 contents_rect, rect, SK_ColorBLACK, edge_aa_mask, opacity); | 1094 contents_rect, rect, SK_ColorBLACK, edge_aa_mask, opacity, filter); |
| 1027 result = new_ca_layer_tree->ScheduleCALayer( | 1095 result = new_ca_layer_tree->ScheduleCALayer( |
| 1028 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 1096 is_clipped, clip_rect, sorting_context_id, transform, io_surface, |
| 1029 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, | 1097 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, |
| 1030 opacity); | 1098 opacity, filter); |
| 1031 EXPECT_TRUE(result); | 1099 EXPECT_TRUE(result); |
| 1032 new_ca_layer_tree->CommitScheduledCALayers( | 1100 new_ca_layer_tree->CommitScheduledCALayers( |
| 1033 superlayer_, std::move(ca_layer_tree), scale_factor); | 1101 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 1034 bool fullscreen_low_power_valid = | 1102 bool fullscreen_low_power_valid = |
| 1035 new_ca_layer_tree->CommitFullscreenLowPowerLayer( | 1103 new_ca_layer_tree->CommitFullscreenLowPowerLayer( |
| 1036 fullscreen_low_power_layer_); | 1104 fullscreen_low_power_layer_); |
| 1037 std::swap(new_ca_layer_tree, ca_layer_tree); | 1105 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 1038 | 1106 |
| 1039 // Validate the tree structure. | 1107 // Validate the tree structure. |
| 1040 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 1108 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1052 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 1120 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 1053 EXPECT_TRUE(fullscreen_low_power_valid); | 1121 EXPECT_TRUE(fullscreen_low_power_valid); |
| 1054 } | 1122 } |
| 1055 | 1123 |
| 1056 // Test a configuration with a white background. It will fail. | 1124 // Test a configuration with a white background. It will fail. |
| 1057 { | 1125 { |
| 1058 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 1126 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 1059 new ui::CARendererLayerTree); | 1127 new ui::CARendererLayerTree); |
| 1060 result = new_ca_layer_tree->ScheduleCALayer( | 1128 result = new_ca_layer_tree->ScheduleCALayer( |
| 1061 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, | 1129 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, |
| 1062 contents_rect, rect, SK_ColorWHITE, edge_aa_mask, opacity); | 1130 contents_rect, rect, SK_ColorWHITE, edge_aa_mask, opacity, filter); |
| 1063 result = new_ca_layer_tree->ScheduleCALayer( | 1131 result = new_ca_layer_tree->ScheduleCALayer( |
| 1064 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 1132 is_clipped, clip_rect, sorting_context_id, transform, io_surface, |
| 1065 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, | 1133 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, |
| 1066 opacity); | 1134 opacity, filter); |
| 1067 EXPECT_TRUE(result); | 1135 EXPECT_TRUE(result); |
| 1068 new_ca_layer_tree->CommitScheduledCALayers( | 1136 new_ca_layer_tree->CommitScheduledCALayers( |
| 1069 superlayer_, std::move(ca_layer_tree), scale_factor); | 1137 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 1070 bool fullscreen_low_power_valid = | 1138 bool fullscreen_low_power_valid = |
| 1071 new_ca_layer_tree->CommitFullscreenLowPowerLayer( | 1139 new_ca_layer_tree->CommitFullscreenLowPowerLayer( |
| 1072 fullscreen_low_power_layer_); | 1140 fullscreen_low_power_layer_); |
| 1073 std::swap(new_ca_layer_tree, ca_layer_tree); | 1141 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 1074 | 1142 |
| 1075 // Validate the tree structure. | 1143 // Validate the tree structure. |
| 1076 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 1144 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1089 EXPECT_FALSE(fullscreen_low_power_valid); | 1157 EXPECT_FALSE(fullscreen_low_power_valid); |
| 1090 } | 1158 } |
| 1091 | 1159 |
| 1092 // Test a configuration with a black foreground. It too will fail. | 1160 // Test a configuration with a black foreground. It too will fail. |
| 1093 { | 1161 { |
| 1094 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( | 1162 std::unique_ptr<ui::CARendererLayerTree> new_ca_layer_tree( |
| 1095 new ui::CARendererLayerTree); | 1163 new ui::CARendererLayerTree); |
| 1096 result = new_ca_layer_tree->ScheduleCALayer( | 1164 result = new_ca_layer_tree->ScheduleCALayer( |
| 1097 is_clipped, clip_rect, sorting_context_id, transform, io_surface, | 1165 is_clipped, clip_rect, sorting_context_id, transform, io_surface, |
| 1098 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, | 1166 cv_pixel_buffer, contents_rect, rect, background_color, edge_aa_mask, |
| 1099 opacity); | 1167 opacity, filter); |
| 1100 result = new_ca_layer_tree->ScheduleCALayer( | 1168 result = new_ca_layer_tree->ScheduleCALayer( |
| 1101 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, | 1169 is_clipped, clip_rect, sorting_context_id, transform, nullptr, nullptr, |
| 1102 contents_rect, rect, SK_ColorBLACK, edge_aa_mask, opacity); | 1170 contents_rect, rect, SK_ColorBLACK, edge_aa_mask, opacity, filter); |
| 1103 EXPECT_TRUE(result); | 1171 EXPECT_TRUE(result); |
| 1104 new_ca_layer_tree->CommitScheduledCALayers( | 1172 new_ca_layer_tree->CommitScheduledCALayers( |
| 1105 superlayer_, std::move(ca_layer_tree), scale_factor); | 1173 superlayer_, std::move(ca_layer_tree), scale_factor); |
| 1106 bool fullscreen_low_power_valid = | 1174 bool fullscreen_low_power_valid = |
| 1107 new_ca_layer_tree->CommitFullscreenLowPowerLayer( | 1175 new_ca_layer_tree->CommitFullscreenLowPowerLayer( |
| 1108 fullscreen_low_power_layer_); | 1176 fullscreen_low_power_layer_); |
| 1109 std::swap(new_ca_layer_tree, ca_layer_tree); | 1177 std::swap(new_ca_layer_tree, ca_layer_tree); |
| 1110 | 1178 |
| 1111 // Validate the tree structure. | 1179 // Validate the tree structure. |
| 1112 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); | 1180 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); |
| 1113 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; | 1181 CALayer* root_layer = [[superlayer_ sublayers] objectAtIndex:0]; |
| 1114 EXPECT_EQ(1u, [[root_layer sublayers] count]); | 1182 EXPECT_EQ(1u, [[root_layer sublayers] count]); |
| 1115 CALayer* clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; | 1183 CALayer* clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; |
| 1116 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); | 1184 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); |
| 1117 CALayer* transform_layer = | 1185 CALayer* transform_layer = |
| 1118 [[clip_and_sorting_layer sublayers] objectAtIndex:0]; | 1186 [[clip_and_sorting_layer sublayers] objectAtIndex:0]; |
| 1119 EXPECT_EQ(2u, [[transform_layer sublayers] count]); | 1187 EXPECT_EQ(2u, [[transform_layer sublayers] count]); |
| 1120 CALayer* content_layer = [[transform_layer sublayers] objectAtIndex:0]; | 1188 CALayer* content_layer = [[transform_layer sublayers] objectAtIndex:0]; |
| 1121 | 1189 |
| 1122 // Validate the content layer and fullscreen low power mode. | 1190 // Validate the content layer and fullscreen low power mode. |
| 1123 EXPECT_TRUE([content_layer | 1191 EXPECT_TRUE([content_layer |
| 1124 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); | 1192 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); |
| 1125 EXPECT_FALSE(fullscreen_low_power_valid); | 1193 EXPECT_FALSE(fullscreen_low_power_valid); |
| 1126 } | 1194 } |
| 1127 } | 1195 } |
| 1128 | 1196 |
| 1129 } // namespace gpu | 1197 } // namespace gpu |
| OLD | NEW |