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_output_surface.h

Issue 2128113002: Use a cc::Display for WebView resourceless software draws. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: displaywebview: mojom Created 4 years, 5 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 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_OUTPUT_SURFACE_H_ 5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ 6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_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/managed_memory_policy.h" 19 #include "cc/output/managed_memory_policy.h"
20 #include "cc/output/output_surface.h" 20 #include "cc/output/output_surface.h"
21 #include "cc/surfaces/display_client.h"
22 #include "cc/surfaces/surface_factory_client.h"
21 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
22 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
23 25
24 namespace cc { 26 namespace cc {
25 class ContextProvider; 27 class ContextProvider;
26 class CompositorFrameMetadata; 28 class CompositorFrameMetadata;
29 class Display;
30 class SurfaceFactory;
31 class SurfaceIdAllocator;
32 class SurfaceManager;
27 } 33 }
28 34
29 namespace IPC { 35 namespace IPC {
30 class Message; 36 class Message;
31 class Sender; 37 class Sender;
32 } 38 }
33 39
34 namespace content { 40 namespace content {
35 41
36 class FrameSwapMessageQueue; 42 class FrameSwapMessageQueue;
(...skipping 13 matching lines...) Expand all
50 56
51 // Specialization of the output surface that adapts it to implement the 57 // Specialization of the output surface that adapts it to implement the
52 // content::SynchronousCompositor public API. This class effects an "inversion 58 // content::SynchronousCompositor public API. This class effects an "inversion
53 // of control" - enabling drawing to be orchestrated by the embedding 59 // of control" - enabling drawing to be orchestrated by the embedding
54 // layer, instead of driven by the compositor internals - hence it holds two 60 // layer, instead of driven by the compositor internals - hence it holds two
55 // 'client' pointers (|client_| in the OutputSurface baseclass and 61 // 'client' pointers (|client_| in the OutputSurface baseclass and
56 // |delegate_|) which represent the consumers of the two roles in plays. 62 // |delegate_|) which represent the consumers of the two roles in plays.
57 // This class can be created only on the main thread, but then becomes pinned 63 // This class can be created only on the main thread, but then becomes pinned
58 // to a fixed thread when BindToClient is called. 64 // to a fixed thread when BindToClient is called.
59 class SynchronousCompositorOutputSurface 65 class SynchronousCompositorOutputSurface
60 : NON_EXPORTED_BASE(public cc::OutputSurface) { 66 : NON_EXPORTED_BASE(public cc::OutputSurface),
67 public cc::SurfaceFactoryClient {
61 public: 68 public:
62 SynchronousCompositorOutputSurface( 69 SynchronousCompositorOutputSurface(
63 scoped_refptr<cc::ContextProvider> context_provider, 70 scoped_refptr<cc::ContextProvider> context_provider,
64 scoped_refptr<cc::ContextProvider> worker_context_provider, 71 scoped_refptr<cc::ContextProvider> worker_context_provider,
65 int routing_id, 72 int routing_id,
66 uint32_t output_surface_id, 73 uint32_t output_surface_id,
67 SynchronousCompositorRegistry* registry, 74 SynchronousCompositorRegistry* registry,
68 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); 75 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue);
69 ~SynchronousCompositorOutputSurface() override; 76 ~SynchronousCompositorOutputSurface() override;
70 77
(...skipping 14 matching lines...) Expand all
85 92
86 // Partial SynchronousCompositor API implementation. 93 // Partial SynchronousCompositor API implementation.
87 void DemandDrawHw(const gfx::Size& surface_size, 94 void DemandDrawHw(const gfx::Size& surface_size,
88 const gfx::Transform& transform, 95 const gfx::Transform& transform,
89 const gfx::Rect& viewport, 96 const gfx::Rect& viewport,
90 const gfx::Rect& clip, 97 const gfx::Rect& clip,
91 const gfx::Rect& viewport_rect_for_tile_priority, 98 const gfx::Rect& viewport_rect_for_tile_priority,
92 const gfx::Transform& transform_for_tile_priority); 99 const gfx::Transform& transform_for_tile_priority);
93 void DemandDrawSw(SkCanvas* canvas); 100 void DemandDrawSw(SkCanvas* canvas);
94 101
102 // SurfaceFactoryClient implementation.
103 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
104 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
105
95 private: 106 private:
96 class SoftwareDevice;
97 friend class SoftwareDevice;
98
99 void InvokeComposite(const gfx::Transform& transform, 107 void InvokeComposite(const gfx::Transform& transform,
100 const gfx::Rect& viewport, 108 const gfx::Rect& viewport,
101 const gfx::Rect& clip, 109 const gfx::Rect& clip);
102 bool hardware_draw);
103 bool Send(IPC::Message* message); 110 bool Send(IPC::Message* message);
104 void DidActivatePendingTree(); 111 void DidActivatePendingTree();
105 void DeliverMessages(); 112 void DeliverMessages();
106 bool CalledOnValidThread() const; 113 bool CalledOnValidThread() const;
107 114
108 void CancelFallbackTick(); 115 void CancelFallbackTick();
109 void FallbackTickFired(); 116 void FallbackTickFired();
110 117
111 // IPC handlers. 118 // IPC handlers.
112 void SetMemoryPolicy(size_t bytes_limit); 119 void SetMemoryPolicy(size_t bytes_limit);
113 void OnReclaimResources(uint32_t output_surface_id, 120 void OnReclaimResources(uint32_t output_surface_id,
114 const cc::CompositorFrameAck& ack); 121 const cc::CompositorFrameAck& ack);
115 122
116 const int routing_id_; 123 const int routing_id_;
117 const uint32_t output_surface_id_; 124 const uint32_t output_surface_id_;
118 SynchronousCompositorRegistry* const registry_; // Not owned. 125 SynchronousCompositorRegistry* const registry_; // Not owned.
119 IPC::Sender* const sender_; // Not owned. 126 IPC::Sender* const sender_; // Not owned.
120 bool registered_; 127 bool registered_ = false;
121 128
122 // Not owned. 129 // Not owned.
123 SynchronousCompositorOutputSurfaceClient* sync_client_; 130 SynchronousCompositorOutputSurfaceClient* sync_client_ = nullptr;
124 131
125 // Only valid (non-NULL) during a DemandDrawSw() call. 132 // Only valid (non-NULL) during a DemandDrawSw() call.
126 SkCanvas* current_sw_canvas_; 133 SkCanvas* current_sw_canvas_ = nullptr;
127 134
128 cc::ManagedMemoryPolicy memory_policy_; 135 cc::ManagedMemoryPolicy memory_policy_;
129 bool did_swap_; 136 bool in_software_draw_ = false;
137 bool did_swap_ = false;
130 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; 138 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
131 139
132 base::CancelableClosure fallback_tick_; 140 base::CancelableClosure fallback_tick_;
133 bool fallback_tick_pending_; 141 bool fallback_tick_pending_ = false;
134 bool fallback_tick_running_; 142 bool fallback_tick_running_ = false;
143
144 class StubDisplayClient : public cc::DisplayClient {
145 void DisplayOutputSurfaceLost() override {}
146 void DisplaySetMemoryPolicy(
147 const cc::ManagedMemoryPolicy& policy) override {}
148 };
149
150 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface
151 // is owned/destroyed on the compositor thread.
152 std::unique_ptr<cc::SurfaceManager> surface_manager_;
153 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
154 cc::SurfaceId delegated_surface_id_;
155 // Uses surface_manager_.
156 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
157 StubDisplayClient display_client_;
158 // Uses surface_manager_.
159 std::unique_ptr<cc::Display> display_;
135 160
136 base::ThreadChecker thread_checker_; 161 base::ThreadChecker thread_checker_;
137 162
138 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); 163 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface);
139 }; 164 };
140 165
141 } // namespace content 166 } // namespace content
142 167
143 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ 168 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | content/renderer/android/synchronous_compositor_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698