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 CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ |
6 #define CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "cc/output/begin_frame_args.h" | 16 #include "cc/output/begin_frame_args.h" |
17 #include "cc/output/output_surface.h" | 17 #include "cc/output/output_surface.h" |
| 18 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" |
18 #include "ipc/ipc_sync_message_filter.h" | 19 #include "ipc/ipc_sync_message_filter.h" |
19 | 20 |
20 namespace base { | |
21 class TaskRunner; | |
22 } | |
23 | |
24 namespace IPC { | 21 namespace IPC { |
25 class ForwardingMessageFilter; | |
26 class Message; | 22 class Message; |
27 } | 23 } |
28 | 24 |
29 namespace cc { | 25 namespace cc { |
30 class CompositorFrame; | 26 class CompositorFrame; |
31 class CompositorFrameAck; | 27 class CompositorFrameAck; |
32 class GLFrameData; | 28 class GLFrameData; |
33 class SoftwareFrameData; | 29 class SoftwareFrameData; |
34 } | 30 } |
35 | 31 |
36 namespace content { | 32 namespace content { |
37 class ContextProviderCommandBuffer; | 33 class ContextProviderCommandBuffer; |
38 class FrameSwapMessageQueue; | 34 class FrameSwapMessageQueue; |
39 | 35 |
40 // This class can be created only on the main thread, but then becomes pinned | 36 // This class can be created only on the main thread, but then becomes pinned |
41 // to a fixed thread when bindToClient is called. | 37 // to a fixed thread when bindToClient is called. |
42 class CompositorOutputSurface | 38 class CompositorOutputSurface |
43 : NON_EXPORTED_BASE(public cc::OutputSurface), | 39 : NON_EXPORTED_BASE(public cc::OutputSurface), |
44 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 40 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
45 public: | 41 public: |
46 static IPC::ForwardingMessageFilter* CreateFilter( | |
47 base::TaskRunner* target_task_runner); | |
48 | |
49 CompositorOutputSurface( | 42 CompositorOutputSurface( |
50 int32 routing_id, | 43 int32 routing_id, |
51 uint32 output_surface_id, | 44 uint32 output_surface_id, |
52 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 45 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
53 scoped_ptr<cc::SoftwareOutputDevice> software, | 46 scoped_ptr<cc::SoftwareOutputDevice> software, |
54 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue, | 47 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue, |
55 bool use_swap_compositor_frame_message); | 48 bool use_swap_compositor_frame_message); |
56 ~CompositorOutputSurface() override; | 49 ~CompositorOutputSurface() override; |
57 | 50 |
58 // cc::OutputSurface implementation. | 51 // cc::OutputSurface implementation. |
59 bool BindToClient(cc::OutputSurfaceClient* client) override; | 52 bool BindToClient(cc::OutputSurfaceClient* client) override; |
60 void SwapBuffers(cc::CompositorFrame* frame) override; | 53 void SwapBuffers(cc::CompositorFrame* frame) override; |
61 #if defined(OS_ANDROID) | |
62 virtual void SetNeedsBeginFrame(bool enable) override; | |
63 #endif | |
64 | 54 |
65 // TODO(epenner): This seems out of place here and would be a better fit | 55 // TODO(epenner): This seems out of place here and would be a better fit |
66 // int CompositorThread after it is fully refactored (http://crbug/170828) | 56 // int CompositorThread after it is fully refactored (http://crbug/170828) |
67 void UpdateSmoothnessTakesPriority(bool prefer_smoothness) override; | 57 void UpdateSmoothnessTakesPriority(bool prefer_smoothness) override; |
68 | 58 |
69 protected: | 59 protected: |
70 void ShortcutSwapAck(uint32 output_surface_id, | 60 void ShortcutSwapAck(uint32 output_surface_id, |
71 scoped_ptr<cc::GLFrameData> gl_frame_data, | 61 scoped_ptr<cc::GLFrameData> gl_frame_data, |
72 scoped_ptr<cc::SoftwareFrameData> software_frame_data); | 62 scoped_ptr<cc::SoftwareFrameData> software_frame_data); |
73 virtual void OnSwapAck(uint32 output_surface_id, | 63 virtual void OnSwapAck(uint32 output_surface_id, |
(...skipping 19 matching lines...) Expand all Loading... |
93 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>; | 83 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>; |
94 ~CompositorOutputSurfaceProxy() {} | 84 ~CompositorOutputSurfaceProxy() {} |
95 CompositorOutputSurface* output_surface_; | 85 CompositorOutputSurface* output_surface_; |
96 | 86 |
97 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy); | 87 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy); |
98 }; | 88 }; |
99 | 89 |
100 void OnMessageReceived(const IPC::Message& message); | 90 void OnMessageReceived(const IPC::Message& message); |
101 void OnUpdateVSyncParametersFromBrowser(base::TimeTicks timebase, | 91 void OnUpdateVSyncParametersFromBrowser(base::TimeTicks timebase, |
102 base::TimeDelta interval); | 92 base::TimeDelta interval); |
103 #if defined(OS_ANDROID) | |
104 void OnBeginFrame(const cc::BeginFrameArgs& args); | |
105 #endif | |
106 bool Send(IPC::Message* message); | 93 bool Send(IPC::Message* message); |
107 | 94 |
108 bool use_swap_compositor_frame_message_; | 95 bool use_swap_compositor_frame_message_; |
109 | 96 |
110 scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_; | 97 scoped_refptr<CompositorForwardingMessageFilter> output_surface_filter_; |
| 98 CompositorForwardingMessageFilter::Handler output_surface_filter_handler_; |
111 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; | 99 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; |
112 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | 100 scoped_refptr<IPC::SyncMessageFilter> message_sender_; |
113 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; | 101 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
114 int routing_id_; | 102 int routing_id_; |
115 bool prefers_smoothness_; | 103 bool prefers_smoothness_; |
116 base::PlatformThreadHandle main_thread_handle_; | 104 base::PlatformThreadHandle main_thread_handle_; |
117 | 105 |
118 // TODO(danakj): Remove this when crbug.com/311404 | 106 // TODO(danakj): Remove this when crbug.com/311404 |
119 bool layout_test_mode_; | 107 bool layout_test_mode_; |
120 scoped_ptr<cc::CompositorFrameAck> layout_test_previous_frame_ack_; | 108 scoped_ptr<cc::CompositorFrameAck> layout_test_previous_frame_ack_; |
121 base::WeakPtrFactory<CompositorOutputSurface> weak_ptrs_; | 109 base::WeakPtrFactory<CompositorOutputSurface> weak_ptrs_; |
122 }; | 110 }; |
123 | 111 |
124 } // namespace content | 112 } // namespace content |
125 | 113 |
126 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 114 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ |
OLD | NEW |