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_COMPOSITOR_OUTPUT_SURFACE_H_ | |
6 #define CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_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/output/begin_frame_args.h" | |
21 #include "cc/output/output_surface.h" | |
22 #include "cc/scheduler/begin_frame_source.h" | |
23 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" | |
24 #include "ipc/ipc_sync_message_filter.h" | |
25 | |
26 namespace IPC { | |
27 class Message; | |
28 } | |
29 | |
30 namespace cc { | |
31 class CompositorFrame; | |
32 class CompositorFrameAck; | |
33 class ContextProvider; | |
34 } | |
35 | |
36 namespace content { | |
37 class FrameSwapMessageQueue; | |
38 | |
39 // This class can be created only on the main thread, but then becomes pinned | |
40 // to a fixed thread when BindToClient is called. | |
41 class CompositorOutputSurface | |
42 : NON_EXPORTED_BASE(public cc::OutputSurface), | |
43 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
44 public: | |
45 CompositorOutputSurface( | |
46 int32_t routing_id, | |
47 uint32_t output_surface_id, | |
48 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | |
49 scoped_refptr<cc::ContextProvider> context_provider, | |
50 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
51 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); | |
52 CompositorOutputSurface( | |
53 int32_t routing_id, | |
54 uint32_t output_surface_id, | |
55 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | |
56 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | |
57 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue); | |
58 ~CompositorOutputSurface() override; | |
59 | |
60 // cc::OutputSurface implementation. | |
61 bool BindToClient(cc::OutputSurfaceClient* client) override; | |
62 void DetachFromClient() override; | |
63 void SwapBuffers(cc::CompositorFrame frame) override; | |
64 void BindFramebuffer() override; | |
65 uint32_t GetFramebufferCopyTextureFormat() override; | |
66 | |
67 protected: | |
68 uint32_t output_surface_id_; | |
69 | |
70 private: | |
71 class CompositorOutputSurfaceProxy : | |
72 public base::RefCountedThreadSafe<CompositorOutputSurfaceProxy> { | |
73 public: | |
74 explicit CompositorOutputSurfaceProxy( | |
75 CompositorOutputSurface* output_surface) | |
76 : output_surface_(output_surface) {} | |
77 void ClearOutputSurface() { output_surface_ = NULL; } | |
78 void OnMessageReceived(const IPC::Message& message) { | |
79 if (output_surface_) | |
80 output_surface_->OnMessageReceived(message); | |
81 } | |
82 | |
83 private: | |
84 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>; | |
85 ~CompositorOutputSurfaceProxy() {} | |
86 CompositorOutputSurface* output_surface_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy); | |
89 }; | |
90 | |
91 void OnMessageReceived(const IPC::Message& message); | |
92 void OnReclaimCompositorResources(uint32_t output_surface_id, | |
93 bool is_swap_ack, | |
94 const cc::ReturnedResourceArray& resources); | |
95 bool Send(IPC::Message* message); | |
96 | |
97 scoped_refptr<CompositorForwardingMessageFilter> output_surface_filter_; | |
98 CompositorForwardingMessageFilter::Handler output_surface_filter_handler_; | |
99 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; | |
100 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | |
101 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; | |
102 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; | |
103 int routing_id_; | |
104 }; | |
105 | |
106 } // namespace content | |
107 | |
108 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | |
OLD | NEW |