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

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

Issue 2774373002: Use MojoCompositorFrameSink in RendererCompositorFrameSink (Closed)
Patch Set: Fixed mac 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 {
31 class Message;
32 }
33
34 namespace cc { 32 namespace cc {
35 class CompositorFrame; 33 class CompositorFrame;
36 class ContextProvider; 34 class ContextProvider;
37 } 35 }
38 36
39 namespace content { 37 namespace content {
40 class FrameSwapMessageQueue; 38 class FrameSwapMessageQueue;
41 39
42 // This class can be created only on the main thread, but then becomes pinned 40 // This class can be created only on the main thread, but then becomes pinned
43 // to a fixed thread when BindToClient is called. 41 // to a fixed thread when BindToClient is called.
44 class RendererCompositorFrameSink 42 class RendererCompositorFrameSink
45 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), 43 : NON_EXPORTED_BASE(public cc::CompositorFrameSink),
46 NON_EXPORTED_BASE(public base::NonThreadSafe), 44 NON_EXPORTED_BASE(public base::NonThreadSafe),
45 NON_EXPORTED_BASE(public cc::mojom::MojoCompositorFrameSinkClient),
47 public cc::ExternalBeginFrameSourceClient { 46 public cc::ExternalBeginFrameSourceClient {
48 public: 47 public:
49 RendererCompositorFrameSink( 48 RendererCompositorFrameSink(
50 int32_t routing_id, 49 int32_t routing_id,
51 uint32_t compositor_frame_sink_id,
52 std::unique_ptr<cc::SyntheticBeginFrameSource> 50 std::unique_ptr<cc::SyntheticBeginFrameSource>
53 synthetic_begin_frame_source, 51 synthetic_begin_frame_source,
54 scoped_refptr<cc::ContextProvider> context_provider, 52 scoped_refptr<cc::ContextProvider> context_provider,
55 scoped_refptr<cc::ContextProvider> worker_context_provider, 53 scoped_refptr<cc::ContextProvider> worker_context_provider,
56 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 54 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
57 cc::SharedBitmapManager* shared_bitmap_manager, 55 cc::SharedBitmapManager* shared_bitmap_manager,
58 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); 56 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue);
59 RendererCompositorFrameSink( 57 RendererCompositorFrameSink(
60 int32_t routing_id, 58 int32_t routing_id,
61 uint32_t compositor_frame_sink_id,
62 std::unique_ptr<cc::SyntheticBeginFrameSource> 59 std::unique_ptr<cc::SyntheticBeginFrameSource>
63 synthetic_begin_frame_source, 60 synthetic_begin_frame_source,
64 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 61 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
65 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); 62 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue);
66 ~RendererCompositorFrameSink() override; 63 ~RendererCompositorFrameSink() override;
67 64
68 // cc::CompositorFrameSink implementation. 65 // cc::CompositorFrameSink implementation.
69 bool BindToClient(cc::CompositorFrameSinkClient* client) override; 66 bool BindToClient(cc::CompositorFrameSinkClient* client) override;
70 void DetachFromClient() override; 67 void DetachFromClient() override;
71 void SubmitCompositorFrame(cc::CompositorFrame frame) override; 68 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
72 69
73 protected:
74 uint32_t compositor_frame_sink_id_;
75
76 private: 70 private:
77 class RendererCompositorFrameSinkProxy
78 : public base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy> {
79 public:
80 explicit RendererCompositorFrameSinkProxy(
81 RendererCompositorFrameSink* compositor_frame_sink)
82 : compositor_frame_sink_(compositor_frame_sink) {}
83 void ClearCompositorFrameSink() { compositor_frame_sink_ = NULL; }
84 void OnMessageReceived(const IPC::Message& message) {
85 if (compositor_frame_sink_)
86 compositor_frame_sink_->OnMessageReceived(message);
87 }
88
89 private:
90 friend class base::RefCountedThreadSafe<RendererCompositorFrameSinkProxy>;
91 ~RendererCompositorFrameSinkProxy() {}
92 RendererCompositorFrameSink* compositor_frame_sink_;
93
94 DISALLOW_COPY_AND_ASSIGN(RendererCompositorFrameSinkProxy);
95 };
96
97 void OnMessageReceived(const IPC::Message& message);
98 void OnReclaimCompositorResources(uint32_t compositor_frame_sink_id,
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
105 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame); 71 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame);
106 void UpdateFrameData(const cc::CompositorFrame& frame); 72 void UpdateFrameData(const cc::CompositorFrame& frame);
107 73
74 // cc::mojom::MojoCompositorFrameSinkClient implementation.
75 void DidReceiveCompositorFrameAck() override;
76 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
77 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
78 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id,
79 const gfx::Rect& damage_rect) override {}
80
108 // cc::ExternalBeginFrameSourceClient implementation. 81 // cc::ExternalBeginFrameSourceClient implementation.
109 void OnNeedsBeginFrames(bool need_begin_frames) override; 82 void OnNeedsBeginFrames(bool need_begin_frames) override;
110 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; 83 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override;
111 84
112 scoped_refptr<CompositorForwardingMessageFilter> 85 void EstablishMojoConnection();
113 compositor_frame_sink_filter_; 86
114 CompositorForwardingMessageFilter::Handler
115 compositor_frame_sink_filter_handler_;
116 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_;
117 scoped_refptr<IPC::SyncMessageFilter> message_sender_; 87 scoped_refptr<IPC::SyncMessageFilter> message_sender_;
118 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; 88 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
119 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; 89 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_;
120 std::unique_ptr<cc::ExternalBeginFrameSource> external_begin_frame_source_; 90 std::unique_ptr<cc::ExternalBeginFrameSource> external_begin_frame_source_;
121 int routing_id_; 91 int routing_id_;
122 92
123 cc::LocalSurfaceId local_surface_id_; 93 cc::LocalSurfaceId local_surface_id_;
124 cc::LocalSurfaceIdAllocator id_allocator_; 94 cc::LocalSurfaceIdAllocator id_allocator_;
125 struct { 95 struct {
126 gfx::Size frame_size; 96 gfx::Size frame_size;
127 float device_scale_factor; 97 float device_scale_factor;
128 #ifdef OS_ANDROID 98 #ifdef OS_ANDROID
129 float top_controls_height; 99 float top_controls_height;
130 float top_controls_shown_ratio; 100 float top_controls_shown_ratio;
131 float bottom_controls_height; 101 float bottom_controls_height;
132 float bottom_controls_shown_ratio; 102 float bottom_controls_shown_ratio;
133 cc::Selection<gfx::SelectionBound> viewport_selection; 103 cc::Selection<gfx::SelectionBound> viewport_selection;
134 bool has_transparent_background; 104 bool has_transparent_background;
135 #endif 105 #endif
136 } current_frame_data_; 106 } current_frame_data_;
137 107
138 base::ThreadChecker thread_checker_; 108 base::ThreadChecker thread_checker_;
109
110 cc::mojom::MojoCompositorFrameSinkPtr sink_;
111 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_ptr_info_;
112 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request_;
113 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> sink_client_binding_;
114
139 bool bound_ = false; 115 bool bound_ = false;
140 }; 116 };
141 117
142 } // namespace content 118 } // namespace content
143 119
144 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ 120 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698