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

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

Issue 1769913003: sync compositor: Add output_surface_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit in test Created 4 years, 9 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 <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 33
34 namespace content { 34 namespace content {
35 35
36 class FrameSwapMessageQueue; 36 class FrameSwapMessageQueue;
37 class SynchronousCompositorRegistry; 37 class SynchronousCompositorRegistry;
38 class WebGraphicsContext3DCommandBufferImpl; 38 class WebGraphicsContext3DCommandBufferImpl;
39 39
40 class SynchronousCompositorOutputSurfaceClient { 40 class SynchronousCompositorOutputSurfaceClient {
41 public: 41 public:
42 virtual void Invalidate() = 0; 42 virtual void Invalidate() = 0;
43 virtual void SwapBuffers(cc::CompositorFrame* frame) = 0; 43 virtual void SwapBuffers(uint32_t output_surface_id,
44 cc::CompositorFrame* frame) = 0;
44 45
45 protected: 46 protected:
46 virtual ~SynchronousCompositorOutputSurfaceClient() {} 47 virtual ~SynchronousCompositorOutputSurfaceClient() {}
47 }; 48 };
48 49
49 // Specialization of the output surface that adapts it to implement the 50 // Specialization of the output surface that adapts it to implement the
50 // content::SynchronousCompositor public API. This class effects an "inversion 51 // content::SynchronousCompositor public API. This class effects an "inversion
51 // of control" - enabling drawing to be orchestrated by the embedding 52 // of control" - enabling drawing to be orchestrated by the embedding
52 // layer, instead of driven by the compositor internals - hence it holds two 53 // layer, instead of driven by the compositor internals - hence it holds two
53 // 'client' pointers (|client_| in the OutputSurface baseclass and 54 // 'client' pointers (|client_| in the OutputSurface baseclass and
54 // |delegate_|) which represent the consumers of the two roles in plays. 55 // |delegate_|) which represent the consumers of the two roles in plays.
55 // This class can be created only on the main thread, but then becomes pinned 56 // This class can be created only on the main thread, but then becomes pinned
56 // to a fixed thread when BindToClient is called. 57 // to a fixed thread when BindToClient is called.
57 class SynchronousCompositorOutputSurface 58 class SynchronousCompositorOutputSurface
58 : NON_EXPORTED_BASE(public cc::OutputSurface) { 59 : NON_EXPORTED_BASE(public cc::OutputSurface) {
59 public: 60 public:
60 SynchronousCompositorOutputSurface( 61 SynchronousCompositorOutputSurface(
61 const scoped_refptr<cc::ContextProvider>& context_provider, 62 const scoped_refptr<cc::ContextProvider>& context_provider,
62 const scoped_refptr<cc::ContextProvider>& worker_context_provider, 63 const scoped_refptr<cc::ContextProvider>& worker_context_provider,
63 int routing_id, 64 int routing_id,
65 uint32_t output_surface_id,
64 SynchronousCompositorRegistry* registry, 66 SynchronousCompositorRegistry* registry,
65 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); 67 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue);
66 ~SynchronousCompositorOutputSurface() override; 68 ~SynchronousCompositorOutputSurface() override;
67 69
68 void SetSyncClient(SynchronousCompositorOutputSurfaceClient* compositor); 70 void SetSyncClient(SynchronousCompositorOutputSurfaceClient* compositor);
69 71
70 // OutputSurface. 72 // OutputSurface.
71 void DidLoseOutputSurface() override; 73 void DidLoseOutputSurface() override;
72 bool BindToClient(cc::OutputSurfaceClient* surface_client) override; 74 bool BindToClient(cc::OutputSurfaceClient* surface_client) override;
73 void DetachFromClient() override; 75 void DetachFromClient() override;
74 void Reshape(const gfx::Size& size, 76 void Reshape(const gfx::Size& size,
75 float scale_factor, 77 float scale_factor,
76 bool has_alpha) override; 78 bool has_alpha) override;
77 void SwapBuffers(cc::CompositorFrame* frame) override; 79 void SwapBuffers(cc::CompositorFrame* frame) override;
78 void Invalidate() override; 80 void Invalidate() override;
79 81
80 // Partial SynchronousCompositor API implementation. 82 // Partial SynchronousCompositor API implementation.
81 void DemandDrawHw(const gfx::Size& surface_size, 83 void DemandDrawHw(const gfx::Size& surface_size,
82 const gfx::Transform& transform, 84 const gfx::Transform& transform,
83 const gfx::Rect& viewport, 85 const gfx::Rect& viewport,
84 const gfx::Rect& clip, 86 const gfx::Rect& clip,
85 const gfx::Rect& viewport_rect_for_tile_priority, 87 const gfx::Rect& viewport_rect_for_tile_priority,
86 const gfx::Transform& transform_for_tile_priority); 88 const gfx::Transform& transform_for_tile_priority);
87 void ReturnResources(const cc::CompositorFrameAck& frame_ack); 89 void ReturnResources(uint32_t output_surface_id,
90 const cc::CompositorFrameAck& frame_ack);
88 void DemandDrawSw(SkCanvas* canvas); 91 void DemandDrawSw(SkCanvas* canvas);
89 void SetMemoryPolicy(size_t bytes_limit); 92 void SetMemoryPolicy(size_t bytes_limit);
90 void SetTreeActivationCallback(const base::Closure& callback); 93 void SetTreeActivationCallback(const base::Closure& callback);
91 void GetMessagesToDeliver(std::vector<scoped_ptr<IPC::Message>>* messages); 94 void GetMessagesToDeliver(std::vector<scoped_ptr<IPC::Message>>* messages);
92 95
93 size_t GetMemoryPolicy() const { 96 size_t GetMemoryPolicy() const {
94 return memory_policy_.bytes_limit_when_visible; 97 return memory_policy_.bytes_limit_when_visible;
95 } 98 }
96 99
97 private: 100 private:
98 class SoftwareDevice; 101 class SoftwareDevice;
99 friend class SoftwareDevice; 102 friend class SoftwareDevice;
100 103
101 void InvokeComposite(const gfx::Transform& transform, 104 void InvokeComposite(const gfx::Transform& transform,
102 const gfx::Rect& viewport, 105 const gfx::Rect& viewport,
103 const gfx::Rect& clip, 106 const gfx::Rect& clip,
104 bool hardware_draw); 107 bool hardware_draw);
105 bool CalledOnValidThread() const; 108 bool CalledOnValidThread() const;
106 109
107 void CancelFallbackTick(); 110 void CancelFallbackTick();
108 void FallbackTickFired(); 111 void FallbackTickFired();
109 112
110 const int routing_id_; 113 const int routing_id_;
114 const uint32_t output_surface_id_;
111 SynchronousCompositorRegistry* const registry_; // unowned 115 SynchronousCompositorRegistry* const registry_; // unowned
112 bool registered_; 116 bool registered_;
113 117
114 // Not owned. 118 // Not owned.
115 SynchronousCompositorOutputSurfaceClient* sync_client_; 119 SynchronousCompositorOutputSurfaceClient* sync_client_;
116 120
117 // Only valid (non-NULL) during a DemandDrawSw() call. 121 // Only valid (non-NULL) during a DemandDrawSw() call.
118 SkCanvas* current_sw_canvas_; 122 SkCanvas* current_sw_canvas_;
119 123
120 cc::ManagedMemoryPolicy memory_policy_; 124 cc::ManagedMemoryPolicy memory_policy_;
121 bool did_swap_; 125 bool did_swap_;
122 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; 126 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
123 127
124 base::CancelableClosure fallback_tick_; 128 base::CancelableClosure fallback_tick_;
125 bool fallback_tick_pending_; 129 bool fallback_tick_pending_;
126 bool fallback_tick_running_; 130 bool fallback_tick_running_;
127 131
128 base::ThreadChecker thread_checker_; 132 base::ThreadChecker thread_checker_;
129 133
130 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); 134 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface);
131 }; 135 };
132 136
133 } // namespace content 137 } // namespace content
134 138
135 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ 139 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698