OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
6 #define CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ | 6 #define CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 #include "content/common/content_export.h" |
12 | 13 |
13 namespace base { class MessageLoopProxy; } | 14 namespace base { class MessageLoopProxy; } |
14 | 15 |
| 16 namespace cc { |
| 17 class SoftwareOutputDevice; |
| 18 } |
| 19 |
15 namespace ui { class Compositor; } | 20 namespace ui { class Compositor; } |
16 | 21 |
17 namespace content { | 22 namespace content { |
18 class ContextProviderCommandBuffer; | 23 class ContextProviderCommandBuffer; |
19 class ReflectorImpl; | 24 class ReflectorImpl; |
20 class WebGraphicsContext3DCommandBufferImpl; | 25 class WebGraphicsContext3DCommandBufferImpl; |
21 | 26 |
22 // Adapts a WebGraphicsContext3DCommandBufferImpl into a | 27 class CONTENT_EXPORT BrowserCompositorOutputSurface |
23 // cc::OutputSurface that also handles vsync parameter updates | |
24 // arriving from the GPU process. | |
25 class BrowserCompositorOutputSurface | |
26 : public cc::OutputSurface, | 28 : public cc::OutputSurface, |
27 public base::NonThreadSafe { | 29 public base::NonThreadSafe { |
28 public: | 30 public: |
| 31 virtual ~BrowserCompositorOutputSurface(); |
| 32 |
| 33 // cc::OutputSurface implementation. |
| 34 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE; |
| 35 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE; |
| 36 |
| 37 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 38 base::TimeDelta interval); |
| 39 |
| 40 void SetReflector(ReflectorImpl* reflector); |
| 41 |
| 42 protected: |
| 43 // Constructor used by the accelerated implementation. |
29 BrowserCompositorOutputSurface( | 44 BrowserCompositorOutputSurface( |
30 const scoped_refptr<ContextProviderCommandBuffer>& context, | 45 const scoped_refptr<ContextProviderCommandBuffer>& context, |
31 int surface_id, | 46 int surface_id, |
32 IDMap<BrowserCompositorOutputSurface>* output_surface_map, | 47 IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
33 base::MessageLoopProxy* compositor_message_loop, | 48 base::MessageLoopProxy* compositor_message_loop, |
34 base::WeakPtr<ui::Compositor> compositor); | 49 base::WeakPtr<ui::Compositor> compositor); |
35 | 50 |
36 virtual ~BrowserCompositorOutputSurface(); | 51 // Constructor used by the software implementation. |
| 52 BrowserCompositorOutputSurface( |
| 53 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
| 54 int surface_id, |
| 55 IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
| 56 base::MessageLoopProxy* compositor_message_loop, |
| 57 base::WeakPtr<ui::Compositor> compositor); |
37 | 58 |
38 // cc::OutputSurface implementation. | |
39 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE; | |
40 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE; | |
41 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; | |
42 | |
43 void OnUpdateVSyncParameters(base::TimeTicks timebase, | |
44 base::TimeDelta interval); | |
45 | |
46 void SetReflector(ReflectorImpl* reflector); | |
47 | |
48 private: | |
49 int surface_id_; | 59 int surface_id_; |
50 IDMap<BrowserCompositorOutputSurface>* output_surface_map_; | 60 IDMap<BrowserCompositorOutputSurface>* output_surface_map_; |
51 | 61 |
52 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_; | 62 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_; |
53 base::WeakPtr<ui::Compositor> compositor_; | 63 base::WeakPtr<ui::Compositor> compositor_; |
54 scoped_refptr<ReflectorImpl> reflector_; | 64 scoped_refptr<ReflectorImpl> reflector_; |
| 65 |
| 66 private: |
| 67 void Initialize(); |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurface); |
55 }; | 70 }; |
56 | 71 |
57 } // namespace content | 72 } // namespace content |
58 | 73 |
59 #endif // CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ | 74 #endif // CONTENT_BROWSER_AURA_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
OLD | NEW |