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

Side by Side Diff: content/common/gpu/ca_layer_tree_mac.mm

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/gpu/ca_layer_tree_mac.h"
6
7 #include <AVFoundation/AVFoundation.h>
8 #include <CoreMedia/CoreMedia.h>
9 #include <CoreVideo/CoreVideo.h>
10
11 #include "base/command_line.h"
12 #include "base/mac/sdk_forward_declarations.h"
13 #include "base/trace_event/trace_event.h"
14 #include "gpu/GLES2/gl2extchromium.h"
15 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/base/cocoa/animation_utils.h"
17 #include "ui/base/ui_base_switches.h"
18 #include "ui/gfx/geometry/dip_util.h"
19
20 #if !defined(MAC_OS_X_VERSION_10_8) || \
21 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
22 extern NSString* const AVLayerVideoGravityResize;
23 extern "C" void NSAccessibilityPostNotificationWithUserInfo(
24 id object,
25 NSString* notification,
26 NSDictionary* user_info);
27 extern "C" OSStatus CMSampleBufferCreateForImageBuffer(
28 CFAllocatorRef,
29 CVImageBufferRef,
30 Boolean dataReady,
31 CMSampleBufferMakeDataReadyCallback,
32 void*,
33 CMVideoFormatDescriptionRef,
34 const CMSampleTimingInfo*,
35 CMSampleBufferRef*);
36 extern "C" CFArrayRef CMSampleBufferGetSampleAttachmentsArray(CMSampleBufferRef,
37 Boolean);
38 extern "C" OSStatus CMVideoFormatDescriptionCreateForImageBuffer(
39 CFAllocatorRef,
40 CVImageBufferRef,
41 CMVideoFormatDescriptionRef*);
42 extern "C" CMTime CMTimeMake(int64_t, int32_t);
43 extern CFStringRef const kCMSampleAttachmentKey_DisplayImmediately;
44 extern const CMTime kCMTimeInvalid;
45 #endif // MAC_OS_X_VERSION_10_8
46
47 namespace content {
48
49 namespace {
50
51 // This will enqueue |io_surface| to be drawn by |av_layer| by wrapping
52 // |io_surface| in a CVPixelBuffer. This will increase the in-use count
53 // of and retain |io_surface| until it is no longer being displayed.
54 bool AVSampleBufferDisplayLayerEnqueueIOSurface(
55 AVSampleBufferDisplayLayer* av_layer,
56 IOSurfaceRef io_surface) {
57 OSStatus os_status = noErr;
58 CVReturn cv_return = kCVReturnSuccess;
59
60 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer;
61 cv_return = CVPixelBufferCreateWithIOSurface(
62 nullptr, io_surface, nullptr, cv_pixel_buffer.InitializeInto());
63 if (cv_return != kCVReturnSuccess) {
64 LOG(ERROR) << "CVPixelBufferCreateWithIOSurface failed with " << cv_return;
65 return false;
66 }
67
68 base::ScopedCFTypeRef<CMVideoFormatDescriptionRef> video_info;
69 os_status = CMVideoFormatDescriptionCreateForImageBuffer(
70 nullptr, cv_pixel_buffer, video_info.InitializeInto());
71 if (os_status != noErr) {
72 LOG(ERROR) << "CMVideoFormatDescriptionCreateForImageBuffer failed with "
73 << os_status;
74 return false;
75 }
76
77 // The frame time doesn't matter because we will specify to display
78 // immediately.
79 CMTime frame_time = CMTimeMake(0, 1);
80 CMSampleTimingInfo timing_info = {frame_time, frame_time, kCMTimeInvalid};
81
82 base::ScopedCFTypeRef<CMSampleBufferRef> sample_buffer;
83 os_status = CMSampleBufferCreateForImageBuffer(
84 nullptr, cv_pixel_buffer, YES, nullptr, nullptr, video_info, &timing_info,
85 sample_buffer.InitializeInto());
86 if (os_status != noErr) {
87 LOG(ERROR) << "CMSampleBufferCreateForImageBuffer failed with "
88 << os_status;
89 return false;
90 }
91
92 // Specify to display immediately via the sample buffer attachments.
93 CFArrayRef attachments =
94 CMSampleBufferGetSampleAttachmentsArray(sample_buffer, YES);
95 if (!attachments) {
96 LOG(ERROR) << "CMSampleBufferGetSampleAttachmentsArray failed";
97 return false;
98 }
99 if (CFArrayGetCount(attachments) < 1) {
100 LOG(ERROR) << "CMSampleBufferGetSampleAttachmentsArray result was empty";
101 return false;
102 }
103 CFMutableDictionaryRef attachments_dictionary =
104 reinterpret_cast<CFMutableDictionaryRef>(
105 const_cast<void*>(CFArrayGetValueAtIndex(attachments, 0)));
106 if (!attachments_dictionary) {
107 LOG(ERROR) << "Failed to get attachments dictionary";
108 return false;
109 }
110 CFDictionarySetValue(attachments_dictionary,
111 kCMSampleAttachmentKey_DisplayImmediately,
112 kCFBooleanTrue);
113
114 [av_layer enqueueSampleBuffer:sample_buffer];
115 return true;
116 }
117
118 } // namespace
119
120 CALayerTree::CALayerTree() {}
121 CALayerTree::~CALayerTree() {}
122
123 bool CALayerTree::ScheduleCALayer(
124 bool is_clipped,
125 const gfx::Rect& clip_rect,
126 unsigned sorting_context_id,
127 const gfx::Transform& transform,
128 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
129 const gfx::RectF& contents_rect,
130 const gfx::Rect& rect,
131 unsigned background_color,
132 unsigned edge_aa_mask,
133 float opacity) {
134 // Excessive logging to debug white screens (crbug.com/583805).
135 // TODO(ccameron): change this back to a DLOG.
136 if (has_committed_) {
137 LOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers.";
138 return false;
139 }
140 return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id,
141 transform, io_surface, contents_rect, rect,
142 background_color, edge_aa_mask, opacity);
143 }
144
145 void CALayerTree::CommitScheduledCALayers(CALayer* superlayer,
146 scoped_ptr<CALayerTree> old_tree,
147 float scale_factor) {
148 TRACE_EVENT0("gpu", "CALayerTree::CommitScheduledCALayers");
149 RootLayer* old_root_layer = nullptr;
150 if (old_tree) {
151 DCHECK(old_tree->has_committed_);
152 if (old_tree->scale_factor_ == scale_factor)
153 old_root_layer = &old_tree->root_layer_;
154 }
155
156 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor);
157 // If there are any extra CALayers in |old_tree| that were not stolen by this
158 // tree, they will be removed from the CALayer tree in this deallocation.
159 old_tree.reset();
160 has_committed_ = true;
161 scale_factor_ = scale_factor;
162 }
163
164 CALayerTree::RootLayer::RootLayer() {}
165
166 // Note that for all destructors, the the CALayer will have been reset to nil if
167 // another layer has taken it.
168 CALayerTree::RootLayer::~RootLayer() {
169 [ca_layer removeFromSuperlayer];
170 }
171
172 CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
173 bool is_clipped,
174 gfx::Rect clip_rect,
175 unsigned sorting_context_id,
176 bool is_singleton_sorting_context)
177 : is_clipped(is_clipped),
178 clip_rect(clip_rect),
179 sorting_context_id(sorting_context_id),
180 is_singleton_sorting_context(is_singleton_sorting_context) {}
181
182 CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
183 ClipAndSortingLayer&& layer)
184 : transform_layers(std::move(layer.transform_layers)),
185 is_clipped(layer.is_clipped),
186 clip_rect(layer.clip_rect),
187 sorting_context_id(layer.sorting_context_id),
188 is_singleton_sorting_context(
189 layer.is_singleton_sorting_context),
190 ca_layer(layer.ca_layer) {
191 // Ensure that the ca_layer be reset, so that when the destructor is called,
192 // the layer hierarchy is unaffected.
193 // TODO(ccameron): Add a move constructor for scoped_nsobject to do this
194 // automatically.
195 layer.ca_layer.reset();
196 }
197
198 CALayerTree::ClipAndSortingLayer::~ClipAndSortingLayer() {
199 [ca_layer removeFromSuperlayer];
200 }
201
202 CALayerTree::TransformLayer::TransformLayer(const gfx::Transform& transform)
203 : transform(transform) {}
204
205 CALayerTree::TransformLayer::TransformLayer(TransformLayer&& layer)
206 : transform(layer.transform),
207 content_layers(std::move(layer.content_layers)),
208 ca_layer(layer.ca_layer) {
209 layer.ca_layer.reset();
210 }
211
212 CALayerTree::TransformLayer::~TransformLayer() {
213 [ca_layer removeFromSuperlayer];
214 }
215
216 CALayerTree::ContentLayer::ContentLayer(
217 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
218 const gfx::RectF& contents_rect,
219 const gfx::Rect& rect,
220 unsigned background_color,
221 unsigned edge_aa_mask,
222 float opacity)
223 : io_surface(io_surface),
224 contents_rect(contents_rect),
225 rect(rect),
226 background_color(background_color),
227 ca_edge_aa_mask(0),
228 opacity(opacity) {
229 // Because the root layer has setGeometryFlipped:YES, there is some ambiguity
230 // about what exactly top and bottom mean. This ambiguity is resolved in
231 // different ways for solid color CALayers and for CALayers that have content
232 // (surprise!). For CALayers with IOSurface content, the top edge in the AA
233 // mask refers to what appears as the bottom edge on-screen. For CALayers
234 // without content (solid color layers), the top edge in the AA mask is the
235 // top edge on-screen.
236 // https://crbug.com/567946
237 if (edge_aa_mask & GL_CA_LAYER_EDGE_LEFT_CHROMIUM)
238 ca_edge_aa_mask |= kCALayerLeftEdge;
239 if (edge_aa_mask & GL_CA_LAYER_EDGE_RIGHT_CHROMIUM)
240 ca_edge_aa_mask |= kCALayerRightEdge;
241 if (io_surface) {
242 if (edge_aa_mask & GL_CA_LAYER_EDGE_TOP_CHROMIUM)
243 ca_edge_aa_mask |= kCALayerBottomEdge;
244 if (edge_aa_mask & GL_CA_LAYER_EDGE_BOTTOM_CHROMIUM)
245 ca_edge_aa_mask |= kCALayerTopEdge;
246 } else {
247 if (edge_aa_mask & GL_CA_LAYER_EDGE_TOP_CHROMIUM)
248 ca_edge_aa_mask |= kCALayerTopEdge;
249 if (edge_aa_mask & GL_CA_LAYER_EDGE_BOTTOM_CHROMIUM)
250 ca_edge_aa_mask |= kCALayerBottomEdge;
251 }
252
253 // Only allow 4:2:0 frames which fill the layer's contents to be promoted to
254 // AV layers.
255 if (IOSurfaceGetPixelFormat(io_surface) ==
256 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange &&
257 contents_rect == gfx::RectF(0, 0, 1, 1)) {
258 // Leave AVFoundation disabled for now while crashing and flashing bugs are
259 // being investigated.
260 // https://crbug.com/598243, https://crbug.com/598388
261 use_av_layer = false;
262 }
263 }
264
265 CALayerTree::ContentLayer::ContentLayer(ContentLayer&& layer)
266 : io_surface(layer.io_surface),
267 contents_rect(layer.contents_rect),
268 rect(layer.rect),
269 background_color(layer.background_color),
270 ca_edge_aa_mask(layer.ca_edge_aa_mask),
271 opacity(layer.opacity),
272 ca_layer(std::move(layer.ca_layer)),
273 av_layer(std::move(layer.av_layer)),
274 use_av_layer(layer.use_av_layer) {
275 DCHECK(!layer.ca_layer);
276 DCHECK(!layer.av_layer);
277 }
278
279 CALayerTree::ContentLayer::~ContentLayer() {
280 [ca_layer removeFromSuperlayer];
281 }
282
283 bool CALayerTree::RootLayer::AddContentLayer(
284 bool is_clipped,
285 const gfx::Rect& clip_rect,
286 unsigned sorting_context_id,
287 const gfx::Transform& transform,
288 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
289 const gfx::RectF& contents_rect,
290 const gfx::Rect& rect,
291 unsigned background_color,
292 unsigned edge_aa_mask,
293 float opacity) {
294 bool needs_new_clip_and_sorting_layer = true;
295
296 // In sorting_context_id 0, all quads are listed in back-to-front order.
297 // This is accomplished by having the CALayers be siblings of each other.
298 // If a quad has a 3D transform, it is necessary to put it in its own sorting
299 // context, so that it will not intersect with quads before and after it.
300 bool is_singleton_sorting_context =
301 !sorting_context_id && !transform.IsFlat();
302
303 if (!clip_and_sorting_layers.empty()) {
304 ClipAndSortingLayer& current_layer = clip_and_sorting_layers.back();
305 // It is in error to change the clipping settings within a non-zero sorting
306 // context. The result will be incorrect layering and intersection.
307 if (sorting_context_id &&
308 current_layer.sorting_context_id == sorting_context_id &&
309 (current_layer.is_clipped != is_clipped ||
310 current_layer.clip_rect != clip_rect)) {
311 // Excessive logging to debug white screens (crbug.com/583805).
312 // TODO(ccameron): change this back to a DLOG.
313 LOG(ERROR) << "CALayer changed clip inside non-zero sorting context.";
314 return false;
315 }
316 if (!is_singleton_sorting_context &&
317 !current_layer.is_singleton_sorting_context &&
318 current_layer.is_clipped == is_clipped &&
319 current_layer.clip_rect == clip_rect &&
320 current_layer.sorting_context_id == sorting_context_id) {
321 needs_new_clip_and_sorting_layer = false;
322 }
323 }
324 if (needs_new_clip_and_sorting_layer) {
325 clip_and_sorting_layers.push_back(
326 ClipAndSortingLayer(is_clipped, clip_rect, sorting_context_id,
327 is_singleton_sorting_context));
328 }
329 clip_and_sorting_layers.back().AddContentLayer(
330 transform, io_surface, contents_rect, rect, background_color,
331 edge_aa_mask, opacity);
332 return true;
333 }
334
335 void CALayerTree::ClipAndSortingLayer::AddContentLayer(
336 const gfx::Transform& transform,
337 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
338 const gfx::RectF& contents_rect,
339 const gfx::Rect& rect,
340 unsigned background_color,
341 unsigned edge_aa_mask,
342 float opacity) {
343 bool needs_new_transform_layer = true;
344 if (!transform_layers.empty()) {
345 const TransformLayer& current_layer = transform_layers.back();
346 if (current_layer.transform == transform)
347 needs_new_transform_layer = false;
348 }
349 if (needs_new_transform_layer)
350 transform_layers.push_back(TransformLayer(transform));
351 transform_layers.back().AddContentLayer(
352 io_surface, contents_rect, rect, background_color, edge_aa_mask, opacity);
353 }
354
355 void CALayerTree::TransformLayer::AddContentLayer(
356 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
357 const gfx::RectF& contents_rect,
358 const gfx::Rect& rect,
359 unsigned background_color,
360 unsigned edge_aa_mask,
361 float opacity) {
362 content_layers.push_back(ContentLayer(io_surface, contents_rect, rect,
363 background_color, edge_aa_mask,
364 opacity));
365 }
366
367 void CALayerTree::RootLayer::CommitToCA(CALayer* superlayer,
368 RootLayer* old_layer,
369 float scale_factor) {
370 if (old_layer) {
371 DCHECK(old_layer->ca_layer);
372 std::swap(ca_layer, old_layer->ca_layer);
373 } else {
374 ca_layer.reset([[CALayer alloc] init]);
375 [ca_layer setAnchorPoint:CGPointZero];
376 [superlayer setSublayers:nil];
377 [superlayer addSublayer:ca_layer];
378 [superlayer setBorderWidth:0];
379 }
380 // Excessive logging to debug white screens (crbug.com/583805).
381 // TODO(ccameron): change this back to a DCHECK.
382 if ([ca_layer superlayer] != superlayer) {
383 LOG(ERROR) << "CALayerTree root layer not attached to tree.";
384 }
385
386 for (size_t i = 0; i < clip_and_sorting_layers.size(); ++i) {
387 ClipAndSortingLayer* old_clip_and_sorting_layer = nullptr;
388 if (old_layer && i < old_layer->clip_and_sorting_layers.size()) {
389 old_clip_and_sorting_layer = &old_layer->clip_and_sorting_layers[i];
390 }
391 clip_and_sorting_layers[i].CommitToCA(
392 ca_layer.get(), old_clip_and_sorting_layer, scale_factor);
393 }
394 }
395
396 void CALayerTree::ClipAndSortingLayer::CommitToCA(
397 CALayer* superlayer,
398 ClipAndSortingLayer* old_layer,
399 float scale_factor) {
400 bool update_is_clipped = true;
401 bool update_clip_rect = true;
402 if (old_layer) {
403 DCHECK(old_layer->ca_layer);
404 std::swap(ca_layer, old_layer->ca_layer);
405 update_is_clipped = old_layer->is_clipped != is_clipped;
406 update_clip_rect = update_is_clipped || old_layer->clip_rect != clip_rect;
407 } else {
408 ca_layer.reset([[CALayer alloc] init]);
409 [ca_layer setAnchorPoint:CGPointZero];
410 [superlayer addSublayer:ca_layer];
411 }
412 // Excessive logging to debug white screens (crbug.com/583805).
413 // TODO(ccameron): change this back to a DCHECK.
414 if ([ca_layer superlayer] != superlayer) {
415 LOG(ERROR) << "CALayerTree root layer not attached to tree.";
416 }
417
418 if (update_is_clipped)
419 [ca_layer setMasksToBounds:is_clipped];
420
421 if (update_clip_rect) {
422 if (is_clipped) {
423 gfx::RectF dip_clip_rect = gfx::RectF(clip_rect);
424 dip_clip_rect.Scale(1 / scale_factor);
425 [ca_layer setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())];
426 [ca_layer setBounds:CGRectMake(0, 0, dip_clip_rect.width(),
427 dip_clip_rect.height())];
428 [ca_layer
429 setSublayerTransform:CATransform3DMakeTranslation(
430 -dip_clip_rect.x(), -dip_clip_rect.y(), 0)];
431 } else {
432 [ca_layer setPosition:CGPointZero];
433 [ca_layer setBounds:CGRectZero];
434 [ca_layer setSublayerTransform:CATransform3DIdentity];
435 }
436 }
437
438 for (size_t i = 0; i < transform_layers.size(); ++i) {
439 TransformLayer* old_transform_layer = nullptr;
440 if (old_layer && i < old_layer->transform_layers.size())
441 old_transform_layer = &old_layer->transform_layers[i];
442 transform_layers[i].CommitToCA(ca_layer.get(), old_transform_layer,
443 scale_factor);
444 }
445 }
446
447 void CALayerTree::TransformLayer::CommitToCA(CALayer* superlayer,
448 TransformLayer* old_layer,
449 float scale_factor) {
450 bool update_transform = true;
451 if (old_layer) {
452 DCHECK(old_layer->ca_layer);
453 std::swap(ca_layer, old_layer->ca_layer);
454 update_transform = old_layer->transform != transform;
455 } else {
456 ca_layer.reset([[CATransformLayer alloc] init]);
457 [superlayer addSublayer:ca_layer];
458 }
459 DCHECK_EQ([ca_layer superlayer], superlayer);
460
461 if (update_transform) {
462 gfx::Transform pre_scale;
463 gfx::Transform post_scale;
464 pre_scale.Scale(1 / scale_factor, 1 / scale_factor);
465 post_scale.Scale(scale_factor, scale_factor);
466 gfx::Transform conjugated_transform = pre_scale * transform * post_scale;
467
468 CATransform3D ca_transform;
469 conjugated_transform.matrix().asColMajord(&ca_transform.m11);
470 [ca_layer setTransform:ca_transform];
471 }
472
473 for (size_t i = 0; i < content_layers.size(); ++i) {
474 ContentLayer* old_content_layer = nullptr;
475 if (old_layer && i < old_layer->content_layers.size())
476 old_content_layer = &old_layer->content_layers[i];
477 content_layers[i].CommitToCA(ca_layer.get(), old_content_layer,
478 scale_factor);
479 }
480 }
481
482 void CALayerTree::ContentLayer::CommitToCA(CALayer* superlayer,
483 ContentLayer* old_layer,
484 float scale_factor) {
485 bool update_contents = true;
486 bool update_contents_rect = true;
487 bool update_rect = true;
488 bool update_background_color = true;
489 bool update_ca_edge_aa_mask = true;
490 bool update_opacity = true;
491 if (old_layer && old_layer->use_av_layer == use_av_layer) {
492 DCHECK(old_layer->ca_layer);
493 std::swap(ca_layer, old_layer->ca_layer);
494 std::swap(av_layer, old_layer->av_layer);
495 update_contents = old_layer->io_surface != io_surface;
496 update_contents_rect = old_layer->contents_rect != contents_rect;
497 update_rect = old_layer->rect != rect;
498 update_background_color = old_layer->background_color != background_color;
499 update_ca_edge_aa_mask = old_layer->ca_edge_aa_mask != ca_edge_aa_mask;
500 update_opacity = old_layer->opacity != opacity;
501 } else {
502 if (use_av_layer) {
503 av_layer.reset([[AVSampleBufferDisplayLayer alloc] init]);
504 ca_layer.reset([av_layer retain]);
505 [av_layer setVideoGravity:AVLayerVideoGravityResize];
506 } else {
507 ca_layer.reset([[CALayer alloc] init]);
508 }
509 [ca_layer setAnchorPoint:CGPointZero];
510 [superlayer addSublayer:ca_layer];
511 }
512 DCHECK_EQ([ca_layer superlayer], superlayer);
513 bool update_anything = update_contents || update_contents_rect ||
514 update_rect || update_background_color ||
515 update_ca_edge_aa_mask || update_opacity;
516 if (use_av_layer) {
517 if (update_contents)
518 AVSampleBufferDisplayLayerEnqueueIOSurface(av_layer, io_surface);
519 } else {
520 if (update_contents) {
521 [ca_layer setContents:static_cast<id>(io_surface.get())];
522 if ([ca_layer respondsToSelector:(@selector(setContentsScale:))])
523 [ca_layer setContentsScale:scale_factor];
524 }
525 if (update_contents_rect)
526 [ca_layer setContentsRect:contents_rect.ToCGRect()];
527 }
528 if (update_rect) {
529 gfx::RectF dip_rect = gfx::RectF(rect);
530 dip_rect.Scale(1 / scale_factor);
531 [ca_layer setPosition:CGPointMake(dip_rect.x(), dip_rect.y())];
532 [ca_layer setBounds:CGRectMake(0, 0, dip_rect.width(), dip_rect.height())];
533 }
534 if (update_background_color) {
535 CGFloat rgba_color_components[4] = {
536 SkColorGetR(background_color) / 255.,
537 SkColorGetG(background_color) / 255.,
538 SkColorGetB(background_color) / 255.,
539 SkColorGetA(background_color) / 255.,
540 };
541 base::ScopedCFTypeRef<CGColorRef> srgb_background_color(CGColorCreate(
542 CGColorSpaceCreateWithName(kCGColorSpaceSRGB), rgba_color_components));
543 [ca_layer setBackgroundColor:srgb_background_color];
544 }
545 if (update_ca_edge_aa_mask)
546 [ca_layer setEdgeAntialiasingMask:ca_edge_aa_mask];
547 if (update_opacity)
548 [ca_layer setOpacity:opacity];
549
550 static bool show_borders = base::CommandLine::ForCurrentProcess()->HasSwitch(
551 switches::kShowMacOverlayBorders);
552 if (show_borders) {
553 base::ScopedCFTypeRef<CGColorRef> color;
554 if (update_anything) {
555 if (use_av_layer) {
556 // Green represents an AV layer that changed this frame.
557 color.reset(CGColorCreateGenericRGB(0, 1, 0, 1));
558 } else {
559 // Pink represents a CALayer that changed this frame.
560 color.reset(CGColorCreateGenericRGB(1, 0, 1, 1));
561 }
562 } else {
563 // Grey represents a CALayer that has not changed.
564 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1));
565 }
566 [ca_layer setBorderWidth:1];
567 [ca_layer setBorderColor:color];
568 }
569 }
570
571 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/ca_layer_tree_mac.h ('k') | content/common/gpu/ca_layer_tree_unittest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698