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 "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Texture provide an abstraction over the external texture that can be passed | 94 // Texture provide an abstraction over the external texture that can be passed |
95 // to a layer. | 95 // to a layer. |
96 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 96 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
97 public: | 97 public: |
98 Texture(bool flipped, const gfx::Size& size); | 98 Texture(bool flipped, const gfx::Size& size); |
99 | 99 |
100 unsigned int texture_id() const { return texture_id_; } | 100 unsigned int texture_id() const { return texture_id_; } |
101 void set_texture_id(unsigned int id) { texture_id_ = id; } | 101 void set_texture_id(unsigned int id) { texture_id_ = id; } |
102 bool flipped() const { return flipped_; } | 102 bool flipped() const { return flipped_; } |
103 gfx::Size size() const { return size_; } | 103 gfx::Size size() const { return size_; } |
| 104 virtual WebKit::WebGraphicsContext3D* HostContext3D() = 0; |
104 | 105 |
105 protected: | 106 protected: |
106 virtual ~Texture(); | 107 virtual ~Texture(); |
107 | 108 |
108 private: | 109 private: |
109 friend class base::RefCounted<Texture>; | 110 friend class base::RefCounted<Texture>; |
110 | 111 |
111 unsigned int texture_id_; | 112 unsigned int texture_id_; |
112 bool flipped_; | 113 bool flipped_; |
113 gfx::Size size_; // in pixel | 114 gfx::Size size_; // in pixel |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Compositor does not own observers. It is the responsibility of the | 184 // Compositor does not own observers. It is the responsibility of the |
184 // observer to remove itself when it is done observing. | 185 // observer to remove itself when it is done observing. |
185 void AddObserver(CompositorObserver* observer); | 186 void AddObserver(CompositorObserver* observer); |
186 void RemoveObserver(CompositorObserver* observer); | 187 void RemoveObserver(CompositorObserver* observer); |
187 bool HasObserver(CompositorObserver* observer); | 188 bool HasObserver(CompositorObserver* observer); |
188 | 189 |
189 // Returns whether a draw is pending, that is, if we're between the Draw call | 190 // Returns whether a draw is pending, that is, if we're between the Draw call |
190 // and the OnCompositingEnded. | 191 // and the OnCompositingEnded. |
191 bool DrawPending() const { return swap_posted_; } | 192 bool DrawPending() const { return swap_posted_; } |
192 | 193 |
| 194 // Returns whether the drawing is issued from a separate thread |
| 195 // (i.e. |Compositor::Initialize(true)| was called). |
| 196 bool IsThreaded() const; |
| 197 |
193 // Internal functions, called back by command-buffer contexts on swap buffer | 198 // Internal functions, called back by command-buffer contexts on swap buffer |
194 // events. | 199 // events. |
195 | 200 |
196 // Signals swap has been posted. | 201 // Signals swap has been posted. |
197 void OnSwapBuffersPosted(); | 202 void OnSwapBuffersPosted(); |
198 | 203 |
199 // Signals swap has completed. | 204 // Signals swap has completed. |
200 void OnSwapBuffersComplete(); | 205 void OnSwapBuffersComplete(); |
201 | 206 |
202 // Signals swap has aborted (e.g. lost context). | 207 // Signals swap has aborted (e.g. lost context). |
203 void OnSwapBuffersAborted(); | 208 void OnSwapBuffersAborted(); |
204 | 209 |
205 // WebLayerTreeViewClient implementation. | 210 // WebLayerTreeViewClient implementation. |
206 virtual void updateAnimations(double frameBeginTime); | 211 virtual void updateAnimations(double frameBeginTime); |
207 virtual void layout(); | 212 virtual void layout(); |
208 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 213 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta, |
209 float scaleFactor); | 214 float scaleFactor); |
210 virtual WebKit::WebGraphicsContext3D* createContext3D(); | 215 virtual WebKit::WebGraphicsContext3D* createContext3D(); |
211 virtual void didRebindGraphicsContext(bool success); | 216 virtual void didRebindGraphicsContext(bool success); |
| 217 virtual void didCommit(); |
212 virtual void didCommitAndDrawFrame(); | 218 virtual void didCommitAndDrawFrame(); |
213 virtual void didCompleteSwapBuffers(); | 219 virtual void didCompleteSwapBuffers(); |
214 virtual void scheduleComposite(); | 220 virtual void scheduleComposite(); |
215 | 221 |
216 int last_started_frame() { return last_started_frame_; } | 222 int last_started_frame() { return last_started_frame_; } |
217 int last_ended_frame() { return last_ended_frame_; } | 223 int last_ended_frame() { return last_ended_frame_; } |
218 | 224 |
219 private: | 225 private: |
220 friend class base::RefCounted<Compositor>; | 226 friend class base::RefCounted<Compositor>; |
221 | 227 |
(...skipping 22 matching lines...) Expand all Loading... |
244 bool swap_posted_; | 250 bool swap_posted_; |
245 | 251 |
246 // The device scale factor of the monitor that this compositor is compositing | 252 // The device scale factor of the monitor that this compositor is compositing |
247 // layers on. | 253 // layers on. |
248 float device_scale_factor_; | 254 float device_scale_factor_; |
249 | 255 |
250 int last_started_frame_; | 256 int last_started_frame_; |
251 int last_ended_frame_; | 257 int last_ended_frame_; |
252 | 258 |
253 bool disable_schedule_composite_; | 259 bool disable_schedule_composite_; |
| 260 |
| 261 DISALLOW_COPY_AND_ASSIGN(Compositor); |
254 }; | 262 }; |
255 | 263 |
256 } // namespace ui | 264 } // namespace ui |
257 | 265 |
258 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 266 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |