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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Constructor for GL-based compositing. | 56 // Constructor for GL-based compositing. |
57 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); | 57 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); |
58 // Constructor for software compositing. | 58 // Constructor for software compositing. |
59 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); | 59 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); |
60 // Constructor for Vulkan-based compositing. | 60 // Constructor for Vulkan-based compositing. |
61 explicit OutputSurface( | 61 explicit OutputSurface( |
62 scoped_refptr<VulkanContextProvider> vulkan_context_provider); | 62 scoped_refptr<VulkanContextProvider> vulkan_context_provider); |
63 | 63 |
64 virtual ~OutputSurface(); | 64 virtual ~OutputSurface(); |
65 | 65 |
66 // Called by the Display to initialize the OutputSurface. This also specifies | |
67 // the thread that the OutputSurface will be used on as tests create and then | |
68 // bind the class on different threads. | |
69 virtual bool BindToClient(OutputSurfaceClient* client); | |
70 | |
71 const Capabilities& capabilities() const { return capabilities_; } | 66 const Capabilities& capabilities() const { return capabilities_; } |
72 | 67 |
73 // Obtain the 3d context or the software device associated with this output | 68 // Obtain the 3d context or the software device associated with this output |
74 // surface. Either of these may return a null pointer, but not both. | 69 // surface. Either of these may return a null pointer, but not both. |
75 // In the event of a lost context, the entire output surface should be | 70 // In the event of a lost context, the entire output surface should be |
76 // recreated. | 71 // recreated. |
77 ContextProvider* context_provider() const { return context_provider_.get(); } | 72 ContextProvider* context_provider() const { return context_provider_.get(); } |
78 VulkanContextProvider* vulkan_context_provider() const { | 73 VulkanContextProvider* vulkan_context_provider() const { |
79 return vulkan_context_provider_.get(); | 74 return vulkan_context_provider_.get(); |
80 } | 75 } |
81 SoftwareOutputDevice* software_device() const { | 76 SoftwareOutputDevice* software_device() const { |
82 return software_device_.get(); | 77 return software_device_.get(); |
83 } | 78 } |
84 | 79 |
| 80 virtual void BindToClient(OutputSurfaceClient* client) = 0; |
| 81 |
85 virtual void EnsureBackbuffer() = 0; | 82 virtual void EnsureBackbuffer() = 0; |
86 virtual void DiscardBackbuffer() = 0; | 83 virtual void DiscardBackbuffer() = 0; |
87 | 84 |
88 // Bind the default framebuffer for drawing to, only valid for GL backed | 85 // Bind the default framebuffer for drawing to, only valid for GL backed |
89 // OutputSurfaces. | 86 // OutputSurfaces. |
90 virtual void BindFramebuffer() = 0; | 87 virtual void BindFramebuffer() = 0; |
91 | 88 |
92 // Get the class capable of informing cc of hardware overlay capability. | 89 // Get the class capable of informing cc of hardware overlay capability. |
93 virtual OverlayCandidateValidator* GetOverlayCandidateValidator() const = 0; | 90 virtual OverlayCandidateValidator* GetOverlayCandidateValidator() const = 0; |
94 | 91 |
(...skipping 17 matching lines...) Expand all Loading... |
112 // Gives the GL internal format that should be used for calling CopyTexImage2D | 109 // Gives the GL internal format that should be used for calling CopyTexImage2D |
113 // when the framebuffer is bound via BindFramebuffer(). | 110 // when the framebuffer is bound via BindFramebuffer(). |
114 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; | 111 virtual uint32_t GetFramebufferCopyTextureFormat() = 0; |
115 | 112 |
116 // Swaps the current backbuffer to the screen. For successful swaps, the | 113 // Swaps the current backbuffer to the screen. For successful swaps, the |
117 // implementation must call OutputSurfaceClient::DidReceiveSwapBuffersAck() | 114 // implementation must call OutputSurfaceClient::DidReceiveSwapBuffersAck() |
118 // after returning from this method in order to unblock the next frame. | 115 // after returning from this method in order to unblock the next frame. |
119 virtual void SwapBuffers(OutputSurfaceFrame frame) = 0; | 116 virtual void SwapBuffers(OutputSurfaceFrame frame) = 0; |
120 | 117 |
121 protected: | 118 protected: |
122 // Used internally for the context provider to inform the client about loss, | |
123 // and can be overridden to change behaviour instead of informing the client. | |
124 virtual void DidLoseOutputSurface(); | |
125 | |
126 OutputSurfaceClient* client_ = nullptr; | |
127 | |
128 struct OutputSurface::Capabilities capabilities_; | 119 struct OutputSurface::Capabilities capabilities_; |
129 scoped_refptr<ContextProvider> context_provider_; | 120 scoped_refptr<ContextProvider> context_provider_; |
130 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; | 121 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; |
131 std::unique_ptr<SoftwareOutputDevice> software_device_; | 122 std::unique_ptr<SoftwareOutputDevice> software_device_; |
132 base::ThreadChecker thread_checker_; | |
133 | 123 |
134 private: | 124 private: |
135 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 125 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
136 }; | 126 }; |
137 | 127 |
138 } // namespace cc | 128 } // namespace cc |
139 | 129 |
140 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 130 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |