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

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

Issue 1917723002: Move logic from ImageTransportSurfaceOverlayMac into ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix grammar Created 4 years, 7 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
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 "ui/accelerated_widget_mac/ca_layer_tree_mac.h" 5 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h"
6 6
7 #include <AVFoundation/AVFoundation.h> 7 #include <AVFoundation/AVFoundation.h>
8 #include <CoreMedia/CoreMedia.h> 8 #include <CoreMedia/CoreMedia.h>
9 #include <CoreVideo/CoreVideo.h> 9 #include <CoreVideo/CoreVideo.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/mac/sdk_forward_declarations.h" 13 #include "base/mac/sdk_forward_declarations.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 LOG(ERROR) << "CVPixelBufferCreateWithIOSurface failed with " << cv_return; 120 LOG(ERROR) << "CVPixelBufferCreateWithIOSurface failed with " << cv_return;
121 return false; 121 return false;
122 } 122 }
123 123
124 return AVSampleBufferDisplayLayerEnqueueCVPixelBuffer(av_layer, 124 return AVSampleBufferDisplayLayerEnqueueCVPixelBuffer(av_layer,
125 cv_pixel_buffer); 125 cv_pixel_buffer);
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 CALayerTree::CALayerTree() {} 130 CARendererLayerTree::CARendererLayerTree() {}
131 CALayerTree::~CALayerTree() {} 131 CARendererLayerTree::~CARendererLayerTree() {}
132 132
133 bool CALayerTree::ScheduleCALayer( 133 bool CARendererLayerTree::ScheduleCALayer(
134 bool is_clipped, 134 bool is_clipped,
135 const gfx::Rect& clip_rect, 135 const gfx::Rect& clip_rect,
136 unsigned sorting_context_id, 136 unsigned sorting_context_id,
137 const gfx::Transform& transform, 137 const gfx::Transform& transform,
138 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 138 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
139 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, 139 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer,
140 const gfx::RectF& contents_rect, 140 const gfx::RectF& contents_rect,
141 const gfx::Rect& rect, 141 const gfx::Rect& rect,
142 unsigned background_color, 142 unsigned background_color,
143 unsigned edge_aa_mask, 143 unsigned edge_aa_mask,
144 float opacity) { 144 float opacity) {
145 // Excessive logging to debug white screens (crbug.com/583805). 145 // Excessive logging to debug white screens (crbug.com/583805).
146 // TODO(ccameron): change this back to a DLOG. 146 // TODO(ccameron): change this back to a DLOG.
147 if (has_committed_) { 147 if (has_committed_) {
148 LOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers."; 148 LOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers.";
149 return false; 149 return false;
150 } 150 }
151 return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id, 151 return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id,
152 transform, io_surface, cv_pixel_buffer, 152 transform, io_surface, cv_pixel_buffer,
153 contents_rect, rect, background_color, 153 contents_rect, rect, background_color,
154 edge_aa_mask, opacity); 154 edge_aa_mask, opacity);
155 } 155 }
156 156
157 void CALayerTree::CommitScheduledCALayers(CALayer* superlayer, 157 void CARendererLayerTree::CommitScheduledCALayers(
158 std::unique_ptr<CALayerTree> old_tree, 158 CALayer* superlayer,
159 float scale_factor) { 159 std::unique_ptr<CARendererLayerTree> old_tree,
160 TRACE_EVENT0("gpu", "CALayerTree::CommitScheduledCALayers"); 160 float scale_factor) {
161 TRACE_EVENT0("gpu", "CARendererLayerTree::CommitScheduledCALayers");
161 RootLayer* old_root_layer = nullptr; 162 RootLayer* old_root_layer = nullptr;
162 if (old_tree) { 163 if (old_tree) {
163 DCHECK(old_tree->has_committed_); 164 DCHECK(old_tree->has_committed_);
164 if (old_tree->scale_factor_ == scale_factor) 165 if (old_tree->scale_factor_ == scale_factor)
165 old_root_layer = &old_tree->root_layer_; 166 old_root_layer = &old_tree->root_layer_;
166 } 167 }
167 168
168 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); 169 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor);
169 // If there are any extra CALayers in |old_tree| that were not stolen by this 170 // If there are any extra CALayers in |old_tree| that were not stolen by this
170 // tree, they will be removed from the CALayer tree in this deallocation. 171 // tree, they will be removed from the CALayer tree in this deallocation.
171 old_tree.reset(); 172 old_tree.reset();
172 has_committed_ = true; 173 has_committed_ = true;
173 scale_factor_ = scale_factor; 174 scale_factor_ = scale_factor;
174 } 175 }
175 176
176 CALayerTree::RootLayer::RootLayer() {} 177 CARendererLayerTree::RootLayer::RootLayer() {}
177 178
178 // Note that for all destructors, the the CALayer will have been reset to nil if 179 // Note that for all destructors, the the CALayer will have been reset to nil if
179 // another layer has taken it. 180 // another layer has taken it.
180 CALayerTree::RootLayer::~RootLayer() { 181 CARendererLayerTree::RootLayer::~RootLayer() {
181 [ca_layer removeFromSuperlayer]; 182 [ca_layer removeFromSuperlayer];
182 } 183 }
183 184
184 CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer( 185 CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
185 bool is_clipped, 186 bool is_clipped,
186 gfx::Rect clip_rect, 187 gfx::Rect clip_rect,
187 unsigned sorting_context_id, 188 unsigned sorting_context_id,
188 bool is_singleton_sorting_context) 189 bool is_singleton_sorting_context)
189 : is_clipped(is_clipped), 190 : is_clipped(is_clipped),
190 clip_rect(clip_rect), 191 clip_rect(clip_rect),
191 sorting_context_id(sorting_context_id), 192 sorting_context_id(sorting_context_id),
192 is_singleton_sorting_context(is_singleton_sorting_context) {} 193 is_singleton_sorting_context(is_singleton_sorting_context) {}
193 194
194 CALayerTree::ClipAndSortingLayer::ClipAndSortingLayer( 195 CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
195 ClipAndSortingLayer&& layer) 196 ClipAndSortingLayer&& layer)
196 : transform_layers(std::move(layer.transform_layers)), 197 : transform_layers(std::move(layer.transform_layers)),
197 is_clipped(layer.is_clipped), 198 is_clipped(layer.is_clipped),
198 clip_rect(layer.clip_rect), 199 clip_rect(layer.clip_rect),
199 sorting_context_id(layer.sorting_context_id), 200 sorting_context_id(layer.sorting_context_id),
200 is_singleton_sorting_context( 201 is_singleton_sorting_context(layer.is_singleton_sorting_context),
201 layer.is_singleton_sorting_context),
202 ca_layer(layer.ca_layer) { 202 ca_layer(layer.ca_layer) {
203 // Ensure that the ca_layer be reset, so that when the destructor is called, 203 // Ensure that the ca_layer be reset, so that when the destructor is called,
204 // the layer hierarchy is unaffected. 204 // the layer hierarchy is unaffected.
205 // TODO(ccameron): Add a move constructor for scoped_nsobject to do this 205 // TODO(ccameron): Add a move constructor for scoped_nsobject to do this
206 // automatically. 206 // automatically.
207 layer.ca_layer.reset(); 207 layer.ca_layer.reset();
208 } 208 }
209 209
210 CALayerTree::ClipAndSortingLayer::~ClipAndSortingLayer() { 210 CARendererLayerTree::ClipAndSortingLayer::~ClipAndSortingLayer() {
211 [ca_layer removeFromSuperlayer]; 211 [ca_layer removeFromSuperlayer];
212 } 212 }
213 213
214 CALayerTree::TransformLayer::TransformLayer(const gfx::Transform& transform) 214 CARendererLayerTree::TransformLayer::TransformLayer(
215 const gfx::Transform& transform)
215 : transform(transform) {} 216 : transform(transform) {}
216 217
217 CALayerTree::TransformLayer::TransformLayer(TransformLayer&& layer) 218 CARendererLayerTree::TransformLayer::TransformLayer(TransformLayer&& layer)
218 : transform(layer.transform), 219 : transform(layer.transform),
219 content_layers(std::move(layer.content_layers)), 220 content_layers(std::move(layer.content_layers)),
220 ca_layer(layer.ca_layer) { 221 ca_layer(layer.ca_layer) {
221 layer.ca_layer.reset(); 222 layer.ca_layer.reset();
222 } 223 }
223 224
224 CALayerTree::TransformLayer::~TransformLayer() { 225 CARendererLayerTree::TransformLayer::~TransformLayer() {
225 [ca_layer removeFromSuperlayer]; 226 [ca_layer removeFromSuperlayer];
226 } 227 }
227 228
228 CALayerTree::ContentLayer::ContentLayer( 229 CARendererLayerTree::ContentLayer::ContentLayer(
229 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 230 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
230 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, 231 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer,
231 const gfx::RectF& contents_rect, 232 const gfx::RectF& contents_rect,
232 const gfx::Rect& rect, 233 const gfx::Rect& rect,
233 unsigned background_color, 234 unsigned background_color,
234 unsigned edge_aa_mask, 235 unsigned edge_aa_mask,
235 float opacity) 236 float opacity)
236 : io_surface(io_surface), 237 : io_surface(io_surface),
237 cv_pixel_buffer(cv_pixel_buffer), 238 cv_pixel_buffer(cv_pixel_buffer),
238 contents_rect(contents_rect), 239 contents_rect(contents_rect),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange && 271 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange &&
271 contents_rect == gfx::RectF(0, 0, 1, 1)) { 272 contents_rect == gfx::RectF(0, 0, 1, 1)) {
272 // Enable only for hardware decoded frames, to see if flashing bugs are 273 // Enable only for hardware decoded frames, to see if flashing bugs are
273 // particular to software IOSurfaces. 274 // particular to software IOSurfaces.
274 // https://crbug.com/598269 275 // https://crbug.com/598269
275 if (cv_pixel_buffer) 276 if (cv_pixel_buffer)
276 use_av_layer = true; 277 use_av_layer = true;
277 } 278 }
278 } 279 }
279 280
280 CALayerTree::ContentLayer::ContentLayer(ContentLayer&& layer) 281 CARendererLayerTree::ContentLayer::ContentLayer(ContentLayer&& layer)
281 : io_surface(layer.io_surface), 282 : io_surface(layer.io_surface),
282 cv_pixel_buffer(layer.cv_pixel_buffer), 283 cv_pixel_buffer(layer.cv_pixel_buffer),
283 contents_rect(layer.contents_rect), 284 contents_rect(layer.contents_rect),
284 rect(layer.rect), 285 rect(layer.rect),
285 background_color(layer.background_color), 286 background_color(layer.background_color),
286 ca_edge_aa_mask(layer.ca_edge_aa_mask), 287 ca_edge_aa_mask(layer.ca_edge_aa_mask),
287 opacity(layer.opacity), 288 opacity(layer.opacity),
288 ca_layer(std::move(layer.ca_layer)), 289 ca_layer(std::move(layer.ca_layer)),
289 av_layer(std::move(layer.av_layer)), 290 av_layer(std::move(layer.av_layer)),
290 use_av_layer(layer.use_av_layer) { 291 use_av_layer(layer.use_av_layer) {
291 DCHECK(!layer.ca_layer); 292 DCHECK(!layer.ca_layer);
292 DCHECK(!layer.av_layer); 293 DCHECK(!layer.av_layer);
293 } 294 }
294 295
295 CALayerTree::ContentLayer::~ContentLayer() { 296 CARendererLayerTree::ContentLayer::~ContentLayer() {
296 [ca_layer removeFromSuperlayer]; 297 [ca_layer removeFromSuperlayer];
297 } 298 }
298 299
299 bool CALayerTree::RootLayer::AddContentLayer( 300 bool CARendererLayerTree::RootLayer::AddContentLayer(
300 bool is_clipped, 301 bool is_clipped,
301 const gfx::Rect& clip_rect, 302 const gfx::Rect& clip_rect,
302 unsigned sorting_context_id, 303 unsigned sorting_context_id,
303 const gfx::Transform& transform, 304 const gfx::Transform& transform,
304 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 305 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
305 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, 306 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer,
306 const gfx::RectF& contents_rect, 307 const gfx::RectF& contents_rect,
307 const gfx::Rect& rect, 308 const gfx::Rect& rect,
308 unsigned background_color, 309 unsigned background_color,
309 unsigned edge_aa_mask, 310 unsigned edge_aa_mask,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 clip_and_sorting_layers.push_back( 343 clip_and_sorting_layers.push_back(
343 ClipAndSortingLayer(is_clipped, clip_rect, sorting_context_id, 344 ClipAndSortingLayer(is_clipped, clip_rect, sorting_context_id,
344 is_singleton_sorting_context)); 345 is_singleton_sorting_context));
345 } 346 }
346 clip_and_sorting_layers.back().AddContentLayer( 347 clip_and_sorting_layers.back().AddContentLayer(
347 transform, io_surface, cv_pixel_buffer, contents_rect, rect, 348 transform, io_surface, cv_pixel_buffer, contents_rect, rect,
348 background_color, edge_aa_mask, opacity); 349 background_color, edge_aa_mask, opacity);
349 return true; 350 return true;
350 } 351 }
351 352
352 void CALayerTree::ClipAndSortingLayer::AddContentLayer( 353 void CARendererLayerTree::ClipAndSortingLayer::AddContentLayer(
353 const gfx::Transform& transform, 354 const gfx::Transform& transform,
354 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 355 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
355 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, 356 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer,
356 const gfx::RectF& contents_rect, 357 const gfx::RectF& contents_rect,
357 const gfx::Rect& rect, 358 const gfx::Rect& rect,
358 unsigned background_color, 359 unsigned background_color,
359 unsigned edge_aa_mask, 360 unsigned edge_aa_mask,
360 float opacity) { 361 float opacity) {
361 bool needs_new_transform_layer = true; 362 bool needs_new_transform_layer = true;
362 if (!transform_layers.empty()) { 363 if (!transform_layers.empty()) {
363 const TransformLayer& current_layer = transform_layers.back(); 364 const TransformLayer& current_layer = transform_layers.back();
364 if (current_layer.transform == transform) 365 if (current_layer.transform == transform)
365 needs_new_transform_layer = false; 366 needs_new_transform_layer = false;
366 } 367 }
367 if (needs_new_transform_layer) 368 if (needs_new_transform_layer)
368 transform_layers.push_back(TransformLayer(transform)); 369 transform_layers.push_back(TransformLayer(transform));
369 transform_layers.back().AddContentLayer(io_surface, cv_pixel_buffer, 370 transform_layers.back().AddContentLayer(io_surface, cv_pixel_buffer,
370 contents_rect, rect, background_color, 371 contents_rect, rect, background_color,
371 edge_aa_mask, opacity); 372 edge_aa_mask, opacity);
372 } 373 }
373 374
374 void CALayerTree::TransformLayer::AddContentLayer( 375 void CARendererLayerTree::TransformLayer::AddContentLayer(
375 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 376 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
376 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, 377 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer,
377 const gfx::RectF& contents_rect, 378 const gfx::RectF& contents_rect,
378 const gfx::Rect& rect, 379 const gfx::Rect& rect,
379 unsigned background_color, 380 unsigned background_color,
380 unsigned edge_aa_mask, 381 unsigned edge_aa_mask,
381 float opacity) { 382 float opacity) {
382 content_layers.push_back(ContentLayer(io_surface, cv_pixel_buffer, 383 content_layers.push_back(ContentLayer(io_surface, cv_pixel_buffer,
383 contents_rect, rect, background_color, 384 contents_rect, rect, background_color,
384 edge_aa_mask, opacity)); 385 edge_aa_mask, opacity));
385 } 386 }
386 387
387 void CALayerTree::RootLayer::CommitToCA(CALayer* superlayer, 388 void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer,
388 RootLayer* old_layer, 389 RootLayer* old_layer,
389 float scale_factor) { 390 float scale_factor) {
390 if (old_layer) { 391 if (old_layer) {
391 DCHECK(old_layer->ca_layer); 392 DCHECK(old_layer->ca_layer);
392 std::swap(ca_layer, old_layer->ca_layer); 393 std::swap(ca_layer, old_layer->ca_layer);
393 } else { 394 } else {
394 ca_layer.reset([[CALayer alloc] init]); 395 ca_layer.reset([[CALayer alloc] init]);
395 [ca_layer setAnchorPoint:CGPointZero]; 396 [ca_layer setAnchorPoint:CGPointZero];
396 [superlayer setSublayers:nil]; 397 [superlayer setSublayers:nil];
397 [superlayer addSublayer:ca_layer]; 398 [superlayer addSublayer:ca_layer];
398 [superlayer setBorderWidth:0]; 399 [superlayer setBorderWidth:0];
399 } 400 }
400 // Excessive logging to debug white screens (crbug.com/583805). 401 // Excessive logging to debug white screens (crbug.com/583805).
401 // TODO(ccameron): change this back to a DCHECK. 402 // TODO(ccameron): change this back to a DCHECK.
402 if ([ca_layer superlayer] != superlayer) { 403 if ([ca_layer superlayer] != superlayer) {
403 LOG(ERROR) << "CALayerTree root layer not attached to tree."; 404 LOG(ERROR) << "CARendererLayerTree root layer not attached to tree.";
404 } 405 }
405 406
406 for (size_t i = 0; i < clip_and_sorting_layers.size(); ++i) { 407 for (size_t i = 0; i < clip_and_sorting_layers.size(); ++i) {
407 ClipAndSortingLayer* old_clip_and_sorting_layer = nullptr; 408 ClipAndSortingLayer* old_clip_and_sorting_layer = nullptr;
408 if (old_layer && i < old_layer->clip_and_sorting_layers.size()) { 409 if (old_layer && i < old_layer->clip_and_sorting_layers.size()) {
409 old_clip_and_sorting_layer = &old_layer->clip_and_sorting_layers[i]; 410 old_clip_and_sorting_layer = &old_layer->clip_and_sorting_layers[i];
410 } 411 }
411 clip_and_sorting_layers[i].CommitToCA( 412 clip_and_sorting_layers[i].CommitToCA(
412 ca_layer.get(), old_clip_and_sorting_layer, scale_factor); 413 ca_layer.get(), old_clip_and_sorting_layer, scale_factor);
413 } 414 }
414 } 415 }
415 416
416 void CALayerTree::ClipAndSortingLayer::CommitToCA( 417 void CARendererLayerTree::ClipAndSortingLayer::CommitToCA(
417 CALayer* superlayer, 418 CALayer* superlayer,
418 ClipAndSortingLayer* old_layer, 419 ClipAndSortingLayer* old_layer,
419 float scale_factor) { 420 float scale_factor) {
420 bool update_is_clipped = true; 421 bool update_is_clipped = true;
421 bool update_clip_rect = true; 422 bool update_clip_rect = true;
422 if (old_layer) { 423 if (old_layer) {
423 DCHECK(old_layer->ca_layer); 424 DCHECK(old_layer->ca_layer);
424 std::swap(ca_layer, old_layer->ca_layer); 425 std::swap(ca_layer, old_layer->ca_layer);
425 update_is_clipped = old_layer->is_clipped != is_clipped; 426 update_is_clipped = old_layer->is_clipped != is_clipped;
426 update_clip_rect = update_is_clipped || old_layer->clip_rect != clip_rect; 427 update_clip_rect = update_is_clipped || old_layer->clip_rect != clip_rect;
427 } else { 428 } else {
428 ca_layer.reset([[CALayer alloc] init]); 429 ca_layer.reset([[CALayer alloc] init]);
429 [ca_layer setAnchorPoint:CGPointZero]; 430 [ca_layer setAnchorPoint:CGPointZero];
430 [superlayer addSublayer:ca_layer]; 431 [superlayer addSublayer:ca_layer];
431 } 432 }
432 // Excessive logging to debug white screens (crbug.com/583805). 433 // Excessive logging to debug white screens (crbug.com/583805).
433 // TODO(ccameron): change this back to a DCHECK. 434 // TODO(ccameron): change this back to a DCHECK.
434 if ([ca_layer superlayer] != superlayer) { 435 if ([ca_layer superlayer] != superlayer) {
435 LOG(ERROR) << "CALayerTree root layer not attached to tree."; 436 LOG(ERROR) << "CARendererLayerTree root layer not attached to tree.";
436 } 437 }
437 438
438 if (update_is_clipped) 439 if (update_is_clipped)
439 [ca_layer setMasksToBounds:is_clipped]; 440 [ca_layer setMasksToBounds:is_clipped];
440 441
441 if (update_clip_rect) { 442 if (update_clip_rect) {
442 if (is_clipped) { 443 if (is_clipped) {
443 gfx::RectF dip_clip_rect = gfx::RectF(clip_rect); 444 gfx::RectF dip_clip_rect = gfx::RectF(clip_rect);
444 dip_clip_rect.Scale(1 / scale_factor); 445 dip_clip_rect.Scale(1 / scale_factor);
445 [ca_layer setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())]; 446 [ca_layer setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())];
(...skipping 11 matching lines...) Expand all
457 458
458 for (size_t i = 0; i < transform_layers.size(); ++i) { 459 for (size_t i = 0; i < transform_layers.size(); ++i) {
459 TransformLayer* old_transform_layer = nullptr; 460 TransformLayer* old_transform_layer = nullptr;
460 if (old_layer && i < old_layer->transform_layers.size()) 461 if (old_layer && i < old_layer->transform_layers.size())
461 old_transform_layer = &old_layer->transform_layers[i]; 462 old_transform_layer = &old_layer->transform_layers[i];
462 transform_layers[i].CommitToCA(ca_layer.get(), old_transform_layer, 463 transform_layers[i].CommitToCA(ca_layer.get(), old_transform_layer,
463 scale_factor); 464 scale_factor);
464 } 465 }
465 } 466 }
466 467
467 void CALayerTree::TransformLayer::CommitToCA(CALayer* superlayer, 468 void CARendererLayerTree::TransformLayer::CommitToCA(CALayer* superlayer,
468 TransformLayer* old_layer, 469 TransformLayer* old_layer,
469 float scale_factor) { 470 float scale_factor) {
470 bool update_transform = true; 471 bool update_transform = true;
471 if (old_layer) { 472 if (old_layer) {
472 DCHECK(old_layer->ca_layer); 473 DCHECK(old_layer->ca_layer);
473 std::swap(ca_layer, old_layer->ca_layer); 474 std::swap(ca_layer, old_layer->ca_layer);
474 update_transform = old_layer->transform != transform; 475 update_transform = old_layer->transform != transform;
475 } else { 476 } else {
476 ca_layer.reset([[CATransformLayer alloc] init]); 477 ca_layer.reset([[CATransformLayer alloc] init]);
477 [superlayer addSublayer:ca_layer]; 478 [superlayer addSublayer:ca_layer];
478 } 479 }
479 DCHECK_EQ([ca_layer superlayer], superlayer); 480 DCHECK_EQ([ca_layer superlayer], superlayer);
(...skipping 12 matching lines...) Expand all
492 493
493 for (size_t i = 0; i < content_layers.size(); ++i) { 494 for (size_t i = 0; i < content_layers.size(); ++i) {
494 ContentLayer* old_content_layer = nullptr; 495 ContentLayer* old_content_layer = nullptr;
495 if (old_layer && i < old_layer->content_layers.size()) 496 if (old_layer && i < old_layer->content_layers.size())
496 old_content_layer = &old_layer->content_layers[i]; 497 old_content_layer = &old_layer->content_layers[i];
497 content_layers[i].CommitToCA(ca_layer.get(), old_content_layer, 498 content_layers[i].CommitToCA(ca_layer.get(), old_content_layer,
498 scale_factor); 499 scale_factor);
499 } 500 }
500 } 501 }
501 502
502 void CALayerTree::ContentLayer::CommitToCA(CALayer* superlayer, 503 void CARendererLayerTree::ContentLayer::CommitToCA(CALayer* superlayer,
503 ContentLayer* old_layer, 504 ContentLayer* old_layer,
504 float scale_factor) { 505 float scale_factor) {
505 bool update_contents = true; 506 bool update_contents = true;
506 bool update_contents_rect = true; 507 bool update_contents_rect = true;
507 bool update_rect = true; 508 bool update_rect = true;
508 bool update_background_color = true; 509 bool update_background_color = true;
509 bool update_ca_edge_aa_mask = true; 510 bool update_ca_edge_aa_mask = true;
510 bool update_opacity = true; 511 bool update_opacity = true;
511 if (old_layer && old_layer->use_av_layer == use_av_layer) { 512 if (old_layer && old_layer->use_av_layer == use_av_layer) {
512 DCHECK(old_layer->ca_layer); 513 DCHECK(old_layer->ca_layer);
513 std::swap(ca_layer, old_layer->ca_layer); 514 std::swap(ca_layer, old_layer->ca_layer);
514 std::swap(av_layer, old_layer->av_layer); 515 std::swap(av_layer, old_layer->av_layer);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } else { 590 } else {
590 // Grey represents a CALayer that has not changed. 591 // Grey represents a CALayer that has not changed.
591 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1)); 592 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1));
592 } 593 }
593 [ca_layer setBorderWidth:1]; 594 [ca_layer setBorderWidth:1];
594 [ca_layer setBorderColor:color]; 595 [ca_layer setBorderColor:color];
595 } 596 }
596 } 597 }
597 598
598 } // namespace ui 599 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/ca_renderer_layer_tree.h ('k') | ui/accelerated_widget_mac/gl_renderer_layer_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698