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

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

Powered by Google App Engine
This is Rietveld 408576698