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

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

Issue 2018793002: Mac: Move remote layer use to GpuOutputSurfaceMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean_up_mac
Patch Set: Review feedback 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
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 #import <Cocoa/Cocoa.h>
8 #include <IOSurface/IOSurface.h> 9 #include <IOSurface/IOSurface.h>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
13 #import "base/mac/scoped_nsobject.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/time/time.h" 15 #include "base/time/time.h"
14 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h" 16 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
15 #include "ui/base/cocoa/remote_layer_api.h" 17 #include "ui/base/cocoa/remote_layer_api.h"
16 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
18 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
19 21
20 #if defined(__OBJC__)
21 #import <Cocoa/Cocoa.h>
22 #import "base/mac/scoped_nsobject.h"
23 #endif // __OBJC__
24
25 class SkCanvas; 22 class SkCanvas;
26 23
27 namespace cc { 24 namespace cc {
28 class SoftwareFrameData; 25 class SoftwareFrameData;
29 } 26 }
30 27
31 namespace ui { 28 namespace ui {
32 29
33 class AcceleratedWidgetMac;
34 class FullscreenLowPowerCoordinator; 30 class FullscreenLowPowerCoordinator;
35 31
36 // A class through which an AcceleratedWidget may be bound to draw the contents 32 // A class through which an AcceleratedWidget may be bound to draw the contents
37 // of an NSView. An AcceleratedWidget may be bound to multiple different views 33 // of an NSView. An AcceleratedWidget may be bound to multiple different views
38 // throughout its lifetime (one at a time, though). 34 // throughout its lifetime (one at a time, though).
39 class AcceleratedWidgetMacNSView { 35 class AcceleratedWidgetMacNSView {
40 public: 36 public:
41 virtual NSView* AcceleratedWidgetGetNSView() const = 0; 37 virtual NSView* AcceleratedWidgetGetNSView() const = 0;
42 virtual void AcceleratedWidgetGetVSyncParameters( 38 virtual void AcceleratedWidgetGetVSyncParameters(
43 base::TimeTicks* timebase, base::TimeDelta* interval) const = 0; 39 base::TimeTicks* timebase, base::TimeDelta* interval) const = 0;
44 virtual void AcceleratedWidgetSwapCompleted() = 0; 40 virtual void AcceleratedWidgetSwapCompleted() = 0;
45 }; 41 };
46 42
47 #if defined(__OBJC__)
48
49 // AcceleratedWidgetMac owns a tree of CALayers. The widget may be passed 43 // AcceleratedWidgetMac owns a tree of CALayers. The widget may be passed
50 // to a ui::Compositor, which will cause, through its output surface, calls to 44 // to a ui::Compositor, which will cause, through its output surface, calls to
51 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed 45 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed
52 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper. 46 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper.
53 class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac { 47 class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
54 public: 48 public:
55 AcceleratedWidgetMac(); 49 AcceleratedWidgetMac();
56 virtual ~AcceleratedWidgetMac(); 50 virtual ~AcceleratedWidgetMac();
57 51
58 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; } 52 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; }
(...skipping 11 matching lines...) Expand all
70 // will return a conservative answer. 64 // will return a conservative answer.
71 bool MightBeInFullscreenLowPowerMode() const; 65 bool MightBeInFullscreenLowPowerMode() const;
72 66
73 // Return true if the last frame swapped has a size in DIP of |dip_size|. 67 // Return true if the last frame swapped has a size in DIP of |dip_size|.
74 bool HasFrameOfSize(const gfx::Size& dip_size) const; 68 bool HasFrameOfSize(const gfx::Size& dip_size) const;
75 69
76 // Populate the vsync parameters for the surface's display. 70 // Populate the vsync parameters for the surface's display.
77 void GetVSyncParameters( 71 void GetVSyncParameters(
78 base::TimeTicks* timebase, base::TimeDelta* interval) const; 72 base::TimeTicks* timebase, base::TimeDelta* interval) const;
79 73
80 void GotFrame(CAContextID ca_context_id, 74 static AcceleratedWidgetMac* Get(gfx::AcceleratedWidget widget);
81 bool fullscreen_low_power_ca_context_valid, 75 void GotCALayerFrame(
82 CAContextID fullscreen_low_power_ca_context_id, 76 base::scoped_nsobject<CALayer> content_layer,
83 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 77 bool fullscreen_low_power_layer_valid,
84 const gfx::Size& pixel_size, 78 base::scoped_nsobject<CALayer> fullscreen_low_power_layer,
85 float scale_factor); 79 const gfx::Size& pixel_size,
86 80 float scale_factor);
87 private:
88 void GotCAContextFrame(CAContextID ca_context_id,
89 bool fullscreen_low_power_ca_context_valid,
90 CAContextID fullscreen_low_power_ca_context_id,
91 const gfx::Size& pixel_size,
92 float scale_factor);
93
94 void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 81 void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
95 const gfx::Size& pixel_size, 82 const gfx::Size& pixel_size,
96 float scale_factor); 83 float scale_factor);
97 84
98 // Remove a layer from the heirarchy and destroy it. Because the accelerated 85 private:
99 // layer types may be replaced by a layer of the same type, the layer to
100 // destroy is parameterized, and, if it is the current layer, the current
101 // layer is reset.
102 void DestroyCAContextLayer(
103 base::scoped_nsobject<CALayerHost> ca_context_layer);
104 void DestroyLocalLayer();
105 void EnsureLocalLayer();
106
107 // The AcceleratedWidgetMacNSView that is using this as its internals. 86 // The AcceleratedWidgetMacNSView that is using this as its internals.
108 AcceleratedWidgetMacNSView* view_; 87 AcceleratedWidgetMacNSView* view_;
109 88
110 // A phony NSView handle used to identify this. 89 // A phony NSView handle used to identify this.
111 gfx::AcceleratedWidget native_widget_; 90 gfx::AcceleratedWidget native_widget_;
112 91
113 // The fullscreen low power coordinator. Weak, reset by 92 // The fullscreen low power coordinator. Weak, reset by
114 // SetFullscreenLowPowerCoordinator when it is destroyed. 93 // SetFullscreenLowPowerCoordinator when it is destroyed.
115 FullscreenLowPowerCoordinator* fslp_coordinator_ = nullptr; 94 FullscreenLowPowerCoordinator* fslp_coordinator_ = nullptr;
116 95
117 // A flipped layer, which acts as the parent of the compositing and software 96 // A flipped layer, which acts as the parent of the compositing and software
118 // layers. This layer is flipped so that the we don't need to recompute the 97 // layers. This layer is flipped so that the we don't need to recompute the
119 // origin for sub-layers when their position changes (this is impossible when 98 // origin for sub-layers when their position changes (this is impossible when
120 // using remote layers, as their size change cannot be synchronized with the 99 // using remote layers, as their size change cannot be synchronized with the
121 // window). This indirection is needed because flipping hosted layers (like 100 // window). This indirection is needed because flipping hosted layers (like
122 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable 101 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable
123 // behavior. 102 // behavior.
124 base::scoped_nsobject<CALayer> flipped_layer_; 103 base::scoped_nsobject<CALayer> flipped_layer_;
125 104
126 // The accelerated CoreAnimation layers hosted by the GPU process. 105 // A CALayer with content provided by the output surface.
127 base::scoped_nsobject<CALayerHost> ca_context_layer_; 106 base::scoped_nsobject<CALayer> content_layer_;
128 base::scoped_nsobject<CALayerHost> fullscreen_low_power_layer_; 107 base::scoped_nsobject<CALayer> fullscreen_low_power_layer_;
129 108
130 // The locally drawn layer, which has its contents set to an IOSurface. 109 // A CALayer that has its content set to an IOSurface.
131 base::scoped_nsobject<CALayer> local_layer_; 110 base::scoped_nsobject<CALayer> io_surface_layer_;
132 111
133 // The size in DIP of the last swap received from |compositor_|. 112 // The size in DIP of the last swap received from |compositor_|.
134 gfx::Size last_swap_size_dip_; 113 gfx::Size last_swap_size_dip_;
135 114
136 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac); 115 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac);
137 }; 116 };
138 117
139 #endif // __OBJC__
140
141 ACCELERATED_WIDGET_MAC_EXPORT
142 void AcceleratedWidgetMacGotFrame(
143 gfx::AcceleratedWidget widget,
144 CAContextID ca_context_id,
145 bool fullscreen_low_power_ca_context_valid,
146 CAContextID fullscreen_low_power_ca_context_id,
147 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
148 const gfx::Size& pixel_size,
149 float scale_factor,
150 base::TimeTicks* vsync_timebase,
151 base::TimeDelta* vsync_interval);
152
153 } // namespace ui 118 } // namespace ui
154 119
155 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_ 120 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/browser_compositor_view_mac.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