| 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_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> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "cc/surfaces/local_surface_id_allocator.h" | 25 #include "cc/surfaces/local_surface_id_allocator.h" |
| 26 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" | 26 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" |
| 27 #include "ipc/ipc_sync_message_filter.h" | 27 #include "ipc/ipc_sync_message_filter.h" |
| 28 #include "ui/gfx/selection_bound.h" | 28 #include "ui/gfx/selection_bound.h" |
| 29 | 29 |
| 30 namespace IPC { | 30 namespace IPC { |
| 31 class Message; | 31 class Message; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace cc { | 34 namespace cc { |
| 35 class BeginFrameSource; | |
| 36 class CompositorFrame; | 35 class CompositorFrame; |
| 37 class ContextProvider; | 36 class ContextProvider; |
| 38 } | 37 } |
| 39 | 38 |
| 40 namespace content { | 39 namespace content { |
| 41 class FrameSwapMessageQueue; | 40 class FrameSwapMessageQueue; |
| 42 | 41 |
| 43 // This class can be created only on the main thread, but then becomes pinned | 42 // This class can be created only on the main thread, but then becomes pinned |
| 44 // to a fixed thread when BindToClient is called. | 43 // to a fixed thread when BindToClient is called. |
| 45 class RendererCompositorFrameSink | 44 class RendererCompositorFrameSink |
| 46 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), | 45 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), |
| 47 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 46 NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 47 public cc::ExternalBeginFrameSourceClient { |
| 48 public: | 48 public: |
| 49 RendererCompositorFrameSink( | 49 RendererCompositorFrameSink( |
| 50 int32_t routing_id, | 50 int32_t routing_id, |
| 51 uint32_t compositor_frame_sink_id, | 51 uint32_t compositor_frame_sink_id, |
| 52 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 52 std::unique_ptr<cc::SyntheticBeginFrameSource> |
| 53 synthetic_begin_frame_source, |
| 53 scoped_refptr<cc::ContextProvider> context_provider, | 54 scoped_refptr<cc::ContextProvider> context_provider, |
| 54 scoped_refptr<cc::ContextProvider> worker_context_provider, | 55 scoped_refptr<cc::ContextProvider> worker_context_provider, |
| 55 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 56 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 56 cc::SharedBitmapManager* shared_bitmap_manager, | 57 cc::SharedBitmapManager* shared_bitmap_manager, |
| 57 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); | 58 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); |
| 58 RendererCompositorFrameSink( | 59 RendererCompositorFrameSink( |
| 59 int32_t routing_id, | 60 int32_t routing_id, |
| 60 uint32_t compositor_frame_sink_id, | 61 uint32_t compositor_frame_sink_id, |
| 61 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 62 std::unique_ptr<cc::SyntheticBeginFrameSource> |
| 63 synthetic_begin_frame_source, |
| 62 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 64 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 63 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); | 65 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); |
| 64 ~RendererCompositorFrameSink() override; | 66 ~RendererCompositorFrameSink() override; |
| 65 | 67 |
| 66 // cc::CompositorFrameSink implementation. | 68 // cc::CompositorFrameSink implementation. |
| 67 bool BindToClient(cc::CompositorFrameSinkClient* client) override; | 69 bool BindToClient(cc::CompositorFrameSinkClient* client) override; |
| 68 void DetachFromClient() override; | 70 void DetachFromClient() override; |
| 69 void SubmitCompositorFrame(cc::CompositorFrame frame) override; | 71 void SubmitCompositorFrame(cc::CompositorFrame frame) override; |
| 70 | 72 |
| 71 protected: | 73 protected: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 ~RendererCompositorFrameSinkProxy() {} | 91 ~RendererCompositorFrameSinkProxy() {} |
| 90 RendererCompositorFrameSink* compositor_frame_sink_; | 92 RendererCompositorFrameSink* compositor_frame_sink_; |
| 91 | 93 |
| 92 DISALLOW_COPY_AND_ASSIGN(RendererCompositorFrameSinkProxy); | 94 DISALLOW_COPY_AND_ASSIGN(RendererCompositorFrameSinkProxy); |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 void OnMessageReceived(const IPC::Message& message); | 97 void OnMessageReceived(const IPC::Message& message); |
| 96 void OnReclaimCompositorResources(uint32_t compositor_frame_sink_id, | 98 void OnReclaimCompositorResources(uint32_t compositor_frame_sink_id, |
| 97 bool is_swap_ack, | 99 bool is_swap_ack, |
| 98 const cc::ReturnedResourceArray& resources); | 100 const cc::ReturnedResourceArray& resources); |
| 101 void OnSetBeginFrameSourcePaused(bool paused); |
| 102 void OnBeginFrame(const cc::BeginFrameArgs& args); |
| 99 bool Send(IPC::Message* message); | 103 bool Send(IPC::Message* message); |
| 100 | 104 |
| 101 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame); | 105 bool ShouldAllocateNewLocalSurfaceId(const cc::CompositorFrame& frame); |
| 102 void UpdateFrameData(const cc::CompositorFrame& frame); | 106 void UpdateFrameData(const cc::CompositorFrame& frame); |
| 103 | 107 |
| 108 // cc::ExternalBeginFrameSourceClient implementation. |
| 109 void OnNeedsBeginFrames(bool need_begin_frames) override; |
| 110 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; |
| 111 |
| 104 scoped_refptr<CompositorForwardingMessageFilter> | 112 scoped_refptr<CompositorForwardingMessageFilter> |
| 105 compositor_frame_sink_filter_; | 113 compositor_frame_sink_filter_; |
| 106 CompositorForwardingMessageFilter::Handler | 114 CompositorForwardingMessageFilter::Handler |
| 107 compositor_frame_sink_filter_handler_; | 115 compositor_frame_sink_filter_handler_; |
| 108 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_; | 116 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_; |
| 109 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | 117 scoped_refptr<IPC::SyncMessageFilter> message_sender_; |
| 110 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; | 118 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
| 111 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; | 119 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source_; |
| 120 std::unique_ptr<cc::ExternalBeginFrameSource> external_begin_frame_source_; |
| 112 int routing_id_; | 121 int routing_id_; |
| 113 | 122 |
| 114 cc::LocalSurfaceId local_surface_id_; | 123 cc::LocalSurfaceId local_surface_id_; |
| 115 cc::LocalSurfaceIdAllocator id_allocator_; | 124 cc::LocalSurfaceIdAllocator id_allocator_; |
| 116 struct { | 125 struct { |
| 117 gfx::Size frame_size; | 126 gfx::Size frame_size; |
| 118 float device_scale_factor; | 127 float device_scale_factor; |
| 119 #ifdef OS_ANDROID | 128 #ifdef OS_ANDROID |
| 120 float top_controls_height; | 129 float top_controls_height; |
| 121 float top_controls_shown_ratio; | 130 float top_controls_shown_ratio; |
| 122 float bottom_controls_height; | 131 float bottom_controls_height; |
| 123 float bottom_controls_shown_ratio; | 132 float bottom_controls_shown_ratio; |
| 124 cc::Selection<gfx::SelectionBound> viewport_selection; | 133 cc::Selection<gfx::SelectionBound> viewport_selection; |
| 125 bool has_transparent_background; | 134 bool has_transparent_background; |
| 126 #endif | 135 #endif |
| 127 } current_frame_data_; | 136 } current_frame_data_; |
| 128 | 137 |
| 129 base::ThreadChecker thread_checker_; | 138 base::ThreadChecker thread_checker_; |
| 130 bool bound_ = false; | 139 bool bound_ = false; |
| 131 }; | 140 }; |
| 132 | 141 |
| 133 } // namespace content | 142 } // namespace content |
| 134 | 143 |
| 135 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ | 144 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ |
| OLD | NEW |