| OLD | NEW |
| 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 Loading... |
| 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::Factory> compositor_context_factory, |
| 51 scoped_refptr<VulkanContextProvider> vulkan_context_provider, | 51 scoped_refptr<ContextProvider> worker_context_provider, |
| 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::Factory> compositor_context_factory, |
| 56 scoped_refptr<ContextProvider> worker_context_provider); |
| 57 explicit OutputSurface( |
| 58 std::unique_ptr<ContextProvider::Factory> compositor_context_factory); |
| 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::Factory> compositor_context_factory, |
| 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 21 matching lines...) Expand all Loading... |
| 91 return capabilities_; | 95 return capabilities_; |
| 92 } | 96 } |
| 93 | 97 |
| 94 virtual bool HasExternalStencilTest() const; | 98 virtual bool HasExternalStencilTest() const; |
| 95 virtual void ApplyExternalStencil(); | 99 virtual void ApplyExternalStencil(); |
| 96 | 100 |
| 97 // Obtain the 3d context or the software device associated with this output | 101 // Obtain the 3d context or the software device associated with this output |
| 98 // surface. Either of these may return a null pointer, but not both. | 102 // surface. Either of these may return a null pointer, but not both. |
| 99 // In the event of a lost context, the entire output surface should be | 103 // In the event of a lost context, the entire output surface should be |
| 100 // recreated. | 104 // recreated. |
| 101 ContextProvider* context_provider() const { return context_provider_.get(); } | 105 ContextProvider* context_provider() const { |
| 106 return compositor_context_provider_.get(); |
| 107 } |
| 102 ContextProvider* worker_context_provider() const { | 108 ContextProvider* worker_context_provider() const { |
| 103 return worker_context_provider_.get(); | 109 return worker_context_provider_.get(); |
| 104 } | 110 } |
| 105 VulkanContextProvider* vulkan_context_provider() const { | 111 VulkanContextProvider* vulkan_context_provider() const { |
| 106 return vulkan_context_provider_.get(); | 112 return vulkan_context_provider_.get(); |
| 107 } | 113 } |
| 108 SoftwareOutputDevice* software_device() const { | 114 SoftwareOutputDevice* software_device() const { |
| 109 return software_device_.get(); | 115 return software_device_.get(); |
| 110 } | 116 } |
| 111 | 117 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // base::trace_event::MemoryDumpProvider implementation. | 176 // base::trace_event::MemoryDumpProvider implementation. |
| 171 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 177 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 172 base::trace_event::ProcessMemoryDump* pmd) override; | 178 base::trace_event::ProcessMemoryDump* pmd) override; |
| 173 | 179 |
| 174 protected: | 180 protected: |
| 175 OutputSurfaceClient* client_; | 181 OutputSurfaceClient* client_; |
| 176 | 182 |
| 177 void PostSwapBuffersComplete(); | 183 void PostSwapBuffersComplete(); |
| 178 | 184 |
| 179 struct OutputSurface::Capabilities capabilities_; | 185 struct OutputSurface::Capabilities capabilities_; |
| 180 scoped_refptr<ContextProvider> context_provider_; | 186 std::unique_ptr<ContextProvider::Factory> compositor_context_factory_; |
| 187 scoped_refptr<ContextProvider> compositor_context_provider_; |
| 181 scoped_refptr<ContextProvider> worker_context_provider_; | 188 scoped_refptr<ContextProvider> worker_context_provider_; |
| 182 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; | 189 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; |
| 183 std::unique_ptr<SoftwareOutputDevice> software_device_; | 190 std::unique_ptr<SoftwareOutputDevice> software_device_; |
| 184 gfx::Size surface_size_; | 191 gfx::Size surface_size_; |
| 185 float device_scale_factor_; | 192 float device_scale_factor_; |
| 186 bool has_alpha_; | 193 bool has_alpha_; |
| 187 base::ThreadChecker client_thread_checker_; | 194 base::ThreadChecker client_thread_checker_; |
| 188 | 195 |
| 189 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); | 196 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); |
| 190 void ReclaimResources(const CompositorFrameAck* ack); | 197 void ReclaimResources(const CompositorFrameAck* ack); |
| 191 void SetExternalStencilTest(bool enabled); | 198 void SetExternalStencilTest(bool enabled); |
| 192 void DetachFromClientInternal(); | 199 void DetachFromClientInternal(); |
| 193 | 200 |
| 194 private: | 201 private: |
| 195 bool external_stencil_test_enabled_; | 202 bool external_stencil_test_enabled_; |
| 196 | 203 |
| 197 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 204 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
| 198 | 205 |
| 199 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 206 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 200 }; | 207 }; |
| 201 | 208 |
| 202 } // namespace cc | 209 } // namespace cc |
| 203 | 210 |
| 204 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 211 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |