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

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

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 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 #ifndef UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_ 5 #ifndef UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_
6 #define UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_ 6 #define UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_
7 7
8 #include <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h" 15 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
15 #include "ui/base/cocoa/remote_layer_api.h" 16 #include "ui/base/cocoa/remote_layer_api.h"
16 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 #include "ui/gfx/native_widget_types.h" 19 #include "ui/gfx/native_widget_types.h"
19 20
20 #if defined(__OBJC__) 21 #if defined(__OBJC__)
21 #import <Cocoa/Cocoa.h> 22 #import <Cocoa/Cocoa.h>
22 #import "base/mac/scoped_nsobject.h" 23 #import "base/mac/scoped_nsobject.h"
24 @class DetachedModeWindow;
23 #endif // __OBJC__ 25 #endif // __OBJC__
24 26
25 class SkCanvas; 27 class SkCanvas;
26 28
27 namespace cc { 29 namespace cc {
28 class SoftwareFrameData; 30 class SoftwareFrameData;
29 } 31 }
30 32
31 namespace ui { 33 namespace ui {
32 34
(...skipping 28 matching lines...) Expand all
61 63
62 // Return true if the last frame swapped has a size in DIP of |dip_size|. 64 // Return true if the last frame swapped has a size in DIP of |dip_size|.
63 bool HasFrameOfSize(const gfx::Size& dip_size) const; 65 bool HasFrameOfSize(const gfx::Size& dip_size) const;
64 66
65 // Populate the vsync parameters for the surface's display. 67 // Populate the vsync parameters for the surface's display.
66 void GetVSyncParameters( 68 void GetVSyncParameters(
67 base::TimeTicks* timebase, base::TimeDelta* interval) const; 69 base::TimeTicks* timebase, base::TimeDelta* interval) const;
68 70
69 void GotFrame(CAContextID ca_context_id, 71 void GotFrame(CAContextID ca_context_id,
70 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 72 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
73 bool use_detached,
74 CAContextID detached_ca_context_id,
71 const gfx::Size& pixel_size, 75 const gfx::Size& pixel_size,
72 float scale_factor); 76 float scale_factor);
73 77
78 NSWindow* CreateDetachedModeWindow();
79 void DestroyDetachedModeWindow();
80 void EnterDetachedMode();
81 void LeaveDetachedMode();
82
74 private: 83 private:
75 void GotCAContextFrame(CAContextID ca_context_id, 84 void GotCAContextFrame(CAContextID ca_context_id,
85 bool use_detached,
86 CAContextID detached_ca_context_id,
76 const gfx::Size& pixel_size, 87 const gfx::Size& pixel_size,
77 float scale_factor); 88 float scale_factor);
78 89
79 void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 90 void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
80 const gfx::Size& pixel_size, 91 const gfx::Size& pixel_size,
81 float scale_factor); 92 float scale_factor);
82 93
83 // Remove a layer from the heirarchy and destroy it. Because the accelerated 94 // Remove a layer from the heirarchy and destroy it. Because the accelerated
84 // layer types may be replaced by a layer of the same type, the layer to 95 // layer types may be replaced by a layer of the same type, the layer to
85 // destroy is parameterized, and, if it is the current layer, the current 96 // destroy is parameterized, and, if it is the current layer, the current
86 // layer is reset. 97 // layer is reset.
87 void DestroyCAContextLayer( 98 void DestroyCAContextLayer(
88 base::scoped_nsobject<CALayerHost> ca_context_layer); 99 base::scoped_nsobject<CALayerHost> ca_context_layer);
89 void DestroyLocalLayer(); 100 void DestroyLocalLayer();
90 void EnsureLocalLayer(); 101 void EnsureLocalLayer();
91 102
92 // The AcceleratedWidgetMacNSView that is using this as its internals. 103 // The AcceleratedWidgetMacNSView that is using this as its internals.
93 AcceleratedWidgetMacNSView* view_; 104 AcceleratedWidgetMacNSView* view_;
94 105
95 // A phony NSView handle used to identify this. 106 // A phony NSView handle used to identify this.
96 gfx::AcceleratedWidget native_widget_; 107 gfx::AcceleratedWidget native_widget_;
97 108
109 base::scoped_nsobject<DetachedModeWindow> detached_mode_window_;
110
98 // A flipped layer, which acts as the parent of the compositing and software 111 // A flipped layer, which acts as the parent of the compositing and software
99 // layers. This layer is flipped so that the we don't need to recompute the 112 // layers. This layer is flipped so that the we don't need to recompute the
100 // origin for sub-layers when their position changes (this is impossible when 113 // origin for sub-layers when their position changes (this is impossible when
101 // using remote layers, as their size change cannot be synchronized with the 114 // using remote layers, as their size change cannot be synchronized with the
102 // window). This indirection is needed because flipping hosted layers (like 115 // window). This indirection is needed because flipping hosted layers (like
103 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable 116 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable
104 // behavior. 117 // behavior.
105 base::scoped_nsobject<CALayer> flipped_layer_; 118 base::scoped_nsobject<CALayer> flipped_layer_;
106 119
107 // The accelerated CoreAnimation layer hosted by the GPU process. 120 // The accelerated CoreAnimation layer hosted by the GPU process.
108 base::scoped_nsobject<CALayerHost> ca_context_layer_; 121 base::scoped_nsobject<CALayerHost> ca_context_layer_;
122 base::scoped_nsobject<CALayerHost> detached_ca_context_layer_;
123 bool in_detached_mode_ = false;
109 124
110 // The locally drawn layer, which has its contents set to an IOSurface. 125 // The locally drawn layer, which has its contents set to an IOSurface.
111 base::scoped_nsobject<CALayer> local_layer_; 126 base::scoped_nsobject<CALayer> local_layer_;
112 127
113 // The size in DIP of the last swap received from |compositor_|. 128 // The size in DIP of the last swap received from |compositor_|.
114 gfx::Size last_swap_size_dip_; 129 gfx::Size last_swap_size_dip_;
115 130
131 base::WeakPtrFactory<AcceleratedWidgetMac> weak_factory_;
116 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac); 132 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac);
117 }; 133 };
118 134
119 #endif // __OBJC__ 135 #endif // __OBJC__
120 136
121 ACCELERATED_WIDGET_MAC_EXPORT 137 ACCELERATED_WIDGET_MAC_EXPORT
122 void AcceleratedWidgetMacGotFrame( 138 void AcceleratedWidgetMacGotFrame(
123 gfx::AcceleratedWidget widget, 139 gfx::AcceleratedWidget widget,
124 CAContextID ca_context_id, 140 CAContextID ca_context_id,
125 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 141 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
142 bool use_detached,
143 CAContextID detached_ca_context_id,
126 const gfx::Size& pixel_size, 144 const gfx::Size& pixel_size,
127 float scale_factor, 145 float scale_factor,
128 base::TimeTicks* vsync_timebase, 146 base::TimeTicks* vsync_timebase,
129 base::TimeDelta* vsync_interval); 147 base::TimeDelta* vsync_interval);
130 148
131 } // namespace ui 149 } // namespace ui
132 150
133 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_ 151 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_
OLDNEW
« no previous file with comments | « content/public/browser/render_widget_host_view.h ('k') | ui/accelerated_widget_mac/accelerated_widget_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698