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

Side by Side Diff: content/renderer/android/synchronous_compositor_frame_sink.h

Issue 2692963002: Replace SurfaceFactory in SynchronousCompositorFrameSink with CompositorFrameSinkSupport (Closed)
Patch Set: submit_to_display_compositor must be false for child Created 3 years, 10 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
« no previous file with comments | « no previous file | content/renderer/android/synchronous_compositor_frame_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ 5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_
6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ 6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/cancelable_callback.h" 13 #include "base/cancelable_callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "cc/output/compositor_frame.h" 18 #include "cc/output/compositor_frame.h"
19 #include "cc/output/compositor_frame_sink.h" 19 #include "cc/output/compositor_frame_sink.h"
20 #include "cc/output/managed_memory_policy.h" 20 #include "cc/output/managed_memory_policy.h"
21 #include "cc/surfaces/compositor_frame_sink_support_client.h"
21 #include "cc/surfaces/display_client.h" 22 #include "cc/surfaces/display_client.h"
22 #include "cc/surfaces/surface_factory_client.h"
23 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
24 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
25 25
26 class SkCanvas; 26 class SkCanvas;
27 27
28 namespace cc { 28 namespace cc {
29 class BeginFrameSource;
30 class CompositorFrameSinkSupport;
29 class ContextProvider; 31 class ContextProvider;
30 class Display; 32 class Display;
31 class SurfaceFactory;
32 class SurfaceIdAllocator; 33 class SurfaceIdAllocator;
33 class SurfaceManager; 34 class SurfaceManager;
34 } 35 }
35 36
36 namespace IPC { 37 namespace IPC {
37 class Message; 38 class Message;
38 class Sender; 39 class Sender;
39 } 40 }
40 41
41 namespace content { 42 namespace content {
(...skipping 15 matching lines...) Expand all
57 // Specialization of the output surface that adapts it to implement the 58 // Specialization of the output surface that adapts it to implement the
58 // content::SynchronousCompositor public API. This class effects an "inversion 59 // content::SynchronousCompositor public API. This class effects an "inversion
59 // of control" - enabling drawing to be orchestrated by the embedding 60 // of control" - enabling drawing to be orchestrated by the embedding
60 // layer, instead of driven by the compositor internals - hence it holds two 61 // layer, instead of driven by the compositor internals - hence it holds two
61 // 'client' pointers (|client_| in the CompositorFrameSink baseclass and 62 // 'client' pointers (|client_| in the CompositorFrameSink baseclass and
62 // |delegate_|) which represent the consumers of the two roles in plays. 63 // |delegate_|) which represent the consumers of the two roles in plays.
63 // This class can be created only on the main thread, but then becomes pinned 64 // This class can be created only on the main thread, but then becomes pinned
64 // to a fixed thread when BindToClient is called. 65 // to a fixed thread when BindToClient is called.
65 class SynchronousCompositorFrameSink 66 class SynchronousCompositorFrameSink
66 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), 67 : NON_EXPORTED_BASE(public cc::CompositorFrameSink),
67 public cc::SurfaceFactoryClient { 68 public cc::CompositorFrameSinkSupportClient {
68 public: 69 public:
69 SynchronousCompositorFrameSink( 70 SynchronousCompositorFrameSink(
70 scoped_refptr<cc::ContextProvider> context_provider, 71 scoped_refptr<cc::ContextProvider> context_provider,
71 scoped_refptr<cc::ContextProvider> worker_context_provider, 72 scoped_refptr<cc::ContextProvider> worker_context_provider,
72 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 73 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
73 int routing_id, 74 int routing_id,
74 uint32_t compositor_frame_sink_id, 75 uint32_t compositor_frame_sink_id,
75 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, 76 std::unique_ptr<cc::BeginFrameSource> begin_frame_source,
76 SynchronousCompositorRegistry* registry, 77 SynchronousCompositorRegistry* registry,
77 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); 78 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue);
78 ~SynchronousCompositorFrameSink() override; 79 ~SynchronousCompositorFrameSink() override;
79 80
80 void SetSyncClient(SynchronousCompositorFrameSinkClient* compositor); 81 void SetSyncClient(SynchronousCompositorFrameSinkClient* compositor);
81 bool OnMessageReceived(const IPC::Message& message); 82 bool OnMessageReceived(const IPC::Message& message);
82 83
83 // cc::CompositorFrameSink implementation. 84 // cc::CompositorFrameSink implementation.
84 bool BindToClient(cc::CompositorFrameSinkClient* sink_client) override; 85 bool BindToClient(cc::CompositorFrameSinkClient* sink_client) override;
85 void DetachFromClient() override; 86 void DetachFromClient() override;
86 void SubmitCompositorFrame(cc::CompositorFrame frame) override; 87 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
87 void Invalidate() override; 88 void Invalidate() override;
88 89
89 // Partial SynchronousCompositor API implementation. 90 // Partial SynchronousCompositor API implementation.
90 void DemandDrawHw(const gfx::Size& viewport_size, 91 void DemandDrawHw(const gfx::Size& viewport_size,
91 const gfx::Rect& viewport_rect_for_tile_priority, 92 const gfx::Rect& viewport_rect_for_tile_priority,
92 const gfx::Transform& transform_for_tile_priority); 93 const gfx::Transform& transform_for_tile_priority);
93 void DemandDrawSw(SkCanvas* canvas); 94 void DemandDrawSw(SkCanvas* canvas);
94 95
95 // SurfaceFactoryClient implementation. 96 // CompositorFrameSinkSupportClient implementation.
96 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 97 void DidReceiveCompositorFrameAck() override;
97 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; 98 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
99 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
100 void WillDrawSurface() override;
98 101
99 private: 102 private:
100 class SoftwareOutputSurface; 103 class SoftwareOutputSurface;
101 104
102 void InvokeComposite(const gfx::Transform& transform, 105 void InvokeComposite(const gfx::Transform& transform,
103 const gfx::Rect& viewport); 106 const gfx::Rect& viewport);
104 bool Send(IPC::Message* message); 107 bool Send(IPC::Message* message);
105 void DidActivatePendingTree(); 108 void DidActivatePendingTree();
106 void DeliverMessages(); 109 void DeliverMessages();
107 bool CalledOnValidThread() const; 110 bool CalledOnValidThread() const;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void DisplayDidDrawAndSwap() override {} 145 void DisplayDidDrawAndSwap() override {}
143 }; 146 };
144 147
145 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface 148 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface
146 // is owned/destroyed on the compositor thread. 149 // is owned/destroyed on the compositor thread.
147 std::unique_ptr<cc::SurfaceManager> surface_manager_; 150 std::unique_ptr<cc::SurfaceManager> surface_manager_;
148 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 151 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
149 cc::LocalSurfaceId child_local_surface_id_; 152 cc::LocalSurfaceId child_local_surface_id_;
150 cc::LocalSurfaceId root_local_surface_id_; 153 cc::LocalSurfaceId root_local_surface_id_;
151 // Uses surface_manager_. 154 // Uses surface_manager_.
152 std::unique_ptr<cc::SurfaceFactory> root_factory_; 155 std::unique_ptr<cc::CompositorFrameSinkSupport> root_support_;
153 std::unique_ptr<cc::SurfaceFactory> child_factory_; 156 // Uses surface_manager_.
157 std::unique_ptr<cc::CompositorFrameSinkSupport> child_support_;
154 StubDisplayClient display_client_; 158 StubDisplayClient display_client_;
155 // Uses surface_manager_. 159 // Uses surface_manager_.
156 std::unique_ptr<cc::Display> display_; 160 std::unique_ptr<cc::Display> display_;
157 // Owned by |display_|. 161 // Owned by |display_|.
158 SoftwareOutputSurface* software_output_surface_ = nullptr; 162 SoftwareOutputSurface* software_output_surface_ = nullptr;
159 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; 163 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_;
160 164
161 gfx::Rect sw_viewport_for_current_draw_; 165 gfx::Rect sw_viewport_for_current_draw_;
162 166
163 base::ThreadChecker thread_checker_; 167 base::ThreadChecker thread_checker_;
164 168
165 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorFrameSink); 169 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorFrameSink);
166 }; 170 };
167 171
168 } // namespace content 172 } // namespace content
169 173
170 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ 174 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/android/synchronous_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698