OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 UI_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_ |
6 #define UI_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_COMPOSITOR_COMPOSITOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 SharedMainThreadContextProvider() = 0; | 96 SharedMainThreadContextProvider() = 0; |
97 | 97 |
98 // Destroys per-compositor data. | 98 // Destroys per-compositor data. |
99 virtual void RemoveCompositor(Compositor* compositor) = 0; | 99 virtual void RemoveCompositor(Compositor* compositor) = 0; |
100 | 100 |
101 // When true, the factory uses test contexts that do not do real GL | 101 // When true, the factory uses test contexts that do not do real GL |
102 // operations. | 102 // operations. |
103 virtual bool DoesCreateTestContexts() = 0; | 103 virtual bool DoesCreateTestContexts() = 0; |
104 }; | 104 }; |
105 | 105 |
106 // Texture provide an abstraction over the external texture that can be passed | |
107 // to a layer. | |
108 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | |
109 public: | |
110 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | |
111 | |
112 bool flipped() const { return flipped_; } | |
113 gfx::Size size() const { return size_; } | |
114 float device_scale_factor() const { return device_scale_factor_; } | |
115 | |
116 virtual unsigned int PrepareTexture() = 0; | |
117 | |
118 // Replaces the texture with the texture from the specified mailbox. | |
119 virtual void Consume(const gpu::Mailbox& mailbox, | |
120 const gfx::Size& new_size) {} | |
121 | |
122 // Moves the texture into the mailbox and returns the mailbox name. | |
123 // The texture must have been previously consumed from a mailbox. | |
124 virtual gpu::Mailbox Produce(); | |
125 | |
126 protected: | |
127 virtual ~Texture(); | |
128 gfx::Size size_; // in pixel | |
129 | |
130 private: | |
131 friend class base::RefCounted<Texture>; | |
132 | |
133 bool flipped_; | |
134 float device_scale_factor_; | |
135 | |
136 DISALLOW_COPY_AND_ASSIGN(Texture); | |
137 }; | |
138 | |
139 // This class represents a lock on the compositor, that can be used to prevent | 106 // This class represents a lock on the compositor, that can be used to prevent |
140 // commits to the compositor tree while we're waiting for an asynchronous | 107 // commits to the compositor tree while we're waiting for an asynchronous |
141 // event. The typical use case is when waiting for a renderer to produce a frame | 108 // event. The typical use case is when waiting for a renderer to produce a frame |
142 // at the right size. The caller keeps a reference on this object, and drops the | 109 // at the right size. The caller keeps a reference on this object, and drops the |
143 // reference once it desires to release the lock. | 110 // reference once it desires to release the lock. |
144 // Note however that the lock is cancelled after a short timeout to ensure | 111 // Note however that the lock is cancelled after a short timeout to ensure |
145 // responsiveness of the UI, so the compositor tree should be kept in a | 112 // responsiveness of the UI, so the compositor tree should be kept in a |
146 // "reasonable" state while the lock is held. | 113 // "reasonable" state while the lock is held. |
147 // Don't instantiate this class directly, use Compositor::GetCompositorLock. | 114 // Don't instantiate this class directly, use Compositor::GetCompositorLock. |
148 class COMPOSITOR_EXPORT CompositorLock | 115 class COMPOSITOR_EXPORT CompositorLock |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 SwapState swap_state_; | 300 SwapState swap_state_; |
334 | 301 |
335 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 302 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
336 | 303 |
337 DISALLOW_COPY_AND_ASSIGN(Compositor); | 304 DISALLOW_COPY_AND_ASSIGN(Compositor); |
338 }; | 305 }; |
339 | 306 |
340 } // namespace ui | 307 } // namespace ui |
341 | 308 |
342 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 309 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |