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

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

Issue 2062463002: Mac: Flip fullscreen low power layer geometry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ui/accelerated_widget_mac/accelerated_widget_mac.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/accelerated_widget_mac.h" 5 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // Add a flipped transparent layer as a child, so that we don't need to 42 // Add a flipped transparent layer as a child, so that we don't need to
43 // fiddle with the position of sub-layers -- they will always be at the 43 // fiddle with the position of sub-layers -- they will always be at the
44 // origin. 44 // origin.
45 flipped_layer_.reset([[CALayer alloc] init]); 45 flipped_layer_.reset([[CALayer alloc] init]);
46 [flipped_layer_ setGeometryFlipped:YES]; 46 [flipped_layer_ setGeometryFlipped:YES];
47 [flipped_layer_ setAnchorPoint:CGPointMake(0, 0)]; 47 [flipped_layer_ setAnchorPoint:CGPointMake(0, 0)];
48 [flipped_layer_ 48 [flipped_layer_
49 setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable]; 49 setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable];
50 50
51 fslp_flipped_layer_.reset([[CALayer alloc] init]);
52 [fslp_flipped_layer_ setGeometryFlipped:YES];
53 [fslp_flipped_layer_ setAnchorPoint:CGPointMake(0, 0)];
54 [fslp_flipped_layer_
55 setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable];
56
51 // Use a sequence number as the accelerated widget handle that we can use 57 // Use a sequence number as the accelerated widget handle that we can use
52 // to look up the internals structure. 58 // to look up the internals structure.
53 static intptr_t last_sequence_number = 0; 59 static intptr_t last_sequence_number = 0;
54 last_sequence_number += 1; 60 last_sequence_number += 1;
55 native_widget_ = reinterpret_cast<gfx::AcceleratedWidget>( 61 native_widget_ = reinterpret_cast<gfx::AcceleratedWidget>(
56 last_sequence_number); 62 last_sequence_number);
57 g_widget_to_helper_map.Pointer()->insert( 63 g_widget_to_helper_map.Pointer()->insert(
58 std::make_pair(native_widget_, this)); 64 std::make_pair(native_widget_, this));
59 } 65 }
60 66
61 AcceleratedWidgetMac::~AcceleratedWidgetMac() { 67 AcceleratedWidgetMac::~AcceleratedWidgetMac() {
62 DCHECK(!view_); 68 DCHECK(!view_);
63 g_widget_to_helper_map.Pointer()->erase(native_widget_); 69 g_widget_to_helper_map.Pointer()->erase(native_widget_);
64 } 70 }
65 71
66 void AcceleratedWidgetMac::SetNSView(AcceleratedWidgetMacNSView* view) { 72 void AcceleratedWidgetMac::SetNSView(AcceleratedWidgetMacNSView* view) {
67 // Disable the fade-in animation as the view is added. 73 // Disable the fade-in animation as the view is added.
68 ScopedCAActionDisabler disabler; 74 ScopedCAActionDisabler disabler;
69 75
70 DCHECK(!fslp_coordinator_); 76 DCHECK(!fslp_coordinator_);
71 DCHECK(view && !view_); 77 DCHECK(view && !view_);
72 view_ = view; 78 view_ = view;
73 79
74 CALayer* background_layer = [view_->AcceleratedWidgetGetNSView() layer]; 80 CALayer* background_layer = [view_->AcceleratedWidgetGetNSView() layer];
75 DCHECK(background_layer); 81 DCHECK(background_layer);
76 [flipped_layer_ setBounds:[background_layer bounds]]; 82 [flipped_layer_ setBounds:[background_layer bounds]];
83 [fslp_flipped_layer_ setBounds:[background_layer bounds]];
77 [background_layer addSublayer:flipped_layer_]; 84 [background_layer addSublayer:flipped_layer_];
78 } 85 }
79 86
80 void AcceleratedWidgetMac::ResetNSView() { 87 void AcceleratedWidgetMac::ResetNSView() {
81 if (!view_) 88 if (!view_)
82 return; 89 return;
83 90
84 if (fslp_coordinator_) { 91 if (fslp_coordinator_) {
85 fslp_coordinator_->WillLoseAcceleratedWidget(); 92 fslp_coordinator_->WillLoseAcceleratedWidget();
86 DCHECK(!fslp_coordinator_); 93 DCHECK(!fslp_coordinator_);
(...skipping 18 matching lines...) Expand all
105 DCHECK(!fslp_coordinator_); 112 DCHECK(!fslp_coordinator_);
106 fslp_coordinator_ = coordinator; 113 fslp_coordinator_ = coordinator;
107 } 114 }
108 115
109 void AcceleratedWidgetMac::ResetFullscreenLowPowerCoordinator() { 116 void AcceleratedWidgetMac::ResetFullscreenLowPowerCoordinator() {
110 DCHECK(fslp_coordinator_); 117 DCHECK(fslp_coordinator_);
111 fslp_coordinator_ = nullptr; 118 fslp_coordinator_ = nullptr;
112 } 119 }
113 120
114 CALayer* AcceleratedWidgetMac::GetFullscreenLowPowerLayer() const { 121 CALayer* AcceleratedWidgetMac::GetFullscreenLowPowerLayer() const {
115 return fullscreen_low_power_layer_; 122 return fslp_flipped_layer_;
116 } 123 }
117 124
118 bool AcceleratedWidgetMac::MightBeInFullscreenLowPowerMode() const { 125 bool AcceleratedWidgetMac::MightBeInFullscreenLowPowerMode() const {
119 return fslp_coordinator_; 126 return fslp_coordinator_;
120 } 127 }
121 128
122 bool AcceleratedWidgetMac::HasFrameOfSize( 129 bool AcceleratedWidgetMac::HasFrameOfSize(
123 const gfx::Size& dip_size) const { 130 const gfx::Size& dip_size) const {
124 return last_swap_size_dip_ == dip_size; 131 return last_swap_size_dip_ == dip_size;
125 } 132 }
(...skipping 25 matching lines...) Expand all
151 base::scoped_nsobject<CALayer> fullscreen_low_power_layer, 158 base::scoped_nsobject<CALayer> fullscreen_low_power_layer,
152 const gfx::Size& pixel_size, 159 const gfx::Size& pixel_size,
153 float scale_factor) { 160 float scale_factor) {
154 TRACE_EVENT0("ui", "AcceleratedWidgetMac::GotCAContextFrame"); 161 TRACE_EVENT0("ui", "AcceleratedWidgetMac::GotCAContextFrame");
155 if (!view_) { 162 if (!view_) {
156 TRACE_EVENT0("ui", "No associated NSView"); 163 TRACE_EVENT0("ui", "No associated NSView");
157 return; 164 return;
158 } 165 }
159 ScopedCAActionDisabler disabler; 166 ScopedCAActionDisabler disabler;
160 last_swap_size_dip_ = gfx::ConvertSizeToDIP(scale_factor, pixel_size); 167 last_swap_size_dip_ = gfx::ConvertSizeToDIP(scale_factor, pixel_size);
168 if (fullscreen_low_power_layer_valid)
169 [fslp_flipped_layer_ setFrame:gfx::Rect(last_swap_size_dip_).ToCGRect()];
161 170
162 // Ensure that the content is in the CALayer hierarchy, and update fullscreen 171 // Ensure that the content is in the CALayer hierarchy, and update fullscreen
163 // low power state. 172 // low power state.
164 if (content_layer_ != content_layer) { 173 if (content_layer_ != content_layer) {
165 [flipped_layer_ addSublayer:content_layer]; 174 [flipped_layer_ addSublayer:content_layer];
166 [content_layer_ removeFromSuperlayer]; 175 [content_layer_ removeFromSuperlayer];
167 content_layer_ = content_layer; 176 content_layer_ = content_layer;
168 } 177 }
169 if (fullscreen_low_power_layer_ != fullscreen_low_power_layer) { 178 if (fullscreen_low_power_layer_ != fullscreen_low_power_layer) {
170 if (fslp_coordinator_) { 179 if (fslp_coordinator_) {
171 fslp_coordinator_->WillLoseAcceleratedWidget(); 180 fslp_coordinator_->WillLoseAcceleratedWidget();
172 DCHECK(!fslp_coordinator_); 181 DCHECK(!fslp_coordinator_);
173 } 182 }
183 [fslp_flipped_layer_ addSublayer:fullscreen_low_power_layer];
184 [fullscreen_low_power_layer_ removeFromSuperlayer];
174 fullscreen_low_power_layer_ = fullscreen_low_power_layer; 185 fullscreen_low_power_layer_ = fullscreen_low_power_layer;
175 } 186 }
176 if (fslp_coordinator_) 187 if (fslp_coordinator_)
177 fslp_coordinator_->SetLowPowerLayerValid(fullscreen_low_power_layer_valid); 188 fslp_coordinator_->SetLowPowerLayerValid(fullscreen_low_power_layer_valid);
178 189
179 // Ensure the IOSurface is removed. 190 // Ensure the IOSurface is removed.
180 if (io_surface_layer_) { 191 if (io_surface_layer_) {
181 [io_surface_layer_ removeFromSuperlayer]; 192 [io_surface_layer_ removeFromSuperlayer];
182 io_surface_layer_.reset(); 193 io_surface_layer_.reset();
183 } 194 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 226
216 // Ensure that the content layer is removed. 227 // Ensure that the content layer is removed.
217 if (content_layer_) { 228 if (content_layer_) {
218 [content_layer_ removeFromSuperlayer]; 229 [content_layer_ removeFromSuperlayer];
219 content_layer_.reset(); 230 content_layer_.reset();
220 } 231 }
221 view_->AcceleratedWidgetSwapCompleted(); 232 view_->AcceleratedWidgetSwapCompleted();
222 } 233 }
223 234
224 } // namespace ui 235 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/accelerated_widget_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698