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

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

Issue 2479723003: Mac: Fix flickering while entering/leaving fullscreen low power video (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ui/accelerated_widget_mac/ca_layer_tree_coordinator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "ui/base/cocoa/animation_utils.h" 11 #include "ui/base/cocoa/animation_utils.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 namespace {
16 const uint64_t kFramesBeforeFlushingLowPowerLayer = 15;
17 }
18
15 CALayerTreeCoordinator::CALayerTreeCoordinator( 19 CALayerTreeCoordinator::CALayerTreeCoordinator(
16 bool allow_remote_layers, 20 bool allow_remote_layers,
17 bool allow_av_sample_buffer_display_layer) 21 bool allow_av_sample_buffer_display_layer)
18 : allow_remote_layers_(allow_remote_layers), 22 : allow_remote_layers_(allow_remote_layers),
19 allow_av_sample_buffer_display_layer_( 23 allow_av_sample_buffer_display_layer_(
20 allow_av_sample_buffer_display_layer) { 24 allow_av_sample_buffer_display_layer) {
21 if (allow_remote_layers_) { 25 if (allow_remote_layers_) {
22 root_ca_layer_.reset([[CALayer alloc] init]); 26 root_ca_layer_.reset([[CALayer alloc] init]);
23 [root_ca_layer_ setGeometryFlipped:YES]; 27 [root_ca_layer_ setGeometryFlipped:YES];
24 [root_ca_layer_ setOpaque:YES]; 28 [root_ca_layer_ setOpaque:YES];
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 scale_factor_, pixel_damage_rect); 93 scale_factor_, pixel_damage_rect);
90 current_gl_renderer_layer_tree_.swap(pending_gl_renderer_layer_tree_); 94 current_gl_renderer_layer_tree_.swap(pending_gl_renderer_layer_tree_);
91 current_ca_renderer_layer_tree_.reset(); 95 current_ca_renderer_layer_tree_.reset();
92 } else { 96 } else {
93 TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers"); 97 TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers");
94 [root_ca_layer_ setSublayers:nil]; 98 [root_ca_layer_ setSublayers:nil];
95 current_gl_renderer_layer_tree_.reset(); 99 current_gl_renderer_layer_tree_.reset();
96 current_ca_renderer_layer_tree_.reset(); 100 current_ca_renderer_layer_tree_.reset();
97 } 101 }
98 102
99 // TODO(ccameron): It may be necessary to leave the last image up for a few 103 // It is necessary to leave the last image up for a few extra frames to allow
100 // extra frames to allow a smooth switch between the normal and low-power 104 // a smooth switch between the normal and low-power NSWindows.
101 // NSWindows. 105 if (*fullscreen_low_power_layer_valid)
102 if (current_fullscreen_low_power_layer_valid_ && 106 frames_since_low_power_layer_was_valid_ = 0;
103 !*fullscreen_low_power_layer_valid) { 107 else
108 frames_since_low_power_layer_was_valid_ += 1;
109 if (frames_since_low_power_layer_was_valid_ ==
110 kFramesBeforeFlushingLowPowerLayer)
104 [fullscreen_low_power_layer_ flushAndRemoveImage]; 111 [fullscreen_low_power_layer_ flushAndRemoveImage];
105 }
106 current_fullscreen_low_power_layer_valid_ = *fullscreen_low_power_layer_valid;
107 112
108 // Reset all state for the next frame. 113 // Reset all state for the next frame.
109 pending_ca_renderer_layer_tree_.reset(); 114 pending_ca_renderer_layer_tree_.reset();
110 pending_gl_renderer_layer_tree_.reset(); 115 pending_gl_renderer_layer_tree_.reset();
111 } 116 }
112 117
113 CALayer* CALayerTreeCoordinator::GetCALayerForDisplay() const { 118 CALayer* CALayerTreeCoordinator::GetCALayerForDisplay() const {
114 DCHECK(allow_remote_layers_); 119 DCHECK(allow_remote_layers_);
115 return root_ca_layer_.get(); 120 return root_ca_layer_.get();
116 } 121 }
117 122
118 CALayer* CALayerTreeCoordinator::GetFullscreenLowPowerLayerForDisplay() const { 123 CALayer* CALayerTreeCoordinator::GetFullscreenLowPowerLayerForDisplay() const {
119 return fullscreen_low_power_layer_.get(); 124 return fullscreen_low_power_layer_.get();
120 } 125 }
121 126
122 IOSurfaceRef CALayerTreeCoordinator::GetIOSurfaceForDisplay() { 127 IOSurfaceRef CALayerTreeCoordinator::GetIOSurfaceForDisplay() {
123 DCHECK(!allow_remote_layers_); 128 DCHECK(!allow_remote_layers_);
124 if (!current_gl_renderer_layer_tree_) 129 if (!current_gl_renderer_layer_tree_)
125 return nullptr; 130 return nullptr;
126 return current_gl_renderer_layer_tree_->RootLayerIOSurface(); 131 return current_gl_renderer_layer_tree_->RootLayerIOSurface();
127 } 132 }
128 133
129 } // namespace ui 134 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/ca_layer_tree_coordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698