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 19 matching lines...) Expand all Loading... |
30 class Size; | 30 class Size; |
31 class Transform; | 31 class Transform; |
32 } | 32 } |
33 | 33 |
34 namespace cc { | 34 namespace cc { |
35 | 35 |
36 struct ManagedMemoryPolicy; | 36 struct ManagedMemoryPolicy; |
37 class OutputSurfaceClient; | 37 class OutputSurfaceClient; |
38 class OutputSurfaceFrame; | 38 class OutputSurfaceFrame; |
39 | 39 |
40 // Represents the output surface for a compositor. The compositor owns | 40 // This class represents a platform-independent API for presenting |
41 // and manages its destruction. Its lifetime is: | 41 // buffers to display via GPU or software compositing. Implementations |
42 // 1. Created on the main thread by the LayerTreeHost through its client. | 42 // can provide platform-specific behaviour. |
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. | |
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. | |
47 class CC_EXPORT OutputSurface { | 43 class CC_EXPORT OutputSurface { |
48 public: | 44 public: |
49 struct Capabilities { | 45 struct Capabilities { |
50 Capabilities() = default; | 46 Capabilities() = default; |
51 | 47 |
52 int max_frames_pending = 1; | 48 int max_frames_pending = 1; |
53 // Whether this output surface renders to the default OpenGL zero | 49 // Whether this output surface renders to the default OpenGL zero |
54 // framebuffer or to an offscreen framebuffer. | 50 // framebuffer or to an offscreen framebuffer. |
55 bool uses_default_gl_framebuffer = true; | 51 bool uses_default_gl_framebuffer = true; |
56 // Whether this OutputSurface is flipped or not. | 52 // Whether this OutputSurface is flipped or not. |
57 bool flipped_output_surface = false; | 53 bool flipped_output_surface = false; |
58 }; | 54 }; |
59 | 55 |
60 // Constructor for GL-based compositing. | 56 // Constructor for GL-based compositing. |
61 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); | 57 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); |
62 // Constructor for software compositing. | 58 // Constructor for software compositing. |
63 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); | 59 explicit OutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device); |
64 // Constructor for Vulkan-based compositing. | 60 // Constructor for Vulkan-based compositing. |
65 explicit OutputSurface( | 61 explicit OutputSurface( |
66 scoped_refptr<VulkanContextProvider> vulkan_context_provider); | 62 scoped_refptr<VulkanContextProvider> vulkan_context_provider); |
67 | 63 |
68 virtual ~OutputSurface(); | 64 virtual ~OutputSurface(); |
69 | 65 |
70 // Called by the compositor on the compositor thread. This is a place where | 66 // Called by the Display to initialize the OutputSurface. This also specifies |
71 // thread-specific data for the output surface can be initialized. The | 67 // the thread that the OutputSurface will be used on as tests create and then |
72 // OutputSurface will be destroyed on the same thread that BoundToClient is | 68 // bind the class on different threads. |
73 // called on. | |
74 virtual bool BindToClient(OutputSurfaceClient* client); | 69 virtual bool BindToClient(OutputSurfaceClient* client); |
75 | 70 |
76 const Capabilities& capabilities() const { return capabilities_; } | 71 const Capabilities& capabilities() const { return capabilities_; } |
77 | 72 |
78 // Obtain the 3d context or the software device associated with this output | 73 // Obtain the 3d context or the software device associated with this output |
79 // surface. Either of these may return a null pointer, but not both. | 74 // surface. Either of these may return a null pointer, but not both. |
80 // In the event of a lost context, the entire output surface should be | 75 // In the event of a lost context, the entire output surface should be |
81 // recreated. | 76 // recreated. |
82 ContextProvider* context_provider() const { return context_provider_.get(); } | 77 ContextProvider* context_provider() const { return context_provider_.get(); } |
83 VulkanContextProvider* vulkan_context_provider() const { | 78 VulkanContextProvider* vulkan_context_provider() const { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 std::unique_ptr<SoftwareOutputDevice> software_device_; | 131 std::unique_ptr<SoftwareOutputDevice> software_device_; |
137 base::ThreadChecker thread_checker_; | 132 base::ThreadChecker thread_checker_; |
138 | 133 |
139 private: | 134 private: |
140 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 135 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
141 }; | 136 }; |
142 | 137 |
143 } // namespace cc | 138 } // namespace cc |
144 | 139 |
145 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 140 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |