OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
13 #include "cc/output/managed_memory_policy.h" | 15 #include "cc/output/managed_memory_policy.h" |
14 #include "cc/output/output_surface.h" | 16 #include "cc/output/output_surface.h" |
15 #include "content/public/browser/android/synchronous_compositor.h" | 17 #include "content/public/browser/android/synchronous_compositor.h" |
| 18 #include "ipc/ipc_message.h" |
16 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
17 | 20 |
18 namespace cc { | 21 namespace cc { |
19 class ContextProvider; | 22 class ContextProvider; |
20 class CompositorFrameMetadata; | 23 class CompositorFrameMetadata; |
21 } | 24 } |
22 | 25 |
| 26 namespace IPC { |
| 27 class Message; |
| 28 } |
| 29 |
23 namespace content { | 30 namespace content { |
24 | 31 |
| 32 class FrameSwapMessageQueue; |
25 class SynchronousCompositorClient; | 33 class SynchronousCompositorClient; |
26 class SynchronousCompositorOutputSurface; | 34 class SynchronousCompositorOutputSurface; |
27 class WebGraphicsContext3DCommandBufferImpl; | 35 class WebGraphicsContext3DCommandBufferImpl; |
28 | 36 |
29 class SynchronousCompositorOutputSurfaceDelegate { | 37 class SynchronousCompositorOutputSurfaceDelegate { |
30 public: | 38 public: |
31 virtual void DidBindOutputSurface( | 39 virtual void DidBindOutputSurface( |
32 SynchronousCompositorOutputSurface* output_surface) = 0; | 40 SynchronousCompositorOutputSurface* output_surface) = 0; |
33 virtual void DidDestroySynchronousOutputSurface( | 41 virtual void DidDestroySynchronousOutputSurface( |
34 SynchronousCompositorOutputSurface* output_surface) = 0; | 42 SynchronousCompositorOutputSurface* output_surface) = 0; |
35 virtual void SetContinuousInvalidate(bool enable) = 0; | 43 virtual void SetContinuousInvalidate(bool enable) = 0; |
36 virtual void DidActivatePendingTree() = 0; | 44 virtual void DidActivatePendingTree() = 0; |
37 | 45 |
38 protected: | 46 protected: |
39 SynchronousCompositorOutputSurfaceDelegate() {} | 47 SynchronousCompositorOutputSurfaceDelegate() {} |
40 virtual ~SynchronousCompositorOutputSurfaceDelegate() {} | 48 virtual ~SynchronousCompositorOutputSurfaceDelegate() {} |
41 }; | 49 }; |
42 | 50 |
43 // Specialization of the output surface that adapts it to implement the | 51 // Specialization of the output surface that adapts it to implement the |
44 // content::SynchronousCompositor public API. This class effects an "inversion | 52 // content::SynchronousCompositor public API. This class effects an "inversion |
45 // of control" - enabling drawing to be orchestrated by the embedding | 53 // of control" - enabling drawing to be orchestrated by the embedding |
46 // layer, instead of driven by the compositor internals - hence it holds two | 54 // layer, instead of driven by the compositor internals - hence it holds two |
47 // 'client' pointers (|client_| in the OutputSurface baseclass and | 55 // 'client' pointers (|client_| in the OutputSurface baseclass and |
48 // GetDelegate()) which represent the consumers of the two roles in plays. | 56 // GetDelegate()) which represent the consumers of the two roles in plays. |
49 // This class can be created only on the main thread, but then becomes pinned | 57 // This class can be created only on the main thread, but then becomes pinned |
50 // to a fixed thread when BindToClient is called. | 58 // to a fixed thread when BindToClient is called. |
51 class SynchronousCompositorOutputSurface | 59 class SynchronousCompositorOutputSurface |
52 : NON_EXPORTED_BASE(public cc::OutputSurface) { | 60 : NON_EXPORTED_BASE(public cc::OutputSurface) { |
53 public: | 61 public: |
54 explicit SynchronousCompositorOutputSurface(int routing_id); | 62 explicit SynchronousCompositorOutputSurface( |
| 63 int routing_id, |
| 64 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); |
55 virtual ~SynchronousCompositorOutputSurface(); | 65 virtual ~SynchronousCompositorOutputSurface(); |
56 | 66 |
57 // OutputSurface. | 67 // OutputSurface. |
58 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; | 68 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; |
59 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; | 69 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; |
60 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE; | 70 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE; |
61 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; | 71 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; |
62 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; | 72 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; |
63 | 73 |
64 // Partial SynchronousCompositor API implementation. | 74 // Partial SynchronousCompositor API implementation. |
65 bool InitializeHwDraw( | 75 bool InitializeHwDraw( |
66 scoped_refptr<cc::ContextProvider> onscreen_context_provider); | 76 scoped_refptr<cc::ContextProvider> onscreen_context_provider); |
67 void ReleaseHwDraw(); | 77 void ReleaseHwDraw(); |
68 scoped_ptr<cc::CompositorFrame> DemandDrawHw(gfx::Size surface_size, | 78 scoped_ptr<cc::CompositorFrame> DemandDrawHw(gfx::Size surface_size, |
69 const gfx::Transform& transform, | 79 const gfx::Transform& transform, |
70 gfx::Rect viewport, | 80 gfx::Rect viewport, |
71 gfx::Rect clip); | 81 gfx::Rect clip); |
72 void ReturnResources(const cc::CompositorFrameAck& frame_ack); | 82 void ReturnResources(const cc::CompositorFrameAck& frame_ack); |
73 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas); | 83 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas); |
74 void SetMemoryPolicy(const SynchronousCompositorMemoryPolicy& policy); | 84 void SetMemoryPolicy(const SynchronousCompositorMemoryPolicy& policy); |
| 85 void GetMessagesToDeliver(ScopedVector<IPC::Message>* messages); |
75 | 86 |
76 private: | 87 private: |
77 class SoftwareDevice; | 88 class SoftwareDevice; |
78 friend class SoftwareDevice; | 89 friend class SoftwareDevice; |
79 | 90 |
80 void InvokeComposite(const gfx::Transform& transform, | 91 void InvokeComposite(const gfx::Transform& transform, |
81 gfx::Rect viewport, | 92 gfx::Rect viewport, |
82 gfx::Rect clip, | 93 gfx::Rect clip, |
83 bool valid_for_tile_management); | 94 bool valid_for_tile_management); |
84 bool CalledOnValidThread() const; | 95 bool CalledOnValidThread() const; |
85 SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); | 96 SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); |
86 | 97 |
87 int routing_id_; | 98 int routing_id_; |
88 bool needs_begin_frame_; | 99 bool needs_begin_frame_; |
89 bool invoking_composite_; | 100 bool invoking_composite_; |
90 | 101 |
91 gfx::Transform cached_hw_transform_; | 102 gfx::Transform cached_hw_transform_; |
92 gfx::Rect cached_hw_viewport_; | 103 gfx::Rect cached_hw_viewport_; |
93 gfx::Rect cached_hw_clip_; | 104 gfx::Rect cached_hw_clip_; |
94 | 105 |
95 // Only valid (non-NULL) during a DemandDrawSw() call. | 106 // Only valid (non-NULL) during a DemandDrawSw() call. |
96 SkCanvas* current_sw_canvas_; | 107 SkCanvas* current_sw_canvas_; |
97 | 108 |
98 cc::ManagedMemoryPolicy memory_policy_; | 109 cc::ManagedMemoryPolicy memory_policy_; |
99 | 110 |
100 cc::OutputSurfaceClient* output_surface_client_; | 111 cc::OutputSurfaceClient* output_surface_client_; |
101 scoped_ptr<cc::CompositorFrame> frame_holder_; | 112 scoped_ptr<cc::CompositorFrame> frame_holder_; |
102 | 113 |
| 114 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
| 115 |
103 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); | 116 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); |
104 }; | 117 }; |
105 | 118 |
106 } // namespace content | 119 } // namespace content |
107 | 120 |
108 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ | 121 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ |
OLD | NEW |