| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ | |
| 6 #define CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "base/threading/non_thread_safe.h" | |
| 17 #include "base/threading/platform_thread.h" | |
| 18 #include "base/time/time.h" | |
| 19 #include "build/build_config.h" | |
| 20 #include "cc/input/selection.h" | |
| 21 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | |
| 22 #include "cc/output/begin_frame_args.h" | |
| 23 #include "cc/output/compositor_frame_sink.h" | |
| 24 #include "cc/scheduler/begin_frame_source.h" | |
| 25 #include "cc/surfaces/local_surface_id.h" | |
| 26 #include "cc/surfaces/local_surface_id_allocator.h" | |
| 27 #include "components/viz/client/client_compositor_frame_sink.h" | |
| 28 #include "content/common/render_widget_surface_properties.h" | |
| 29 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" | |
| 30 #include "ipc/ipc_sync_message_filter.h" | |
| 31 #include "mojo/public/cpp/bindings/binding.h" | |
| 32 #include "ui/gfx/selection_bound.h" | |
| 33 | |
| 34 namespace IPC { | |
| 35 class Message; | |
| 36 } | |
| 37 | |
| 38 namespace cc { | |
| 39 class CompositorFrame; | |
| 40 class ContextProvider; | |
| 41 } | |
| 42 | |
| 43 namespace content { | |
| 44 | |
| 45 // This class can be created only on the main thread, but then becomes pinned | |
| 46 // to a fixed thread when BindToClient is called. | |
| 47 class RendererCompositorFrameSink | |
| 48 : NON_EXPORTED_BASE(public viz::ClientCompositorFrameSink) { | |
| 49 public: | |
| 50 RendererCompositorFrameSink( | |
| 51 int32_t routing_id, | |
| 52 std::unique_ptr<cc::SyntheticBeginFrameSource> | |
| 53 synthetic_begin_frame_source, | |
| 54 scoped_refptr<cc::ContextProvider> context_provider, | |
| 55 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
| 56 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
| 57 cc::SharedBitmapManager* shared_bitmap_manager, | |
| 58 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_info, | |
| 59 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request); | |
| 60 RendererCompositorFrameSink( | |
| 61 int32_t routing_id, | |
| 62 std::unique_ptr<cc::SyntheticBeginFrameSource> | |
| 63 synthetic_begin_frame_source, | |
| 64 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | |
| 65 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_info, | |
| 66 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request); | |
| 67 ~RendererCompositorFrameSink() override; | |
| 68 | |
| 69 // Overriden from viz::ClientCompositorFrameSink. | |
| 70 bool BindToClient(cc::CompositorFrameSinkClient* client) override; | |
| 71 void DetachFromClient() override; | |
| 72 void SubmitCompositorFrame(cc::CompositorFrame frame) override; | |
| 73 bool ShouldAllocateNewLocalSurfaceId( | |
| 74 const cc::CompositorFrame& frame) override; | |
| 75 | |
| 76 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 | |
| 99 scoped_refptr<CompositorForwardingMessageFilter> | |
| 100 compositor_frame_sink_filter_; | |
| 101 CompositorForwardingMessageFilter::Handler | |
| 102 compositor_frame_sink_filter_handler_; | |
| 103 scoped_refptr<RendererCompositorFrameSinkProxy> compositor_frame_sink_proxy_; | |
| 104 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | |
| 105 int routing_id_; | |
| 106 | |
| 107 RenderWidgetSurfaceProperties current_surface_properties_; | |
| 108 }; | |
| 109 | |
| 110 } // namespace content | |
| 111 | |
| 112 #endif // CONTENT_RENDERER_GPU_RENDERER_COMPOSITOR_FRAME_SINK_H_ | |
| OLD | NEW |