| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 // If this returns true, then the surface will not attempt to draw. | 113 // If this returns true, then the surface will not attempt to draw. |
| 114 virtual bool SurfaceIsSuspendForRecycle() const; | 114 virtual bool SurfaceIsSuspendForRecycle() const; |
| 115 | 115 |
| 116 virtual void Reshape(const gfx::Size& size, | 116 virtual void Reshape(const gfx::Size& size, |
| 117 float scale_factor, | 117 float scale_factor, |
| 118 const gfx::ColorSpace& color_space, | 118 const gfx::ColorSpace& color_space, |
| 119 bool alpha); | 119 bool alpha); |
| 120 gfx::Size SurfaceSize() const { return surface_size_; } | 120 gfx::Size SurfaceSize() const { return surface_size_; } |
| 121 | 121 |
| 122 virtual bool HasExternalStencilTest() const; |
| 122 virtual void ApplyExternalStencil(); | 123 virtual void ApplyExternalStencil(); |
| 123 virtual bool HasExternalStencilTest() const; | |
| 124 | 124 |
| 125 // ============== LAYER TREE COMPOSITOR ONLY =================== | 125 // ============== LAYER TREE COMPOSITOR ONLY =================== |
| 126 | 126 |
| 127 // If supported, this causes a ReclaimResources for all resources that are | 127 // If supported, this causes a ReclaimResources for all resources that are |
| 128 // currently in use. | 128 // currently in use. |
| 129 virtual void ForceReclaimResources() {} | 129 virtual void ForceReclaimResources() {} |
| 130 | 130 |
| 131 virtual void BindFramebuffer(); | 131 virtual void BindFramebuffer(); |
| 132 // Gives the GL internal format that should be used for calling CopyTexImage2D | 132 // Gives the GL internal format that should be used for calling CopyTexImage2D |
| 133 // when the framebuffer is bound via BindFramebuffer(). | 133 // when the framebuffer is bound via BindFramebuffer(). |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return software_device_.get(); | 173 return software_device_.get(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // The implementation may destroy or steal the contents of the CompositorFrame | 176 // The implementation may destroy or steal the contents of the CompositorFrame |
| 177 // passed in (though it will not take ownership of the CompositorFrame | 177 // passed in (though it will not take ownership of the CompositorFrame |
| 178 // itself). For successful swaps, the implementation must call | 178 // itself). For successful swaps, the implementation must call |
| 179 // DidSwapBuffersComplete() (via OnSwapBuffersComplete()) eventually. | 179 // DidSwapBuffersComplete() (via OnSwapBuffersComplete()) eventually. |
| 180 virtual void SwapBuffers(CompositorFrame frame) = 0; | 180 virtual void SwapBuffers(CompositorFrame frame) = 0; |
| 181 virtual void OnSwapBuffersComplete(); | 181 virtual void OnSwapBuffersComplete(); |
| 182 | 182 |
| 183 // base::trace_event::MemoryDumpProvider implementation. |
| 184 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 185 base::trace_event::ProcessMemoryDump* pmd) override; |
| 186 |
| 187 protected: |
| 188 // This is used by both display and delegating implementations. |
| 189 void PostSwapBuffersComplete(); |
| 190 |
| 183 // This is how LayerTreeHostImpl hears about context loss when the Display | 191 // This is how LayerTreeHostImpl hears about context loss when the Display |
| 184 // is the one listening for context loss. Also used internally for the | 192 // is the one listening for context loss. Also used internally for the |
| 185 // context provider to inform the LayerTreeHostImpl or Display about loss. | 193 // context provider to inform the LayerTreeHostImpl or Display about loss. |
| 186 // It would become display-compositor-only when LayerTreeHostImpl receives | 194 // It would become display-compositor-only when LayerTreeHostImpl receives |
| 187 // its contexts independently from the "OutputSurface". | 195 // its contexts independently from the "OutputSurface". |
| 188 // TODO(danakj): Be private. Subclasses should just call the client directly. | |
| 189 virtual void DidLoseOutputSurface(); | 196 virtual void DidLoseOutputSurface(); |
| 190 | 197 |
| 191 // base::trace_event::MemoryDumpProvider implementation. | |
| 192 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | |
| 193 base::trace_event::ProcessMemoryDump* pmd) override; | |
| 194 | |
| 195 protected: | |
| 196 // ============== DISPLAY COMPOSITOR ONLY ======================= | |
| 197 | |
| 198 // Used by WebView for the display compositor only. | |
| 199 // TODO(danakj): This should go away, store the state in the subclass that | |
| 200 // uses this. | |
| 201 void SetExternalStencilTest(bool enabled); | |
| 202 | |
| 203 // ============== BOTH TYPES OF COMPOSITOR ====================== | |
| 204 | |
| 205 // This is used by both display and delegating implementations. | |
| 206 void PostSwapBuffersComplete(); | |
| 207 // TODO(danakj): Delete this. Subclasses should just call the client directly. | |
| 208 void SetNeedsRedrawRect(const gfx::Rect& damage_rect); | |
| 209 // TODO(danakj): Delete this. Subclasses should just call the client directly. | |
| 210 void ReclaimResources(const ReturnedResourceArray& resources); | |
| 211 | |
| 212 OutputSurfaceClient* client_ = nullptr; | 198 OutputSurfaceClient* client_ = nullptr; |
| 213 | 199 |
| 214 struct OutputSurface::Capabilities capabilities_; | 200 struct OutputSurface::Capabilities capabilities_; |
| 215 scoped_refptr<ContextProvider> context_provider_; | 201 scoped_refptr<ContextProvider> context_provider_; |
| 216 scoped_refptr<ContextProvider> worker_context_provider_; | 202 scoped_refptr<ContextProvider> worker_context_provider_; |
| 217 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; | 203 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; |
| 218 std::unique_ptr<SoftwareOutputDevice> software_device_; | 204 std::unique_ptr<SoftwareOutputDevice> software_device_; |
| 219 gfx::Size surface_size_; | 205 gfx::Size surface_size_; |
| 220 float device_scale_factor_ = -1; | 206 float device_scale_factor_ = -1; |
| 221 gfx::ColorSpace device_color_space_; | 207 gfx::ColorSpace device_color_space_; |
| 222 bool has_alpha_ = true; | 208 bool has_alpha_ = true; |
| 223 gfx::ColorSpace color_space_; | 209 gfx::ColorSpace color_space_; |
| 224 base::ThreadChecker client_thread_checker_; | 210 base::ThreadChecker client_thread_checker_; |
| 225 | 211 |
| 226 private: | 212 private: |
| 227 void DetachFromClientInternal(); | 213 void DetachFromClientInternal(); |
| 228 | 214 |
| 229 bool external_stencil_test_enabled_ = false; | |
| 230 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 215 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
| 231 | 216 |
| 232 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 217 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 233 }; | 218 }; |
| 234 | 219 |
| 235 } // namespace cc | 220 } // namespace cc |
| 236 | 221 |
| 237 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 222 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |