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

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

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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_OUTPUT_SURFACE_H_
6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ 6 #define CC_OUTPUT_OUTPUT_SURFACE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 // Represents the output surface for a compositor. The compositor owns 40 // Represents the output surface for a compositor. The compositor owns
41 // and manages its destruction. Its lifetime is: 41 // and manages its destruction. Its lifetime is:
42 // 1. Created on the main thread by the LayerTreeHost through its client. 42 // 1. Created on the main thread by the LayerTreeHost through its client.
43 // 2. Passed to the compositor thread and bound to a client via BindToClient. 43 // 2. Passed to the compositor thread and bound to a client via BindToClient.
44 // From here on, it will only be used on the compositor thread. 44 // From here on, it will only be used on the compositor thread.
45 // 3. If the 3D context is lost, then the compositor will delete the output 45 // 3. If the 3D context is lost, then the compositor will delete the output
46 // surface (on the compositor thread) and go back to step 1. 46 // surface (on the compositor thread) and go back to step 1.
47 class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider { 47 class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider {
48 public: 48 public:
49 OutputSurface(scoped_refptr<ContextProvider> context_provider, 49 OutputSurface(
50 scoped_refptr<ContextProvider> worker_context_provider, 50 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
51 scoped_refptr<VulkanContextProvider> vulkan_context_provider, 51 scoped_refptr<ContextProvider> worker_context_provider,
piman 2016/05/17 03:41:40 Is the intent that the worker will also come from
danakj 2016/05/17 19:53:33 Yes. I did the compositor one first since it's alr
52 std::unique_ptr<SoftwareOutputDevice> software_device); 52 scoped_refptr<VulkanContextProvider> vulkan_context_provider,
53 OutputSurface(scoped_refptr<ContextProvider> context_provider, 53 std::unique_ptr<SoftwareOutputDevice> software_device);
54 scoped_refptr<ContextProvider> worker_context_provider); 54 OutputSurface(
55 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); 55 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
56 scoped_refptr<ContextProvider> worker_context_provider);
57 explicit OutputSurface(
58 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create);
56 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); 59 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device);
57 60
58 OutputSurface(scoped_refptr<ContextProvider> context_provider, 61 OutputSurface(
59 std::unique_ptr<SoftwareOutputDevice> software_device); 62 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
63 std::unique_ptr<SoftwareOutputDevice> software_device);
60 64
61 ~OutputSurface() override; 65 ~OutputSurface() override;
62 66
63 struct Capabilities { 67 struct Capabilities {
64 Capabilities() 68 Capabilities()
65 : delegated_rendering(false), 69 : delegated_rendering(false),
66 max_frames_pending(1), 70 max_frames_pending(1),
67 adjust_deadline_for_parent(true), 71 adjust_deadline_for_parent(true),
68 uses_default_gl_framebuffer(true), 72 uses_default_gl_framebuffer(true),
69 flipped_output_surface(false), 73 flipped_output_surface(false),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // base::trace_event::MemoryDumpProvider implementation. 174 // base::trace_event::MemoryDumpProvider implementation.
171 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 175 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
172 base::trace_event::ProcessMemoryDump* pmd) override; 176 base::trace_event::ProcessMemoryDump* pmd) override;
173 177
174 protected: 178 protected:
175 OutputSurfaceClient* client_; 179 OutputSurfaceClient* client_;
176 180
177 void PostSwapBuffersComplete(); 181 void PostSwapBuffersComplete();
178 182
179 struct OutputSurface::Capabilities capabilities_; 183 struct OutputSurface::Capabilities capabilities_;
184 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create_;
180 scoped_refptr<ContextProvider> context_provider_; 185 scoped_refptr<ContextProvider> context_provider_;
181 scoped_refptr<ContextProvider> worker_context_provider_; 186 scoped_refptr<ContextProvider> worker_context_provider_;
182 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; 187 scoped_refptr<VulkanContextProvider> vulkan_context_provider_;
183 std::unique_ptr<SoftwareOutputDevice> software_device_; 188 std::unique_ptr<SoftwareOutputDevice> software_device_;
184 gfx::Size surface_size_; 189 gfx::Size surface_size_;
185 float device_scale_factor_; 190 float device_scale_factor_;
186 bool has_alpha_; 191 bool has_alpha_;
187 base::ThreadChecker client_thread_checker_; 192 base::ThreadChecker client_thread_checker_;
188 193
189 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); 194 void SetNeedsRedrawRect(const gfx::Rect& damage_rect);
190 void ReclaimResources(const CompositorFrameAck* ack); 195 void ReclaimResources(const CompositorFrameAck* ack);
191 void SetExternalStencilTest(bool enabled); 196 void SetExternalStencilTest(bool enabled);
192 void DetachFromClientInternal(); 197 void DetachFromClientInternal();
193 198
194 private: 199 private:
195 bool external_stencil_test_enabled_; 200 bool external_stencil_test_enabled_;
196 201
197 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; 202 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_;
198 203
199 DISALLOW_COPY_AND_ASSIGN(OutputSurface); 204 DISALLOW_COPY_AND_ASSIGN(OutputSurface);
200 }; 205 };
201 206
202 } // namespace cc 207 } // namespace cc
203 208
204 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ 209 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698