| 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 "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" | 5 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" |
| 6 | 6 |
| 7 #include <AVFoundation/AVFoundation.h> | 7 #include <AVFoundation/AVFoundation.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/base/cocoa/animation_utils.h" | 10 #include "ui/base/cocoa/animation_utils.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 CALayerTreeCoordinator::CALayerTreeCoordinator(bool allow_remote_layers) | 14 CALayerTreeCoordinator::CALayerTreeCoordinator( |
| 15 : allow_remote_layers_(allow_remote_layers) { | 15 bool allow_remote_layers, |
| 16 bool allow_av_sample_buffer_display_layer) |
| 17 : allow_remote_layers_(allow_remote_layers), |
| 18 allow_av_sample_buffer_display_layer_( |
| 19 allow_av_sample_buffer_display_layer) { |
| 16 if (allow_remote_layers_) { | 20 if (allow_remote_layers_) { |
| 17 root_ca_layer_.reset([[CALayer alloc] init]); | 21 root_ca_layer_.reset([[CALayer alloc] init]); |
| 18 [root_ca_layer_ setGeometryFlipped:YES]; | 22 [root_ca_layer_ setGeometryFlipped:YES]; |
| 19 [root_ca_layer_ setOpaque:YES]; | 23 [root_ca_layer_ setOpaque:YES]; |
| 20 | 24 |
| 21 fullscreen_low_power_layer_.reset( | 25 if (allow_av_sample_buffer_display_layer_) { |
| 22 [[AVSampleBufferDisplayLayer alloc] init]); | 26 fullscreen_low_power_layer_.reset( |
| 27 [[AVSampleBufferDisplayLayer alloc] init]); |
| 28 } |
| 23 } | 29 } |
| 24 } | 30 } |
| 25 | 31 |
| 26 CALayerTreeCoordinator::~CALayerTreeCoordinator() {} | 32 CALayerTreeCoordinator::~CALayerTreeCoordinator() {} |
| 27 | 33 |
| 28 void CALayerTreeCoordinator::Resize(const gfx::Size& pixel_size, | 34 void CALayerTreeCoordinator::Resize(const gfx::Size& pixel_size, |
| 29 float scale_factor) { | 35 float scale_factor) { |
| 30 pixel_size_ = pixel_size; | 36 pixel_size_ = pixel_size; |
| 31 scale_factor_ = scale_factor; | 37 scale_factor_ = scale_factor; |
| 32 } | 38 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 return true; | 54 return true; |
| 49 } | 55 } |
| 50 | 56 |
| 51 CARendererLayerTree* CALayerTreeCoordinator::GetPendingCARendererLayerTree() { | 57 CARendererLayerTree* CALayerTreeCoordinator::GetPendingCARendererLayerTree() { |
| 52 DCHECK(allow_remote_layers_); | 58 DCHECK(allow_remote_layers_); |
| 53 if (pending_gl_renderer_layer_tree_) { | 59 if (pending_gl_renderer_layer_tree_) { |
| 54 DLOG(ERROR) << "Either CALayer overlays or a backbuffer should be " | 60 DLOG(ERROR) << "Either CALayer overlays or a backbuffer should be " |
| 55 "specified, but not both."; | 61 "specified, but not both."; |
| 56 } | 62 } |
| 57 if (!pending_ca_renderer_layer_tree_) | 63 if (!pending_ca_renderer_layer_tree_) |
| 58 pending_ca_renderer_layer_tree_.reset(new CARendererLayerTree); | 64 pending_ca_renderer_layer_tree_.reset( |
| 65 new CARendererLayerTree(allow_av_sample_buffer_display_layer_)); |
| 59 return pending_ca_renderer_layer_tree_.get(); | 66 return pending_ca_renderer_layer_tree_.get(); |
| 60 } | 67 } |
| 61 | 68 |
| 62 void CALayerTreeCoordinator::CommitPendingTreesToCA( | 69 void CALayerTreeCoordinator::CommitPendingTreesToCA( |
| 63 const gfx::Rect& pixel_damage_rect, | 70 const gfx::Rect& pixel_damage_rect, |
| 64 bool* fullscreen_low_power_layer_valid) { | 71 bool* fullscreen_low_power_layer_valid) { |
| 65 *fullscreen_low_power_layer_valid = false; | 72 *fullscreen_low_power_layer_valid = false; |
| 66 | 73 |
| 67 // Update the CALayer hierarchy. | 74 // Update the CALayer hierarchy. |
| 68 ScopedCAActionDisabler disabler; | 75 ScopedCAActionDisabler disabler; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 119 } |
| 113 | 120 |
| 114 IOSurfaceRef CALayerTreeCoordinator::GetIOSurfaceForDisplay() { | 121 IOSurfaceRef CALayerTreeCoordinator::GetIOSurfaceForDisplay() { |
| 115 DCHECK(!allow_remote_layers_); | 122 DCHECK(!allow_remote_layers_); |
| 116 if (!current_gl_renderer_layer_tree_) | 123 if (!current_gl_renderer_layer_tree_) |
| 117 return nullptr; | 124 return nullptr; |
| 118 return current_gl_renderer_layer_tree_->RootLayerIOSurface(); | 125 return current_gl_renderer_layer_tree_->RootLayerIOSurface(); |
| 119 } | 126 } |
| 120 | 127 |
| 121 } // namespace ui | 128 } // namespace ui |
| OLD | NEW |