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

Side by Side Diff: cc/output/compositor_frame_sink.h

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 years, 3 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 | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/output/compositor_frame_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 CC_OUTPUT_OUTPUT_SURFACE_H_ 5 #ifndef CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ 6 #define CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/trace_event/memory_dump_provider.h" 15 #include "base/trace_event/memory_dump_provider.h"
16 #include "cc/base/cc_export.h" 16 #include "cc/base/cc_export.h"
(...skipping 13 matching lines...) Expand all
30 class ColorSpace; 30 class ColorSpace;
31 class Rect; 31 class Rect;
32 class Size; 32 class Size;
33 class Transform; 33 class Transform;
34 } 34 }
35 35
36 namespace cc { 36 namespace cc {
37 37
38 class CompositorFrame; 38 class CompositorFrame;
39 struct ManagedMemoryPolicy; 39 struct ManagedMemoryPolicy;
40 class OutputSurfaceClient; 40 class CompositorFrameSinkClient;
41 41
42 // Represents the output surface for a compositor. The compositor owns 42 // Represents the output surface for a compositor. The compositor owns
43 // and manages its destruction. Its lifetime is: 43 // and manages its destruction. Its lifetime is:
44 // 1. Created on the main thread by the LayerTreeHost through its client. 44 // 1. Created on the main thread by the LayerTreeHost through its client.
45 // 2. Passed to the compositor thread and bound to a client via BindToClient. 45 // 2. Passed to the compositor thread and bound to a client via BindToClient.
46 // From here on, it will only be used on the compositor thread. 46 // From here on, it will only be used on the compositor thread.
47 // 3. If the 3D context is lost, then the compositor will delete the output 47 // 3. If the 3D context is lost, then the compositor will delete the output
48 // surface (on the compositor thread) and go back to step 1. 48 // surface (on the compositor thread) and go back to step 1.
49 class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider { 49 class CC_EXPORT CompositorFrameSink
50 : public base::trace_event::MemoryDumpProvider {
50 public: 51 public:
51 // Constructor for GL-based and/or software compositing. 52 // Constructor for GL-based and/or software compositing.
52 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider, 53 explicit CompositorFrameSink(
53 scoped_refptr<ContextProvider> worker_context_provider, 54 scoped_refptr<ContextProvider> context_provider,
54 std::unique_ptr<SoftwareOutputDevice> software_device); 55 scoped_refptr<ContextProvider> worker_context_provider,
56 std::unique_ptr<SoftwareOutputDevice> software_device);
55 57
56 // Constructor for Vulkan-based compositing. 58 // Constructor for Vulkan-based compositing.
57 explicit OutputSurface( 59 explicit CompositorFrameSink(
58 scoped_refptr<VulkanContextProvider> vulkan_context_provider); 60 scoped_refptr<VulkanContextProvider> vulkan_context_provider);
59 61
60 ~OutputSurface() override; 62 ~CompositorFrameSink() override;
61 63
62 struct Capabilities { 64 struct Capabilities {
63 Capabilities() 65 Capabilities()
64 : delegated_rendering(false), 66 : delegated_rendering(false),
65 max_frames_pending(1), 67 max_frames_pending(1),
66 adjust_deadline_for_parent(true), 68 adjust_deadline_for_parent(true),
67 uses_default_gl_framebuffer(true), 69 uses_default_gl_framebuffer(true),
68 flipped_output_surface(false), 70 flipped_compositor_frame_sink(false),
69 can_force_reclaim_resources(false), 71 can_force_reclaim_resources(false),
70 delegated_sync_points_required(true) {} 72 delegated_sync_points_required(true) {}
71 bool delegated_rendering; 73 bool delegated_rendering;
72 int max_frames_pending; 74 int max_frames_pending;
73 // This doesn't handle the <webview> case, but once BeginFrame is 75 // This doesn't handle the <webview> case, but once BeginFrame is
74 // supported natively, we shouldn't need adjust_deadline_for_parent. 76 // supported natively, we shouldn't need adjust_deadline_for_parent.
75 bool adjust_deadline_for_parent; 77 bool adjust_deadline_for_parent;
76 // Whether this output surface renders to the default OpenGL zero 78 // Whether this output surface renders to the default OpenGL zero
77 // framebuffer or to an offscreen framebuffer. 79 // framebuffer or to an offscreen framebuffer.
78 bool uses_default_gl_framebuffer; 80 bool uses_default_gl_framebuffer;
79 // Whether this OutputSurface is flipped or not. 81 // Whether this CompositorFrameSink is flipped or not.
80 bool flipped_output_surface; 82 bool flipped_compositor_frame_sink;
81 // Whether ForceReclaimResources can be called to reclaim all resources 83 // Whether ForceReclaimResources can be called to reclaim all resources
82 // from the OutputSurface. 84 // from the CompositorFrameSink.
83 bool can_force_reclaim_resources; 85 bool can_force_reclaim_resources;
84 // True if sync points for resources are needed when swapping delegated 86 // True if sync points for resources are needed when swapping delegated
85 // frames. 87 // frames.
86 bool delegated_sync_points_required; 88 bool delegated_sync_points_required;
87 }; 89 };
88 90
89 // ============== DISPLAY COMPOSITOR ONLY ======================= 91 // ============== DISPLAY COMPOSITOR ONLY =======================
90 92
91 virtual void EnsureBackbuffer(); 93 virtual void EnsureBackbuffer();
92 virtual void DiscardBackbuffer(); 94 virtual void DiscardBackbuffer();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // currently in use. 130 // currently in use.
129 virtual void ForceReclaimResources() {} 131 virtual void ForceReclaimResources() {}
130 132
131 virtual void BindFramebuffer(); 133 virtual void BindFramebuffer();
132 // Gives the GL internal format that should be used for calling CopyTexImage2D 134 // Gives the GL internal format that should be used for calling CopyTexImage2D
133 // when the framebuffer is bound via BindFramebuffer(). 135 // when the framebuffer is bound via BindFramebuffer().
134 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; 136 virtual uint32_t GetFramebufferCopyTextureFormat() = 0;
135 137
136 // Support for a pull-model where draws are requested by the output surface. 138 // Support for a pull-model where draws are requested by the output surface.
137 // 139 //
138 // OutputSurface::Invalidate is called by the compositor to notify that 140 // CompositorFrameSink::Invalidate is called by the compositor to notify that
139 // there's new content. 141 // there's new content.
140 virtual void Invalidate() {} 142 virtual void Invalidate() {}
141 143
142 // ============== BOTH TYPES OF COMPOSITOR ====================== 144 // ============== BOTH TYPES OF COMPOSITOR ======================
143 145
144 // Called by the compositor on the compositor thread. This is a place where 146 // Called by the compositor on the compositor thread. This is a place where
145 // thread-specific data for the output surface can be initialized, since from 147 // thread-specific data for the output surface can be initialized, since from
146 // this point to when DetachFromClient() is called the output surface will 148 // this point to when DetachFromClient() is called the output surface will
147 // only be used on the compositor thread. 149 // only be used on the compositor thread.
148 // The caller should call DetachFromClient() on the same thread before 150 // The caller should call DetachFromClient() on the same thread before
149 // destroying the OutputSurface, even if this fails. And BindToClient should 151 // destroying the CompositorFrameSink, even if this fails. And BindToClient
150 // not be called twice for a given OutputSurface. 152 // should not be called twice for a given CompositorFrameSink.
151 virtual bool BindToClient(OutputSurfaceClient* client); 153 virtual bool BindToClient(CompositorFrameSinkClient* client);
152 154
153 // Called by the compositor on the compositor thread. This is a place where 155 // Called by the compositor on the compositor thread. This is a place where
154 // thread-specific data for the output surface can be uninitialized. 156 // thread-specific data for the output surface can be uninitialized.
155 virtual void DetachFromClient(); 157 virtual void DetachFromClient();
156 158
157 bool HasClient() { return !!client_; } 159 bool HasClient() { return !!client_; }
158 160
159 const Capabilities& capabilities() const { return capabilities_; } 161 const Capabilities& capabilities() const { return capabilities_; }
160 162
161 // Obtain the 3d context or the software device associated with this output 163 // Obtain the 3d context or the software device associated with this output
(...skipping 23 matching lines...) Expand all
185 base::trace_event::ProcessMemoryDump* pmd) override; 187 base::trace_event::ProcessMemoryDump* pmd) override;
186 188
187 protected: 189 protected:
188 // This is used by both display and delegating implementations. 190 // This is used by both display and delegating implementations.
189 void PostSwapBuffersComplete(); 191 void PostSwapBuffersComplete();
190 192
191 // This is how LayerTreeHostImpl hears about context loss when the Display 193 // This is how LayerTreeHostImpl hears about context loss when the Display
192 // is the one listening for context loss. Also used internally for the 194 // is the one listening for context loss. Also used internally for the
193 // context provider to inform the LayerTreeHostImpl or Display about loss. 195 // context provider to inform the LayerTreeHostImpl or Display about loss.
194 // It would become display-compositor-only when LayerTreeHostImpl receives 196 // It would become display-compositor-only when LayerTreeHostImpl receives
195 // its contexts independently from the "OutputSurface". 197 // its contexts independently from the "CompositorFrameSink".
196 virtual void DidLoseOutputSurface(); 198 virtual void DidLoseCompositorFrameSink();
197 199
198 OutputSurfaceClient* client_ = nullptr; 200 CompositorFrameSinkClient* client_ = nullptr;
199 201
200 struct OutputSurface::Capabilities capabilities_; 202 struct CompositorFrameSink::Capabilities capabilities_;
201 scoped_refptr<ContextProvider> context_provider_; 203 scoped_refptr<ContextProvider> context_provider_;
202 scoped_refptr<ContextProvider> worker_context_provider_; 204 scoped_refptr<ContextProvider> worker_context_provider_;
203 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; 205 scoped_refptr<VulkanContextProvider> vulkan_context_provider_;
204 std::unique_ptr<SoftwareOutputDevice> software_device_; 206 std::unique_ptr<SoftwareOutputDevice> software_device_;
205 gfx::Size surface_size_; 207 gfx::Size surface_size_;
206 float device_scale_factor_ = -1; 208 float device_scale_factor_ = -1;
207 gfx::ColorSpace device_color_space_; 209 gfx::ColorSpace device_color_space_;
208 bool has_alpha_ = true; 210 bool has_alpha_ = true;
209 gfx::ColorSpace color_space_; 211 gfx::ColorSpace color_space_;
210 base::ThreadChecker client_thread_checker_; 212 base::ThreadChecker client_thread_checker_;
211 213
212 private: 214 private:
213 void DetachFromClientInternal(); 215 void DetachFromClientInternal();
214 216
215 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; 217 base::WeakPtrFactory<CompositorFrameSink> weak_ptr_factory_;
216 218
217 DISALLOW_COPY_AND_ASSIGN(OutputSurface); 219 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSink);
218 }; 220 };
219 221
220 } // namespace cc 222 } // namespace cc
221 223
222 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ 224 #endif // CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/output/compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698