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

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: Incorporate 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; 30 class AcceleratedWidgetMac;
tapted 2016/06/03 03:10:47 nit: remove
34 class FullscreenLowPowerCoordinator; 31 class FullscreenLowPowerCoordinator;
35 32
36 // A class through which an AcceleratedWidget may be bound to draw the contents 33 // 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 34 // of an NSView. An AcceleratedWidget may be bound to multiple different views
38 // throughout its lifetime (one at a time, though). 35 // throughout its lifetime (one at a time, though).
39 class AcceleratedWidgetMacNSView { 36 class AcceleratedWidgetMacNSView {
40 public: 37 public:
41 virtual NSView* AcceleratedWidgetGetNSView() const = 0; 38 virtual NSView* AcceleratedWidgetGetNSView() const = 0;
42 virtual void AcceleratedWidgetGetVSyncParameters( 39 virtual void AcceleratedWidgetGetVSyncParameters(
43 base::TimeTicks* timebase, base::TimeDelta* interval) const = 0; 40 base::TimeTicks* timebase, base::TimeDelta* interval) const = 0;
44 virtual void AcceleratedWidgetSwapCompleted() = 0; 41 virtual void AcceleratedWidgetSwapCompleted() = 0;
45 }; 42 };
46 43
47 #if defined(__OBJC__)
48
49 // AcceleratedWidgetMac owns a tree of CALayers. The widget may be passed 44 // 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 45 // to a ui::Compositor, which will cause, through its output surface, calls to
51 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed 46 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed
52 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper. 47 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper.
53 class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac { 48 class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
54 public: 49 public:
55 AcceleratedWidgetMac(); 50 AcceleratedWidgetMac();
56 virtual ~AcceleratedWidgetMac(); 51 virtual ~AcceleratedWidgetMac();
57 52
58 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; } 53 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; }
(...skipping 11 matching lines...) Expand all
70 // will return a conservative answer. 65 // will return a conservative answer.
71 bool MightBeInFullscreenLowPowerMode() const; 66 bool MightBeInFullscreenLowPowerMode() const;
72 67
73 // Return true if the last frame swapped has a size in DIP of |dip_size|. 68 // Return true if the last frame swapped has a size in DIP of |dip_size|.
74 bool HasFrameOfSize(const gfx::Size& dip_size) const; 69 bool HasFrameOfSize(const gfx::Size& dip_size) const;
75 70
76 // Populate the vsync parameters for the surface's display. 71 // Populate the vsync parameters for the surface's display.
77 void GetVSyncParameters( 72 void GetVSyncParameters(
78 base::TimeTicks* timebase, base::TimeDelta* interval) const; 73 base::TimeTicks* timebase, base::TimeDelta* interval) const;
79 74
80 void GotFrame(CAContextID ca_context_id, 75 static AcceleratedWidgetMac* Get(gfx::AcceleratedWidget widget);
81 bool fullscreen_low_power_ca_context_valid, 76 void GotCALayerFrame(
82 CAContextID fullscreen_low_power_ca_context_id, 77 base::scoped_nsobject<CALayer> content_layer,
83 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 78 bool fullscreen_low_power_layer_valid,
84 const gfx::Size& pixel_size, 79 base::scoped_nsobject<CALayer> fullscreen_low_power_layer,
85 float scale_factor); 80 const gfx::Size& pixel_size,
86 81 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, 82 void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
95 const gfx::Size& pixel_size, 83 const gfx::Size& pixel_size,
96 float scale_factor); 84 float scale_factor);
97 85
98 // Remove a layer from the heirarchy and destroy it. Because the accelerated 86 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. 87 // The AcceleratedWidgetMacNSView that is using this as its internals.
108 AcceleratedWidgetMacNSView* view_; 88 AcceleratedWidgetMacNSView* view_;
109 89
110 // A phony NSView handle used to identify this. 90 // A phony NSView handle used to identify this.
111 gfx::AcceleratedWidget native_widget_; 91 gfx::AcceleratedWidget native_widget_;
112 92
113 // The fullscreen low power coordinator. Weak, reset by 93 // The fullscreen low power coordinator. Weak, reset by
114 // SetFullscreenLowPowerCoordinator when it is destroyed. 94 // SetFullscreenLowPowerCoordinator when it is destroyed.
115 FullscreenLowPowerCoordinator* fslp_coordinator_ = nullptr; 95 FullscreenLowPowerCoordinator* fslp_coordinator_ = nullptr;
116 96
117 // A flipped layer, which acts as the parent of the compositing and software 97 // 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 98 // 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 99 // 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 100 // using remote layers, as their size change cannot be synchronized with the
121 // window). This indirection is needed because flipping hosted layers (like 101 // window). This indirection is needed because flipping hosted layers (like
122 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable 102 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable
123 // behavior. 103 // behavior.
124 base::scoped_nsobject<CALayer> flipped_layer_; 104 base::scoped_nsobject<CALayer> flipped_layer_;
125 105
126 // The accelerated CoreAnimation layers hosted by the GPU process. 106 // A CALayer with content provided by the output surface.
127 base::scoped_nsobject<CALayerHost> ca_context_layer_; 107 base::scoped_nsobject<CALayer> content_layer_;
128 base::scoped_nsobject<CALayerHost> fullscreen_low_power_layer_; 108 base::scoped_nsobject<CALayer> fullscreen_low_power_layer_;
129 109
130 // The locally drawn layer, which has its contents set to an IOSurface. 110 // A CALayer that has its content set to an IOSurface.
131 base::scoped_nsobject<CALayer> local_layer_; 111 base::scoped_nsobject<CALayer> io_surface_layer_;
132 112
133 // The size in DIP of the last swap received from |compositor_|. 113 // The size in DIP of the last swap received from |compositor_|.
134 gfx::Size last_swap_size_dip_; 114 gfx::Size last_swap_size_dip_;
135 115
136 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac); 116 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac);
137 }; 117 };
138 118
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 119 } // namespace ui
154 120
155 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_ 121 #endif // UI_ACCELERATED_WIDGET_MAC_ACCELERATED_WIDGET_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698