Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Side by Side Diff: content/renderer/gpu/renderer_compositor_frame_sink.h

Issue 2774373002: Use MojoCompositorFrameSink in RendererCompositorFrameSink (Closed)
Patch Set: Rebased, dedup IPC Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_RENDERER_COMPOSITOR_FRAME_SINK_H_ 5 #ifndef CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_
6 #define CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ 6 #define CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "cc/input/selection.h" 20 #include "cc/input/selection.h"
21 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
21 #include "cc/output/begin_frame_args.h" 22 #include "cc/output/begin_frame_args.h"
22 #include "cc/output/compositor_frame_sink.h" 23 #include "cc/output/compositor_frame_sink.h"
23 #include "cc/scheduler/begin_frame_source.h" 24 #include "cc/scheduler/begin_frame_source.h"
24 #include "cc/surfaces/local_surface_id.h" 25 #include "cc/surfaces/local_surface_id.h"
25 #include "cc/surfaces/local_surface_id_allocator.h" 26 #include "cc/surfaces/local_surface_id_allocator.h"
26 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" 27 #include "content/renderer/gpu/compositor_forwarding_message_filter.h"
27 #include "ipc/ipc_sync_message_filter.h" 28 #include "ipc/ipc_sync_message_filter.h"
29 #include "mojo/public/cpp/bindings/binding.h"
28 #include "ui/gfx/selection_bound.h" 30 #include "ui/gfx/selection_bound.h"
29 31
30 namespace IPC { 32 namespace IPC {
31 class Message; 33 class Message;
32 } 34 }
33 35
34 namespace cc { 36 namespace cc {
35 class CompositorFrame; 37 class CompositorFrame;
36 class ContextProvider; 38 class ContextProvider;
37 } 39 }
38 40
39 namespace content { 41 namespace content {
40 class FrameSwapMessageQueue; 42 class FrameSwapMessageQueue;
41 43
42 // This class can be created only on the main thread, but then becomes pinned 44 // This class can be created only on the main thread, but then becomes pinned
43 // to a fixed thread when BindToClient is called. 45 // to a fixed thread when BindToClient is called.
44 class RendererCompositorFrameSink 46 class RendererCompositorFrameSink
45 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), 47 : NON_EXPORTED_BASE(public cc::CompositorFrameSink),
46 NON_EXPORTED_BASE(public base::NonThreadSafe), 48 NON_EXPORTED_BASE(public base::NonThreadSafe),
49 NON_EXPORTED_BASE(public cc::mojom::MojoCompositorFrameSinkClient),
47 public cc::ExternalBeginFrameSourceClient { 50 public cc::ExternalBeginFrameSourceClient {
48 public: 51 public:
49 RendererCompositorFrameSink( 52 RendererCompositorFrameSink(
50 int32_t routing_id, 53 int32_t routing_id,
51 uint32_t compositor_frame_sink_id,
52 std::unique_ptr<cc::SyntheticBeginFrameSource> 54 std::unique_ptr<cc::SyntheticBeginFrameSource>
53 synthetic_begin_frame_source, 55 synthetic_begin_frame_source,
54 scoped_refptr<cc::ContextProvider> context_provider, 56 scoped_refptr<cc::ContextProvider> context_provider,
55 scoped_refptr<cc::ContextProvider> worker_context_provider, 57 scoped_refptr<cc::ContextProvider> worker_context_provider,
56 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 58 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
57 cc::SharedBitmapManager* shared_bitmap_manager, 59 cc::SharedBitmapManager* shared_bitmap_manager,
58 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); 60 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue);
59 RendererCompositorFrameSink( 61 RendererCompositorFrameSink(
60 int32_t routing_id, 62 int32_t routing_id,
61 uint32_t compositor_frame_sink_id,
62 std::unique_ptr<cc::SyntheticBeginFrameSource> 63 std::unique_ptr<cc::SyntheticBeginFrameSource>
63 synthetic_begin_frame_source, 64 synthetic_begin_frame_source,
64 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 65 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
65 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); 66 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue);
66 ~RendererCompositorFrameSink() override; 67 ~RendererCompositorFrameSink() override;
67 68
68 // cc::CompositorFrameSink implementation. 69 // cc::CompositorFrameSink implementation.
69 bool BindToClient(cc::CompositorFrameSinkClient* client) override; 70 bool BindToClient(cc::CompositorFrameSinkClient* client) override;
70 void DetachFromClient() override; 71 void DetachFromClient() override;
71 void SubmitCompositorFrame(cc::CompositorFrame frame) override; 72 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
72 73
73 protected:
74 uint32_t compositor_frame_sink_id_;
75
76 private: 74 private:
77 class RendererCompositorFrameSinkProxy 75 class RendererCompositorFrameSinkProxy
78 : public base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy> { 76 : public base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy> {
79 public: 77 public:
80 explicit RendererCompositorFrameSinkProxy( 78 explicit RendererCompositorFrameSinkProxy(
81 RendererCompositorFrameSink* compositor_frame_sink) 79 RendererCompositorFrameSink* compositor_frame_sink)
82 : compositor_frame_sink_(compositor_frame_sink) {} 80 : compositor_frame_sink_(compositor_frame_sink) {}
83 void ClearCompositorFrameSink() { compositor_frame_sink_ = NULL; } 81 void ClearCompositorFrameSink() { compositor_frame_sink_ = NULL; }
84 void OnMessageReceived(const IPC::Message& message) { 82 void OnMessageReceived(const IPC::Message& message) {
85 if (compositor_frame_sink_) 83 if (compositor_frame_sink_)
86 compositor_frame_sink_->OnMessageReceived(message); 84 compositor_frame_sink_->OnMessageReceived(message);
87 } 85 }
88 86
89 private: 87 private:
90 friend class base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy>; 88 friend class base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy>;
91 ~RendererCompositorFrameSinkProxy() {} 89 ~RendererCompositorFrameSinkProxy() {}
92 RendererCompositorFrameSink* compositor_frame_sink_; 90 RendererCompositorFrameSink* compositor_frame_sink_;
93 91
94 DISALLOW_COPY_AND_ASSIGN(RendererCompositorFrameSinkProxy); 92 DISALLOW_COPY_AND_ASSIGN(RendererCompositorFrameSinkProxy);
95 }; 93 };
96 94
97 void OnMessageReceived(const IPC::Message& message); 95 void OnMessageReceived(const IPC::Message& message);
98 void OnReclaimCompositorResources(uint32_t compositor_frame_sink_id, 96 void OnBeginFrameIPC(const cc::BeginFrameArgs& args);
99 bool is_swap_ack,
100 const cc::ReturnedResourceArray& resources);
101 void OnSetBeginFrameSourcePaused(bool paused);
102 void OnBeginFrame(const cc::BeginFrameArgs& args);
103 bool Send(IPC::Message* message);
104 97
105 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame); 98 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame);
106 void UpdateFrameData(const cc::CompositorFrame& frame); 99 void UpdateFrameData(const cc::CompositorFrame& frame);
107 100
101 // cc::mojom::MojoCompositorFrameSinkClient implementation.
102 void DidReceiveCompositorFrameAck(
103 const cc::ReturnedResourceArray& resources) override;
104 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
105 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
106
108 // cc::ExternalBeginFrameSourceClient implementation. 107 // cc::ExternalBeginFrameSourceClient implementation.
109 void OnNeedsBeginFrames(bool need_begin_frames) override; 108 void OnNeedsBeginFrames(bool need_begin_frames) override;
110 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; 109 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override;
111 110
111 void EstablishMojoConnection();
112
112 scoped_refptr<CompositorForwardingMessageFilter> 113 scoped_refptr<CompositorForwardingMessageFilter>
113 compositor_frame_sink_filter_; 114 compositor_frame_sink_filter_;
114 CompositorForwardingMessageFilter::Handler 115 CompositorForwardingMessageFilter::Handler
115 compositor_frame_sink_filter_handler_; 116 compositor_frame_sink_filter_handler_;
116 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_; 117 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_;
117 scoped_refptr<IPC::SyncMessageFilter> message_sender_; 118 scoped_refptr<IPC::SyncMessageFilter> message_sender_;
118 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; 119 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
119 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; 120 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_;
120 std::unique_ptr<cc::ExternalBeginFrameSource> external_begin_frame_source_; 121 std::unique_ptr<cc::ExternalBeginFrameSource> external_begin_frame_source_;
121 int routing_id_; 122 int routing_id_;
122 123
123 cc::LocalSurfaceId local_surface_id_; 124 cc::LocalSurfaceId local_surface_id_;
124 cc::LocalSurfaceIdAllocator id_allocator_; 125 cc::LocalSurfaceIdAllocator id_allocator_;
125 struct { 126 struct {
126 gfx::Size frame_size; 127 gfx::Size frame_size;
127 float device_scale_factor; 128 float device_scale_factor;
128 #ifdef OS_ANDROID 129 #ifdef OS_ANDROID
129 float top_controls_height; 130 float top_controls_height;
130 float top_controls_shown_ratio; 131 float top_controls_shown_ratio;
131 float bottom_controls_height; 132 float bottom_controls_height;
132 float bottom_controls_shown_ratio; 133 float bottom_controls_shown_ratio;
133 cc::Selection<gfx::SelectionBound> viewport_selection; 134 cc::Selection<gfx::SelectionBound> viewport_selection;
134 bool has_transparent_background; 135 bool has_transparent_background;
135 #endif 136 #endif
136 } current_frame_data_; 137 } current_frame_data_;
137 138
138 base::ThreadChecker thread_checker_; 139 base::ThreadChecker thread_checker_;
140
141 cc::mojom::MojoCompositorFrameSinkPtr sink_;
142 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_ptr_info_;
143 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request_;
144 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> sink_client_binding_;
145
139 bool bound_ = false; 146 bool bound_ = false;
140 }; 147 };
141 148
142 } // namespace content 149 } // namespace content
143 150
144 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ 151 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_forwarding_message_filter.cc ('k') | content/renderer/gpu/renderer_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698