Chromium Code Reviews| 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_renderer_layer_tree.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> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 } | 167 } |
| 168 | 168 |
| 169 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); | 169 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); |
| 170 // 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 |
| 171 // 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. |
| 172 old_tree.reset(); | 172 old_tree.reset(); |
| 173 has_committed_ = true; | 173 has_committed_ = true; |
| 174 scale_factor_ = scale_factor; | 174 scale_factor_ = scale_factor; |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool CARendererLayerTree::CommitFullscreenLowPowerLayer( | |
| 178 AVSampleBufferDisplayLayer* fullscreen_low_power_layer) { | |
| 179 DCHECK(has_committed_); | |
| 180 ContentLayer* video_layer = nullptr; | |
| 181 gfx::RectF video_layer_frame_dip; | |
| 182 for (auto& clip_layer : root_layer_.clip_and_sorting_layers) { | |
|
erikchen
2016/04/26 23:56:21
const auto& for all loops
ccameron
2016/04/27 20:01:10
Done.
| |
| 183 for (auto& transform_layer : clip_layer.transform_layers) { | |
| 184 for (auto& content_layer : transform_layer.content_layers) { | |
| 185 // Detached mode requires that no layers be on top of the video layer. | |
| 186 if (video_layer) | |
| 187 return false; | |
| 188 | |
| 189 // See if this is the video layer. | |
| 190 if (content_layer.use_av_layer) { | |
| 191 video_layer = &content_layer; | |
| 192 video_layer_frame_dip = gfx::RectF(video_layer->rect); | |
| 193 if (!transform_layer.transform.IsPositiveScaleOrTranslation()) | |
| 194 return false; | |
| 195 if (content_layer.opacity != 1) | |
| 196 return false; | |
| 197 transform_layer.transform.TransformRect(&video_layer_frame_dip); | |
| 198 video_layer_frame_dip.Scale(1 / scale_factor_); | |
| 199 continue; | |
| 200 } | |
| 201 | |
| 202 // If we haven't found the video layer yet, make sure everything is | |
| 203 // solid black or transparent | |
| 204 if (content_layer.io_surface) | |
| 205 return false; | |
| 206 if (content_layer.background_color != SK_ColorBLACK && | |
| 207 content_layer.background_color != SK_ColorTRANSPARENT) { | |
| 208 return false; | |
| 209 } | |
| 210 } | |
| 211 } | |
| 212 } | |
| 213 if (!video_layer) | |
| 214 return false; | |
| 215 | |
| 216 if (video_layer->cv_pixel_buffer) { | |
| 217 AVSampleBufferDisplayLayerEnqueueCVPixelBuffer( | |
| 218 fullscreen_low_power_layer, video_layer->cv_pixel_buffer); | |
| 219 } else { | |
| 220 AVSampleBufferDisplayLayerEnqueueIOSurface(fullscreen_low_power_layer, | |
| 221 video_layer->io_surface); | |
| 222 } | |
| 223 [fullscreen_low_power_layer setVideoGravity:AVLayerVideoGravityResize]; | |
| 224 [fullscreen_low_power_layer setFrame:video_layer_frame_dip.ToCGRect()]; | |
| 225 return true; | |
| 226 } | |
| 227 | |
| 228 | |
| 177 CARendererLayerTree::RootLayer::RootLayer() {} | 229 CARendererLayerTree::RootLayer::RootLayer() {} |
| 178 | 230 |
| 179 // Note that for all destructors, the the CALayer will have been reset to nil if | 231 // Note that for all destructors, the the CALayer will have been reset to nil if |
| 180 // another layer has taken it. | 232 // another layer has taken it. |
| 181 CARendererLayerTree::RootLayer::~RootLayer() { | 233 CARendererLayerTree::RootLayer::~RootLayer() { |
| 182 [ca_layer removeFromSuperlayer]; | 234 [ca_layer removeFromSuperlayer]; |
| 183 } | 235 } |
| 184 | 236 |
| 185 CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer( | 237 CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer( |
| 186 bool is_clipped, | 238 bool is_clipped, |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 } else { | 642 } else { |
| 591 // Grey represents a CALayer that has not changed. | 643 // Grey represents a CALayer that has not changed. |
| 592 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1)); | 644 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1)); |
| 593 } | 645 } |
| 594 [ca_layer setBorderWidth:1]; | 646 [ca_layer setBorderWidth:1]; |
| 595 [ca_layer setBorderColor:color]; | 647 [ca_layer setBorderColor:color]; |
| 596 } | 648 } |
| 597 } | 649 } |
| 598 | 650 |
| 599 } // namespace ui | 651 } // namespace ui |
| OLD | NEW |