| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // Called by the compositor on the compositor thread. This is a place where | 72 // 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 | 73 // thread-specific data for the output surface can be initialized, since from |
| 74 // this point to when DetachFromClient() is called the output surface will | 74 // this point to when DetachFromClient() is called the output surface will |
| 75 // only be used on the compositor thread. | 75 // only be used on the compositor thread. |
| 76 // The caller should call DetachFromClient() on the same thread before | 76 // The caller should call DetachFromClient() on the same thread before |
| 77 // destroying the OutputSurface, even if this fails. And BindToClient should | 77 // destroying the OutputSurface, even if this fails. And BindToClient should |
| 78 // not be called twice for a given OutputSurface. | 78 // not be called twice for a given OutputSurface. |
| 79 virtual bool BindToClient(OutputSurfaceClient* client); | 79 virtual bool BindToClient(OutputSurfaceClient* client); |
| 80 | 80 |
| 81 // Called by the compositor on the compositor thread. This is a place where | |
| 82 // thread-specific data for the output surface can be uninitialized. | |
| 83 virtual void DetachFromClient(); | |
| 84 | |
| 85 bool HasClient() { return !!client_; } | |
| 86 | |
| 87 const Capabilities& capabilities() const { return capabilities_; } | 81 const Capabilities& capabilities() const { return capabilities_; } |
| 88 | 82 |
| 89 // Obtain the 3d context or the software device associated with this output | 83 // Obtain the 3d context or the software device associated with this output |
| 90 // surface. Either of these may return a null pointer, but not both. | 84 // surface. Either of these may return a null pointer, but not both. |
| 91 // In the event of a lost context, the entire output surface should be | 85 // In the event of a lost context, the entire output surface should be |
| 92 // recreated. | 86 // recreated. |
| 93 ContextProvider* context_provider() const { return context_provider_.get(); } | 87 ContextProvider* context_provider() const { return context_provider_.get(); } |
| 94 VulkanContextProvider* vulkan_context_provider() const { | 88 VulkanContextProvider* vulkan_context_provider() const { |
| 95 return vulkan_context_provider_.get(); | 89 return vulkan_context_provider_.get(); |
| 96 } | 90 } |
| 97 SoftwareOutputDevice* software_device() const { | 91 SoftwareOutputDevice* software_device() const { |
| 98 return software_device_.get(); | 92 return software_device_.get(); |
| 99 } | 93 } |
| 100 | 94 |
| 101 virtual void EnsureBackbuffer(); | 95 virtual void EnsureBackbuffer() = 0; |
| 102 virtual void DiscardBackbuffer(); | 96 virtual void DiscardBackbuffer() = 0; |
| 97 |
| 98 // Bind the default framebuffer for drawing to, only valid for GL backed |
| 99 // OutputSurfaces. |
| 100 virtual void BindFramebuffer() = 0; |
| 103 | 101 |
| 104 const gfx::ColorSpace& device_color_space() const { | 102 const gfx::ColorSpace& device_color_space() const { |
| 105 return device_color_space_; | 103 return device_color_space_; |
| 106 } | 104 } |
| 107 | 105 |
| 108 // Called by subclasses after receiving a response from the gpu process to a | |
| 109 // query about whether a given set of textures is still in use by the OS | |
| 110 // compositor. | |
| 111 void DidReceiveTextureInUseResponses( | |
| 112 const gpu::TextureInUseResponses& responses); | |
| 113 | |
| 114 // Get the class capable of informing cc of hardware overlay capability. | 106 // Get the class capable of informing cc of hardware overlay capability. |
| 115 virtual OverlayCandidateValidator* GetOverlayCandidateValidator() const; | 107 virtual OverlayCandidateValidator* GetOverlayCandidateValidator() const = 0; |
| 116 | 108 |
| 117 // Returns true if a main image overlay plane should be scheduled. | 109 // Returns true if a main image overlay plane should be scheduled. |
| 118 virtual bool IsDisplayedAsOverlayPlane() const; | 110 virtual bool IsDisplayedAsOverlayPlane() const = 0; |
| 119 | 111 |
| 120 // Get the texture for the main image's overlay. | 112 // Get the texture for the main image's overlay. |
| 121 virtual unsigned GetOverlayTextureId() const; | 113 virtual unsigned GetOverlayTextureId() const = 0; |
| 122 | 114 |
| 123 // If this returns true, then the surface will not attempt to draw. | 115 // If this returns true, then the surface will not attempt to draw. |
| 124 virtual bool SurfaceIsSuspendForRecycle() const; | 116 virtual bool SurfaceIsSuspendForRecycle() const = 0; |
| 125 | 117 |
| 126 virtual void Reshape(const gfx::Size& size, | 118 virtual void Reshape(const gfx::Size& size, |
| 127 float scale_factor, | 119 float scale_factor, |
| 128 const gfx::ColorSpace& color_space, | 120 const gfx::ColorSpace& color_space, |
| 129 bool alpha); | 121 bool alpha); |
| 130 gfx::Size SurfaceSize() const { return surface_size_; } | 122 gfx::Size SurfaceSize() const { return surface_size_; } |
| 131 | 123 |
| 132 virtual void BindFramebuffer(); | 124 virtual bool HasExternalStencilTest() const = 0; |
| 133 | 125 virtual void ApplyExternalStencil() = 0; |
| 134 virtual bool HasExternalStencilTest() const; | |
| 135 virtual void ApplyExternalStencil(); | |
| 136 | 126 |
| 137 // Gives the GL internal format that should be used for calling CopyTexImage2D | 127 // Gives the GL internal format that should be used for calling CopyTexImage2D |
| 138 // when the framebuffer is bound via BindFramebuffer(). | 128 // when the framebuffer is bound via BindFramebuffer(). |
| 139 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; | 129 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; |
| 140 | 130 |
| 141 // The implementation may destroy or steal the contents of the CompositorFrame | 131 // The implementation may destroy or steal the contents of the CompositorFrame |
| 142 // passed in (though it will not take ownership of the CompositorFrame | 132 // passed in (though it will not take ownership of the CompositorFrame |
| 143 // itself). For successful swaps, the implementation must call | 133 // itself). For successful swaps, the implementation must call |
| 144 // DidSwapBuffersComplete() (via OnSwapBuffersComplete()) eventually. | 134 // OutputSurfaceClient::DidSwapBuffersComplete() eventually. |
| 145 virtual void SwapBuffers(CompositorFrame frame) = 0; | 135 virtual void SwapBuffers(CompositorFrame frame) = 0; |
| 146 virtual void OnSwapBuffersComplete(); | |
| 147 | 136 |
| 148 // base::trace_event::MemoryDumpProvider implementation. | 137 // base::trace_event::MemoryDumpProvider implementation. |
| 149 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 138 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 150 base::trace_event::ProcessMemoryDump* pmd) override; | 139 base::trace_event::ProcessMemoryDump* pmd) override; |
| 151 | 140 |
| 152 protected: | 141 protected: |
| 153 void PostSwapBuffersComplete(); | 142 void PostSwapBuffersComplete(); |
| 154 | 143 |
| 155 // Used internally for the context provider to inform the client about loss, | 144 // Used internally for the context provider to inform the client about loss, |
| 156 // and can be overridden to change behaviour instead of informing the client. | 145 // and can be overridden to change behaviour instead of informing the client. |
| 157 virtual void DidLoseOutputSurface(); | 146 virtual void DidLoseOutputSurface(); |
| 158 | 147 |
| 159 OutputSurfaceClient* client_ = nullptr; | 148 OutputSurfaceClient* client_ = nullptr; |
| 160 | 149 |
| 161 struct OutputSurface::Capabilities capabilities_; | 150 struct OutputSurface::Capabilities capabilities_; |
| 162 scoped_refptr<ContextProvider> context_provider_; | 151 scoped_refptr<ContextProvider> context_provider_; |
| 163 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; | 152 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; |
| 164 std::unique_ptr<SoftwareOutputDevice> software_device_; | 153 std::unique_ptr<SoftwareOutputDevice> software_device_; |
| 165 gfx::Size surface_size_; | 154 gfx::Size surface_size_; |
| 166 float device_scale_factor_ = -1; | 155 float device_scale_factor_ = -1; |
| 167 gfx::ColorSpace device_color_space_; | 156 gfx::ColorSpace device_color_space_; |
| 168 bool has_alpha_ = true; | 157 bool has_alpha_ = true; |
| 169 gfx::ColorSpace color_space_; | 158 gfx::ColorSpace color_space_; |
| 170 base::ThreadChecker client_thread_checker_; | 159 base::ThreadChecker thread_checker_; |
| 171 | 160 |
| 172 private: | 161 private: |
| 173 void DetachFromClientInternal(); | 162 void OnSwapBuffersComplete(); |
| 174 | 163 |
| 175 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 164 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
| 176 | 165 |
| 177 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 166 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 178 }; | 167 }; |
| 179 | 168 |
| 180 } // namespace cc | 169 } // namespace cc |
| 181 | 170 |
| 182 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 171 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |