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

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

Issue 1844053002: Add detached mode plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: And target 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
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 "content/common/gpu/ca_layer_tree_mac.h" 5 #include "content/common/gpu/ca_layer_tree_mac.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 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // TODO(ccameron): change this back to a DLOG. 135 // TODO(ccameron): change this back to a DLOG.
136 if (has_committed_) { 136 if (has_committed_) {
137 LOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers."; 137 LOG(ERROR) << "ScheduleCALayer called after CommitScheduledCALayers.";
138 return false; 138 return false;
139 } 139 }
140 return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id, 140 return root_layer_.AddContentLayer(is_clipped, clip_rect, sorting_context_id,
141 transform, io_surface, contents_rect, rect, 141 transform, io_surface, contents_rect, rect,
142 background_color, edge_aa_mask, opacity); 142 background_color, edge_aa_mask, opacity);
143 } 143 }
144 144
145 void CALayerTree::CommitScheduledCALayers(CALayer* superlayer, 145 void CALayerTree::CommitScheduledCALayers(
146 scoped_ptr<CALayerTree> old_tree, 146 CALayer* superlayer,
147 float scale_factor) { 147 bool* use_detached_video_layer,
148 AVSampleBufferDisplayLayer* detached_video_layer,
149 scoped_ptr<CALayerTree> old_tree,
150 float scale_factor) {
148 TRACE_EVENT0("gpu", "CALayerTree::CommitScheduledCALayers"); 151 TRACE_EVENT0("gpu", "CALayerTree::CommitScheduledCALayers");
149 RootLayer* old_root_layer = nullptr; 152 RootLayer* old_root_layer = nullptr;
150 if (old_tree) { 153 if (old_tree) {
151 DCHECK(old_tree->has_committed_); 154 DCHECK(old_tree->has_committed_);
152 if (old_tree->scale_factor_ == scale_factor) 155 if (old_tree->scale_factor_ == scale_factor)
153 old_root_layer = &old_tree->root_layer_; 156 old_root_layer = &old_tree->root_layer_;
154 } 157 }
155 158
159 // Do the video check.
160 {
161 bool all_before_black = true;
162 bool found_video = false;
163 bool nothing_after = true;
164 ContentLayer* video_layer = nullptr;
165
166 for (auto& clip_layer : root_layer_.clip_and_sorting_layers) {
167 for (auto& transform_layer : clip_layer.transform_layers) {
168 for (auto& content_layer : transform_layer.content_layers) {
169 if (all_before_black) {
170 if (found_video) {
171 nothing_after = false;
172 }
173 if (content_layer.use_av_layer) {
174 found_video = true;
175 video_layer = &content_layer;
176 } else if (content_layer.background_color & 0x00FFFFFF) {
177 all_before_black = false;
178 }
179 }
180 }
181 }
182 }
183 printf("bb:%d fv:%d na:%d\n", all_before_black, found_video, nothing_after);
184 if (all_before_black && found_video && nothing_after) {
185 printf("YES TO DETACHED MODE!!!\n");
186 *use_detached_video_layer = true;
187 AVSampleBufferDisplayLayerEnqueueIOSurface(detached_video_layer, video_lay er->io_surface);
188 } else {
189 *use_detached_video_layer = false;
190 }
191 }
192
193
156 root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); 194 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 195 // 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. 196 // tree, they will be removed from the CALayer tree in this deallocation.
159 old_tree.reset(); 197 old_tree.reset();
160 has_committed_ = true; 198 has_committed_ = true;
161 scale_factor_ = scale_factor; 199 scale_factor_ = scale_factor;
162 } 200 }
163 201
164 CALayerTree::RootLayer::RootLayer() {} 202 CALayerTree::RootLayer::RootLayer() {}
165 203
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } else { 597 } else {
560 // Grey represents a CALayer that has not changed. 598 // Grey represents a CALayer that has not changed.
561 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1)); 599 color.reset(CGColorCreateGenericRGB(0, 0, 0, 0.1));
562 } 600 }
563 [ca_layer setBorderWidth:1]; 601 [ca_layer setBorderWidth:1];
564 [ca_layer setBorderColor:color]; 602 [ca_layer setBorderColor:color];
565 } 603 }
566 } 604 }
567 605
568 } // namespace content 606 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/ca_layer_tree_mac.h ('k') | content/common/gpu/gpu_channel_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698