Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: ui/accelerated_widget_mac/ca_layer_tree_unittest_mac.mm

Issue 1901253002: Mac: Towards moving CALayerTree to the browser proc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove BUILD.gn Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/accelerated_widget_mac/ca_layer_tree_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "base/mac/sdk_forward_declarations.h" 7 #include "base/mac/sdk_forward_declarations.h"
8 #include "gpu/GLES2/gl2extchromium.h" 8 #include "gpu/GLES2/gl2extchromium.h"
9 #include "gpu/ipc/service/ca_layer_tree_mac.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/accelerated_widget_mac/ca_layer_tree_mac.h"
12 #include "ui/gfx/geometry/dip_util.h" 12 #include "ui/gfx/geometry/dip_util.h"
13 #include "ui/gfx/mac/io_surface.h" 13 #include "ui/gfx/mac/io_surface.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 16
17 class CALayerTreeTest : public testing::Test { 17 class CALayerTreeTest : public testing::Test {
18 protected: 18 protected:
19 void SetUp() override { 19 void SetUp() override {
20 superlayer_.reset([[CALayer alloc] init]); 20 superlayer_.reset([[CALayer alloc] init]);
21 } 21 }
(...skipping 11 matching lines...) Expand all
33 gfx::Transform transform; 33 gfx::Transform transform;
34 transform.Translate(10, 20); 34 transform.Translate(10, 20);
35 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f); 35 gfx::RectF contents_rect(0.0f, 0.25f, 0.5f, 0.75f);
36 gfx::Rect rect(16, 32, 64, 128); 36 gfx::Rect rect(16, 32, 64, 128);
37 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); 37 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0);
38 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; 38 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM;
39 float opacity = 0.5f; 39 float opacity = 0.5f;
40 float scale_factor = 1.0f; 40 float scale_factor = 1.0f;
41 bool result = false; 41 bool result = false;
42 42
43 std::unique_ptr<CALayerTree> ca_layer_tree; 43 std::unique_ptr<ui::CALayerTree> ca_layer_tree;
44 CALayer* root_layer = nil; 44 CALayer* root_layer = nil;
45 CALayer* clip_and_sorting_layer = nil; 45 CALayer* clip_and_sorting_layer = nil;
46 CALayer* transform_layer = nil; 46 CALayer* transform_layer = nil;
47 CALayer* content_layer = nil; 47 CALayer* content_layer = nil;
48 48
49 // Validate the initial values. 49 // Validate the initial values.
50 { 50 {
51 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 51 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
52 result = new_ca_layer_tree->ScheduleCALayer( 52 result = new_ca_layer_tree->ScheduleCALayer(
53 is_clipped, 53 is_clipped,
54 clip_rect, 54 clip_rect,
55 sorting_context_id, 55 sorting_context_id,
56 transform, 56 transform,
57 io_surface, 57 io_surface,
58 contents_rect, 58 contents_rect,
59 rect, 59 rect,
60 background_color, 60 background_color,
61 edge_aa_mask, 61 edge_aa_mask,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); 99 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds]));
100 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]); 100 EXPECT_EQ(kCALayerLeftEdge, [content_layer edgeAntialiasingMask]);
101 EXPECT_EQ(opacity, [content_layer opacity]); 101 EXPECT_EQ(opacity, [content_layer opacity]);
102 if ([content_layer respondsToSelector:(@selector(contentsScale))]) 102 if ([content_layer respondsToSelector:(@selector(contentsScale))])
103 EXPECT_EQ(scale_factor, [content_layer contentsScale]); 103 EXPECT_EQ(scale_factor, [content_layer contentsScale]);
104 } 104 }
105 105
106 // Update just the clip rect and re-commit. 106 // Update just the clip rect and re-commit.
107 { 107 {
108 clip_rect = gfx::Rect(4, 8, 16, 32); 108 clip_rect = gfx::Rect(4, 8, 16, 32);
109 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 109 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
110 result = new_ca_layer_tree->ScheduleCALayer( 110 result = new_ca_layer_tree->ScheduleCALayer(
111 is_clipped, 111 is_clipped,
112 clip_rect, 112 clip_rect,
113 sorting_context_id, 113 sorting_context_id,
114 transform, 114 transform,
115 io_surface, 115 io_surface,
116 contents_rect, 116 contents_rect,
117 rect, 117 rect,
118 background_color, 118 background_color,
119 edge_aa_mask, 119 edge_aa_mask,
(...skipping 20 matching lines...) Expand all
140 gfx::Point([clip_and_sorting_layer position])); 140 gfx::Point([clip_and_sorting_layer position]));
141 EXPECT_EQ(-clip_rect.origin().x(), 141 EXPECT_EQ(-clip_rect.origin().x(),
142 [clip_and_sorting_layer sublayerTransform].m41); 142 [clip_and_sorting_layer sublayerTransform].m41);
143 EXPECT_EQ(-clip_rect.origin().y(), 143 EXPECT_EQ(-clip_rect.origin().y(),
144 [clip_and_sorting_layer sublayerTransform].m42); 144 [clip_and_sorting_layer sublayerTransform].m42);
145 } 145 }
146 146
147 // Disable clipping and re-commit. 147 // Disable clipping and re-commit.
148 { 148 {
149 is_clipped = false; 149 is_clipped = false;
150 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 150 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
151 result = new_ca_layer_tree->ScheduleCALayer( 151 result = new_ca_layer_tree->ScheduleCALayer(
152 is_clipped, 152 is_clipped,
153 clip_rect, 153 clip_rect,
154 sorting_context_id, 154 sorting_context_id,
155 transform, 155 transform,
156 io_surface, 156 io_surface,
157 contents_rect, 157 contents_rect,
158 rect, 158 rect,
159 background_color, 159 background_color,
160 edge_aa_mask, 160 edge_aa_mask,
(...skipping 17 matching lines...) Expand all
178 EXPECT_EQ(gfx::Rect(), gfx::Rect([clip_and_sorting_layer bounds])); 178 EXPECT_EQ(gfx::Rect(), gfx::Rect([clip_and_sorting_layer bounds]));
179 EXPECT_EQ(gfx::Point(), gfx::Point([clip_and_sorting_layer position])); 179 EXPECT_EQ(gfx::Point(), gfx::Point([clip_and_sorting_layer position]));
180 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m41); 180 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m41);
181 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m42); 181 EXPECT_EQ(0.0, [clip_and_sorting_layer sublayerTransform].m42);
182 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); 182 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]);
183 } 183 }
184 184
185 // Change the transform and re-commit. 185 // Change the transform and re-commit.
186 { 186 {
187 transform.Translate(5, 5); 187 transform.Translate(5, 5);
188 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 188 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
189 result = new_ca_layer_tree->ScheduleCALayer( 189 result = new_ca_layer_tree->ScheduleCALayer(
190 is_clipped, 190 is_clipped,
191 clip_rect, 191 clip_rect,
192 sorting_context_id, 192 sorting_context_id,
193 transform, 193 transform,
194 io_surface, 194 io_surface,
195 contents_rect, 195 contents_rect,
196 rect, 196 rect,
197 background_color, 197 background_color,
198 edge_aa_mask, 198 edge_aa_mask,
(...skipping 15 matching lines...) Expand all
214 // Validate the transform layer. 214 // Validate the transform layer.
215 EXPECT_EQ(transform.matrix().get(3, 0), 215 EXPECT_EQ(transform.matrix().get(3, 0),
216 [transform_layer sublayerTransform].m41); 216 [transform_layer sublayerTransform].m41);
217 EXPECT_EQ(transform.matrix().get(3, 1), 217 EXPECT_EQ(transform.matrix().get(3, 1),
218 [transform_layer sublayerTransform].m42); 218 [transform_layer sublayerTransform].m42);
219 } 219 }
220 220
221 // Change the edge antialiasing mask and commit. 221 // Change the edge antialiasing mask and commit.
222 { 222 {
223 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM; 223 edge_aa_mask = GL_CA_LAYER_EDGE_TOP_CHROMIUM;
224 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 224 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
225 result = new_ca_layer_tree->ScheduleCALayer( 225 result = new_ca_layer_tree->ScheduleCALayer(
226 is_clipped, 226 is_clipped,
227 clip_rect, 227 clip_rect,
228 sorting_context_id, 228 sorting_context_id,
229 transform, 229 transform,
230 io_surface, 230 io_surface,
231 contents_rect, 231 contents_rect,
232 rect, 232 rect,
233 background_color, 233 background_color,
234 edge_aa_mask, 234 edge_aa_mask,
(...skipping 13 matching lines...) Expand all
248 [[clip_and_sorting_layer sublayers] objectAtIndex:0]); 248 [[clip_and_sorting_layer sublayers] objectAtIndex:0]);
249 EXPECT_EQ(1u, [[transform_layer sublayers] count]); 249 EXPECT_EQ(1u, [[transform_layer sublayers] count]);
250 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 250 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
251 251
252 // Validate the content layer. Note that top and bottom edges flip. 252 // Validate the content layer. Note that top and bottom edges flip.
253 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); 253 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]);
254 } 254 }
255 255
256 // Change the contents and commit. 256 // Change the contents and commit.
257 { 257 {
258 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 258 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
259 result = new_ca_layer_tree->ScheduleCALayer( 259 result = new_ca_layer_tree->ScheduleCALayer(
260 is_clipped, 260 is_clipped,
261 clip_rect, 261 clip_rect,
262 sorting_context_id, 262 sorting_context_id,
263 transform, 263 transform,
264 nullptr, 264 nullptr,
265 contents_rect, 265 contents_rect,
266 rect, 266 rect,
267 background_color, 267 background_color,
268 edge_aa_mask, 268 edge_aa_mask,
(...skipping 15 matching lines...) Expand all
284 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 284 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
285 285
286 // Validate the content layer. Note that edge anti-aliasing no longer flips. 286 // Validate the content layer. Note that edge anti-aliasing no longer flips.
287 EXPECT_EQ(nil, [content_layer contents]); 287 EXPECT_EQ(nil, [content_layer contents]);
288 EXPECT_EQ(kCALayerTopEdge, [content_layer edgeAntialiasingMask]); 288 EXPECT_EQ(kCALayerTopEdge, [content_layer edgeAntialiasingMask]);
289 } 289 }
290 290
291 // Change the rect size. 291 // Change the rect size.
292 { 292 {
293 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16)); 293 rect = gfx::Rect(rect.origin(), gfx::Size(32, 16));
294 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 294 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
295 result = new_ca_layer_tree->ScheduleCALayer( 295 result = new_ca_layer_tree->ScheduleCALayer(
296 is_clipped, 296 is_clipped,
297 clip_rect, 297 clip_rect,
298 sorting_context_id, 298 sorting_context_id,
299 transform, 299 transform,
300 nullptr, 300 nullptr,
301 contents_rect, 301 contents_rect,
302 rect, 302 rect,
303 background_color, 303 background_color,
304 edge_aa_mask, 304 edge_aa_mask,
(...skipping 15 matching lines...) Expand all
320 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 320 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
321 321
322 // Validate the content layer. 322 // Validate the content layer.
323 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); 323 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position]));
324 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); 324 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds]));
325 } 325 }
326 326
327 // Change the rect position. 327 // Change the rect position.
328 { 328 {
329 rect = gfx::Rect(gfx::Point(16, 4), rect.size()); 329 rect = gfx::Rect(gfx::Point(16, 4), rect.size());
330 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 330 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
331 result = new_ca_layer_tree->ScheduleCALayer( 331 result = new_ca_layer_tree->ScheduleCALayer(
332 is_clipped, 332 is_clipped,
333 clip_rect, 333 clip_rect,
334 sorting_context_id, 334 sorting_context_id,
335 transform, 335 transform,
336 nullptr, 336 nullptr,
337 contents_rect, 337 contents_rect,
338 rect, 338 rect,
339 background_color, 339 background_color,
340 edge_aa_mask, 340 edge_aa_mask,
(...skipping 15 matching lines...) Expand all
356 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 356 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
357 357
358 // Validate the content layer. 358 // Validate the content layer.
359 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position])); 359 EXPECT_EQ(rect.origin(), gfx::Point([content_layer position]));
360 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds])); 360 EXPECT_EQ(gfx::Rect(rect.size()), gfx::Rect([content_layer bounds]));
361 } 361 }
362 362
363 // Change the opacity. 363 // Change the opacity.
364 { 364 {
365 opacity = 1.0f; 365 opacity = 1.0f;
366 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 366 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
367 result = new_ca_layer_tree->ScheduleCALayer( 367 result = new_ca_layer_tree->ScheduleCALayer(
368 is_clipped, 368 is_clipped,
369 clip_rect, 369 clip_rect,
370 sorting_context_id, 370 sorting_context_id,
371 transform, 371 transform,
372 nullptr, 372 nullptr,
373 contents_rect, 373 contents_rect,
374 rect, 374 rect,
375 background_color, 375 background_color,
376 edge_aa_mask, 376 edge_aa_mask,
(...skipping 14 matching lines...) Expand all
391 EXPECT_EQ(1u, [[transform_layer sublayers] count]); 391 EXPECT_EQ(1u, [[transform_layer sublayers] count]);
392 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 392 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
393 393
394 // Validate the content layer. 394 // Validate the content layer.
395 EXPECT_EQ(opacity, [content_layer opacity]); 395 EXPECT_EQ(opacity, [content_layer opacity]);
396 } 396 }
397 397
398 // Add the clipping and IOSurface contents back. 398 // Add the clipping and IOSurface contents back.
399 { 399 {
400 is_clipped = true; 400 is_clipped = true;
401 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 401 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
402 result = new_ca_layer_tree->ScheduleCALayer( 402 result = new_ca_layer_tree->ScheduleCALayer(
403 is_clipped, 403 is_clipped,
404 clip_rect, 404 clip_rect,
405 sorting_context_id, 405 sorting_context_id,
406 transform, 406 transform,
407 io_surface, 407 io_surface,
408 contents_rect, 408 contents_rect,
409 rect, 409 rect,
410 background_color, 410 background_color,
411 edge_aa_mask, 411 edge_aa_mask,
(...skipping 15 matching lines...) Expand all
427 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]); 427 EXPECT_EQ(content_layer, [[transform_layer sublayers] objectAtIndex:0]);
428 428
429 // Validate the content layer. 429 // Validate the content layer.
430 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]); 430 EXPECT_EQ(static_cast<id>(io_surface.get()), [content_layer contents]);
431 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]); 431 EXPECT_EQ(kCALayerBottomEdge, [content_layer edgeAntialiasingMask]);
432 } 432 }
433 433
434 // Change the scale factor. This should result in a new tree being created. 434 // Change the scale factor. This should result in a new tree being created.
435 { 435 {
436 scale_factor = 2.0f; 436 scale_factor = 2.0f;
437 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 437 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
438 result = new_ca_layer_tree->ScheduleCALayer( 438 result = new_ca_layer_tree->ScheduleCALayer(
439 is_clipped, 439 is_clipped,
440 clip_rect, 440 clip_rect,
441 sorting_context_id, 441 sorting_context_id,
442 transform, 442 transform,
443 io_surface, 443 io_surface,
444 contents_rect, 444 contents_rect,
445 rect, 445 rect,
446 background_color, 446 background_color,
447 edge_aa_mask, 447 edge_aa_mask,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // * 1 non-flat (new sorting context layer) 521 // * 1 non-flat (new sorting context layer)
522 // * 2 flat and the same (new sorting context layer, 1 transform layer) 522 // * 2 flat and the same (new sorting context layer, 1 transform layer)
523 gfx::Transform transforms[5]; 523 gfx::Transform transforms[5];
524 transforms[0].Translate(10, 10); 524 transforms[0].Translate(10, 10);
525 transforms[1].RotateAboutZAxis(45.0f); 525 transforms[1].RotateAboutZAxis(45.0f);
526 transforms[2].RotateAboutYAxis(45.0f); 526 transforms[2].RotateAboutYAxis(45.0f);
527 transforms[3].Translate(10, 10); 527 transforms[3].Translate(10, 10);
528 transforms[4].Translate(10, 10); 528 transforms[4].Translate(10, 10);
529 529
530 // Schedule and commit the layers. 530 // Schedule and commit the layers.
531 std::unique_ptr<CALayerTree> ca_layer_tree(new CALayerTree); 531 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree);
532 for (size_t i = 0; i < 5; ++i) { 532 for (size_t i = 0; i < 5; ++i) {
533 bool result = ca_layer_tree->ScheduleCALayer( 533 bool result = ca_layer_tree->ScheduleCALayer(
534 is_clipped, 534 is_clipped,
535 clip_rect, 535 clip_rect,
536 sorting_context_id, 536 sorting_context_id,
537 transforms[i], 537 transforms[i],
538 io_surfaces[i], 538 io_surfaces[i],
539 contents_rect, 539 contents_rect,
540 rect, 540 rect,
541 background_color, 541 background_color,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 float scale_factor = 1.0f; 606 float scale_factor = 1.0f;
607 607
608 // We'll use the IOSurface contents to identify the content layers. 608 // We'll use the IOSurface contents to identify the content layers.
609 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3]; 609 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces[3];
610 for (size_t i = 0; i < 3; ++i) { 610 for (size_t i = 0; i < 3; ++i) {
611 io_surfaces[i].reset(gfx::CreateIOSurface( 611 io_surfaces[i].reset(gfx::CreateIOSurface(
612 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888)); 612 gfx::Size(256, 256), gfx::BufferFormat::BGRA_8888));
613 } 613 }
614 614
615 // Schedule and commit the layers. 615 // Schedule and commit the layers.
616 std::unique_ptr<CALayerTree> ca_layer_tree(new CALayerTree); 616 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree);
617 for (size_t i = 0; i < 3; ++i) { 617 for (size_t i = 0; i < 3; ++i) {
618 bool result = ca_layer_tree->ScheduleCALayer( 618 bool result = ca_layer_tree->ScheduleCALayer(
619 is_clipped, 619 is_clipped,
620 clip_rect, 620 clip_rect,
621 sorting_context_ids[i], 621 sorting_context_ids[i],
622 transform, 622 transform,
623 io_surfaces[i], 623 io_surfaces[i],
624 contents_rect, 624 contents_rect,
625 rect, 625 rect,
626 background_color, 626 background_color,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 float opacity = 1.0f; 676 float opacity = 1.0f;
677 677
678 // Vary the clipping parameters within sorting contexts. 678 // Vary the clipping parameters within sorting contexts.
679 bool is_clippeds[3] = { true, true, false}; 679 bool is_clippeds[3] = { true, true, false};
680 gfx::Rect clip_rects[3] = { 680 gfx::Rect clip_rects[3] = {
681 gfx::Rect(0, 0, 16, 16), 681 gfx::Rect(0, 0, 16, 16),
682 gfx::Rect(4, 8, 16, 32), 682 gfx::Rect(4, 8, 16, 32),
683 gfx::Rect(0, 0, 16, 16) 683 gfx::Rect(0, 0, 16, 16)
684 }; 684 };
685 685
686 std::unique_ptr<CALayerTree> ca_layer_tree(new CALayerTree); 686 std::unique_ptr<ui::CALayerTree> ca_layer_tree(new ui::CALayerTree);
687 // First send the various clip parameters to sorting context zero. This is 687 // First send the various clip parameters to sorting context zero. This is
688 // legitimate. 688 // legitimate.
689 for (size_t i = 0; i < 3; ++i) { 689 for (size_t i = 0; i < 3; ++i) {
690 int sorting_context_id = 0; 690 int sorting_context_id = 0;
691 bool result = ca_layer_tree->ScheduleCALayer( 691 bool result = ca_layer_tree->ScheduleCALayer(
692 is_clippeds[i], 692 is_clippeds[i],
693 clip_rects[i], 693 clip_rects[i],
694 sorting_context_id, 694 sorting_context_id,
695 transform, 695 transform,
696 io_surface, 696 io_surface,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 int sorting_context_id = 0; 748 int sorting_context_id = 0;
749 gfx::Transform transform; 749 gfx::Transform transform;
750 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f); 750 gfx::RectF contents_rect(0.0f, 0.0f, 1.0f, 1.0f);
751 gfx::Rect rect(16, 32, 64, 128); 751 gfx::Rect rect(16, 32, 64, 128);
752 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0); 752 unsigned background_color = SkColorSetARGB(0xFF, 0xFF, 0, 0);
753 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM; 753 unsigned edge_aa_mask = GL_CA_LAYER_EDGE_LEFT_CHROMIUM;
754 float opacity = 0.5f; 754 float opacity = 0.5f;
755 float scale_factor = 1.0f; 755 float scale_factor = 1.0f;
756 bool result = false; 756 bool result = false;
757 757
758 std::unique_ptr<CALayerTree> ca_layer_tree; 758 std::unique_ptr<ui::CALayerTree> ca_layer_tree;
759 CALayer* root_layer = nil; 759 CALayer* root_layer = nil;
760 CALayer* clip_and_sorting_layer = nil; 760 CALayer* clip_and_sorting_layer = nil;
761 CALayer* transform_layer = nil; 761 CALayer* transform_layer = nil;
762 CALayer* content_layer1 = nil; 762 CALayer* content_layer1 = nil;
763 CALayer* content_layer2 = nil; 763 CALayer* content_layer2 = nil;
764 CALayer* content_layer3 = nil; 764 CALayer* content_layer3 = nil;
765 765
766 // Validate the initial values. 766 // Validate the initial values.
767 { 767 {
768 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 768 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
769 result = new_ca_layer_tree->ScheduleCALayer( 769 result = new_ca_layer_tree->ScheduleCALayer(
770 is_clipped, clip_rect, sorting_context_id, transform, io_surface, 770 is_clipped, clip_rect, sorting_context_id, transform, io_surface,
771 contents_rect, rect, background_color, edge_aa_mask, opacity); 771 contents_rect, rect, background_color, edge_aa_mask, opacity);
772 EXPECT_TRUE(result); 772 EXPECT_TRUE(result);
773 new_ca_layer_tree->CommitScheduledCALayers( 773 new_ca_layer_tree->CommitScheduledCALayers(
774 superlayer_, std::move(ca_layer_tree), scale_factor); 774 superlayer_, std::move(ca_layer_tree), scale_factor);
775 std::swap(new_ca_layer_tree, ca_layer_tree); 775 std::swap(new_ca_layer_tree, ca_layer_tree);
776 776
777 // Validate the tree structure. 777 // Validate the tree structure.
778 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); 778 EXPECT_EQ(1u, [[superlayer_ sublayers] count]);
779 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; 779 root_layer = [[superlayer_ sublayers] objectAtIndex:0];
780 EXPECT_EQ(1u, [[root_layer sublayers] count]); 780 EXPECT_EQ(1u, [[root_layer sublayers] count]);
781 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; 781 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0];
782 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); 782 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]);
783 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; 783 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0];
784 EXPECT_EQ(1u, [[transform_layer sublayers] count]); 784 EXPECT_EQ(1u, [[transform_layer sublayers] count]);
785 content_layer1 = [[transform_layer sublayers] objectAtIndex:0]; 785 content_layer1 = [[transform_layer sublayers] objectAtIndex:0];
786 786
787 // Validate the content layer. 787 // Validate the content layer.
788 EXPECT_FALSE([content_layer1 788 EXPECT_FALSE([content_layer1
789 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); 789 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]);
790 } 790 }
791 791
792 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), 792 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256),
793 gfx::BufferFormat::YUV_420_BIPLANAR)); 793 gfx::BufferFormat::YUV_420_BIPLANAR));
794 794
795 // Pass another frame. 795 // Pass another frame.
796 { 796 {
797 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 797 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
798 result = new_ca_layer_tree->ScheduleCALayer( 798 result = new_ca_layer_tree->ScheduleCALayer(
799 is_clipped, clip_rect, sorting_context_id, transform, io_surface, 799 is_clipped, clip_rect, sorting_context_id, transform, io_surface,
800 contents_rect, rect, background_color, edge_aa_mask, opacity); 800 contents_rect, rect, background_color, edge_aa_mask, opacity);
801 EXPECT_TRUE(result); 801 EXPECT_TRUE(result);
802 new_ca_layer_tree->CommitScheduledCALayers( 802 new_ca_layer_tree->CommitScheduledCALayers(
803 superlayer_, std::move(ca_layer_tree), scale_factor); 803 superlayer_, std::move(ca_layer_tree), scale_factor);
804 std::swap(new_ca_layer_tree, ca_layer_tree); 804 std::swap(new_ca_layer_tree, ca_layer_tree);
805 805
806 // Validate the tree structure. 806 // Validate the tree structure.
807 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); 807 EXPECT_EQ(1u, [[superlayer_ sublayers] count]);
(...skipping 10 matching lines...) Expand all
818 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); 818 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]);
819 EXPECT_EQ(content_layer2, content_layer1); 819 EXPECT_EQ(content_layer2, content_layer1);
820 } 820 }
821 821
822 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256), 822 io_surface.reset(gfx::CreateIOSurface(gfx::Size(256, 256),
823 gfx::BufferFormat::YUV_420_BIPLANAR)); 823 gfx::BufferFormat::YUV_420_BIPLANAR));
824 824
825 // Pass a frame that is clipped. 825 // Pass a frame that is clipped.
826 contents_rect = gfx::RectF(0, 0, 1, 0.9); 826 contents_rect = gfx::RectF(0, 0, 1, 0.9);
827 { 827 {
828 std::unique_ptr<CALayerTree> new_ca_layer_tree(new CALayerTree); 828 std::unique_ptr<ui::CALayerTree> new_ca_layer_tree(new ui::CALayerTree);
829 result = new_ca_layer_tree->ScheduleCALayer( 829 result = new_ca_layer_tree->ScheduleCALayer(
830 is_clipped, clip_rect, sorting_context_id, transform, io_surface, 830 is_clipped, clip_rect, sorting_context_id, transform, io_surface,
831 contents_rect, rect, background_color, edge_aa_mask, opacity); 831 contents_rect, rect, background_color, edge_aa_mask, opacity);
832 EXPECT_TRUE(result); 832 EXPECT_TRUE(result);
833 new_ca_layer_tree->CommitScheduledCALayers( 833 new_ca_layer_tree->CommitScheduledCALayers(
834 superlayer_, std::move(ca_layer_tree), scale_factor); 834 superlayer_, std::move(ca_layer_tree), scale_factor);
835 std::swap(new_ca_layer_tree, ca_layer_tree); 835 std::swap(new_ca_layer_tree, ca_layer_tree);
836 836
837 // Validate the tree structure. 837 // Validate the tree structure.
838 EXPECT_EQ(1u, [[superlayer_ sublayers] count]); 838 EXPECT_EQ(1u, [[superlayer_ sublayers] count]);
839 root_layer = [[superlayer_ sublayers] objectAtIndex:0]; 839 root_layer = [[superlayer_ sublayers] objectAtIndex:0];
840 EXPECT_EQ(1u, [[root_layer sublayers] count]); 840 EXPECT_EQ(1u, [[root_layer sublayers] count]);
841 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0]; 841 clip_and_sorting_layer = [[root_layer sublayers] objectAtIndex:0];
842 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]); 842 EXPECT_EQ(1u, [[clip_and_sorting_layer sublayers] count]);
843 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0]; 843 transform_layer = [[clip_and_sorting_layer sublayers] objectAtIndex:0];
844 EXPECT_EQ(1u, [[transform_layer sublayers] count]); 844 EXPECT_EQ(1u, [[transform_layer sublayers] count]);
845 content_layer3 = [[transform_layer sublayers] objectAtIndex:0]; 845 content_layer3 = [[transform_layer sublayers] objectAtIndex:0];
846 846
847 // Validate the content layer. 847 // Validate the content layer.
848 EXPECT_FALSE([content_layer3 848 EXPECT_FALSE([content_layer3
849 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]); 849 isKindOfClass:NSClassFromString(@"AVSampleBufferDisplayLayer")]);
850 EXPECT_EQ(content_layer3, content_layer2); 850 EXPECT_EQ(content_layer3, content_layer2);
851 } 851 }
852 } 852 }
853 853
854 } // namespace gpu 854 } // namespace gpu
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/ca_layer_tree_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698