| 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 |
| 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" | |
| 16 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
| 17 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
| 18 #include "cc/output/overlay_candidate_validator.h" | 17 #include "cc/output/overlay_candidate_validator.h" |
| 19 #include "cc/output/software_output_device.h" | 18 #include "cc/output/software_output_device.h" |
| 20 #include "cc/output/vulkan_context_provider.h" | 19 #include "cc/output/vulkan_context_provider.h" |
| 21 #include "cc/resources/returned_resource.h" | 20 #include "cc/resources/returned_resource.h" |
| 22 #include "gpu/command_buffer/common/texture_in_use_response.h" | 21 #include "gpu/command_buffer/common/texture_in_use_response.h" |
| 23 #include "ui/gfx/color_space.h" | 22 #include "ui/gfx/color_space.h" |
| 24 | 23 |
| 25 namespace ui { | 24 namespace ui { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 class OutputSurfaceClient; | 38 class OutputSurfaceClient; |
| 40 class OutputSurfaceFrame; | 39 class OutputSurfaceFrame; |
| 41 | 40 |
| 42 // Represents the output surface for a compositor. The compositor owns | 41 // Represents the output surface for a compositor. The compositor owns |
| 43 // and manages its destruction. Its lifetime is: | 42 // and manages its destruction. Its lifetime is: |
| 44 // 1. Created on the main thread by the LayerTreeHost through its client. | 43 // 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. | 44 // 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. | 45 // 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 | 46 // 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. | 47 // surface (on the compositor thread) and go back to step 1. |
| 49 class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider { | 48 class CC_EXPORT OutputSurface { |
| 50 public: | 49 public: |
| 51 struct Capabilities { | 50 struct Capabilities { |
| 52 Capabilities() = default; | 51 Capabilities() = default; |
| 53 | 52 |
| 54 int max_frames_pending = 1; | 53 int max_frames_pending = 1; |
| 55 // Whether this output surface renders to the default OpenGL zero | 54 // Whether this output surface renders to the default OpenGL zero |
| 56 // framebuffer or to an offscreen framebuffer. | 55 // framebuffer or to an offscreen framebuffer. |
| 57 bool uses_default_gl_framebuffer = true; | 56 bool uses_default_gl_framebuffer = true; |
| 58 // Whether this OutputSurface is flipped or not. | 57 // Whether this OutputSurface is flipped or not. |
| 59 bool flipped_output_surface = false; | 58 bool flipped_output_surface = false; |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 // Constructor for GL-based compositing. | 61 // Constructor for GL-based compositing. |
| 63 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); | 62 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); |
| 64 // Constructor for software compositing. | 63 // Constructor for software compositing. |
| 65 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); | 64 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); |
| 66 // Constructor for Vulkan-based compositing. | 65 // Constructor for Vulkan-based compositing. |
| 67 explicit OutputSurface( | 66 explicit OutputSurface( |
| 68 scoped_refptr<VulkanContextProvider> vulkan_context_provider); | 67 scoped_refptr<VulkanContextProvider> vulkan_context_provider); |
| 69 | 68 |
| 70 ~OutputSurface() override; | 69 virtual ~OutputSurface(); |
| 71 | 70 |
| 72 // Called by the compositor on the compositor thread. This is a place where | 71 // Called by the compositor on the compositor thread. This is a place where |
| 73 // thread-specific data for the output surface can be initialized, since from | 72 // thread-specific data for the output surface can be initialized, since from |
| 74 // this point to when DetachFromClient() is called the output surface will | 73 // this point to when DetachFromClient() is called the output surface will |
| 75 // only be used on the compositor thread. | 74 // only be used on the compositor thread. |
| 76 // The caller should call DetachFromClient() on the same thread before | 75 // The caller should call DetachFromClient() on the same thread before |
| 77 // destroying the OutputSurface, even if this fails. And BindToClient should | 76 // destroying the OutputSurface, even if this fails. And BindToClient should |
| 78 // not be called twice for a given OutputSurface. | 77 // not be called twice for a given OutputSurface. |
| 79 virtual bool BindToClient(OutputSurfaceClient* client); | 78 virtual bool BindToClient(OutputSurfaceClient* client); |
| 80 | 79 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Gives the GL internal format that should be used for calling CopyTexImage2D | 125 // Gives the GL internal format that should be used for calling CopyTexImage2D |
| 127 // when the framebuffer is bound via BindFramebuffer(). | 126 // when the framebuffer is bound via BindFramebuffer(). |
| 128 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; | 127 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; |
| 129 | 128 |
| 130 // The implementation may destroy or steal the contents of the CompositorFrame | 129 // The implementation may destroy or steal the contents of the CompositorFrame |
| 131 // passed in (though it will not take ownership of the CompositorFrame | 130 // passed in (though it will not take ownership of the CompositorFrame |
| 132 // itself). For successful swaps, the implementation must call | 131 // itself). For successful swaps, the implementation must call |
| 133 // OutputSurfaceClient::DidSwapBuffersComplete() eventually. | 132 // OutputSurfaceClient::DidSwapBuffersComplete() eventually. |
| 134 virtual void SwapBuffers(OutputSurfaceFrame frame) = 0; | 133 virtual void SwapBuffers(OutputSurfaceFrame frame) = 0; |
| 135 | 134 |
| 136 // base::trace_event::MemoryDumpProvider implementation. | |
| 137 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | |
| 138 base::trace_event::ProcessMemoryDump* pmd) override; | |
| 139 | |
| 140 protected: | 135 protected: |
| 141 void PostSwapBuffersComplete(); | 136 void PostSwapBuffersComplete(); |
| 142 | 137 |
| 143 // Used internally for the context provider to inform the client about loss, | 138 // Used internally for the context provider to inform the client about loss, |
| 144 // and can be overridden to change behaviour instead of informing the client. | 139 // and can be overridden to change behaviour instead of informing the client. |
| 145 virtual void DidLoseOutputSurface(); | 140 virtual void DidLoseOutputSurface(); |
| 146 | 141 |
| 147 OutputSurfaceClient* client_ = nullptr; | 142 OutputSurfaceClient* client_ = nullptr; |
| 148 | 143 |
| 149 struct OutputSurface::Capabilities capabilities_; | 144 struct OutputSurface::Capabilities capabilities_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 161 void OnSwapBuffersComplete(); | 156 void OnSwapBuffersComplete(); |
| 162 | 157 |
| 163 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 158 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
| 164 | 159 |
| 165 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 160 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 166 }; | 161 }; |
| 167 | 162 |
| 168 } // namespace cc | 163 } // namespace cc |
| 169 | 164 |
| 170 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 165 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |