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

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

Issue 15875009: Refactor SynchronousCompositor out of SynchronousCompositorOutputSurface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase mistake Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/renderer/android/synchronous_compositor_output_surface.h" 5 #include "content/renderer/android/synchronous_compositor_output_surface.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 private: 81 private:
82 SynchronousCompositorOutputSurface* surface_; 82 SynchronousCompositorOutputSurface* surface_;
83 SkDevice null_device_; 83 SkDevice null_device_;
84 SkCanvas null_canvas_; 84 SkCanvas null_canvas_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); 86 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice);
87 }; 87 };
88 88
89 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( 89 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
90 int32 routing_id) 90 SynchronousCompositorOutputSurfaceDelegate* delegate)
91 : cc::OutputSurface(CreateWebGraphicsContext3D(), 91 : cc::OutputSurface(
92 scoped_ptr<cc::SoftwareOutputDevice>( 92 CreateWebGraphicsContext3D(),
93 new SoftwareDevice(this))), 93 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
94 compositor_client_(NULL), 94 delegate_(delegate),
95 routing_id_(routing_id),
96 needs_begin_frame_(false), 95 needs_begin_frame_(false),
97 did_swap_buffer_(false), 96 did_swap_buffer_(false),
98 current_sw_canvas_(NULL) { 97 current_sw_canvas_(NULL) {
99 capabilities_.deferred_gl_initialization = true; 98 capabilities_.deferred_gl_initialization = true;
100 } 99 }
101 100
102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { 101 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
103 DCHECK(CalledOnValidThread()); 102 DCHECK(CalledOnValidThread());
104 if (compositor_client_) 103 delegate_->DidDestroySynchronousOutputSurface();
105 compositor_client_->DidDestroyCompositor(this);
106 } 104 }
107 105
108 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { 106 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
109 return current_sw_canvas_ != NULL; 107 return current_sw_canvas_ != NULL;
110 } 108 }
111 109
112 bool SynchronousCompositorOutputSurface::BindToClient( 110 bool SynchronousCompositorOutputSurface::BindToClient(
113 cc::OutputSurfaceClient* surface_client) { 111 cc::OutputSurfaceClient* surface_client) {
114 DCHECK(CalledOnValidThread()); 112 DCHECK(CalledOnValidThread());
115 if (!cc::OutputSurface::BindToClient(surface_client)) 113 if (!cc::OutputSurface::BindToClient(surface_client))
116 return false; 114 return false;
117 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, 115 delegate_->DidCreateSynchronousOutputSurface();
118 this);
119 return true; 116 return true;
120 } 117 }
121 118
122 void SynchronousCompositorOutputSurface::Reshape( 119 void SynchronousCompositorOutputSurface::Reshape(
123 gfx::Size size, float scale_factor) { 120 gfx::Size size, float scale_factor) {
124 // Intentional no-op: surface size is controlled by the embedder. 121 // Intentional no-op: surface size is controlled by the embedder.
125 } 122 }
126 123
127 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( 124 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
128 cc::CompositorFrame* frame) { 125 cc::CompositorFrame* frame) {
129 NOTREACHED(); 126 NOTREACHED();
130 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 127 // TODO(joth): Route page scale to the client, see http://crbug.com/237006
131 } 128 }
132 129
133 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame( 130 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(
134 bool enable) { 131 bool enable) {
135 DCHECK(CalledOnValidThread()); 132 DCHECK(CalledOnValidThread());
136 needs_begin_frame_ = enable; 133 needs_begin_frame_ = enable;
137 UpdateCompositorClientSettings(); 134 delegate_->SetContinuousInvalidate(needs_begin_frame_);
138 } 135 }
139 136
140 void SynchronousCompositorOutputSurface::SwapBuffers( 137 void SynchronousCompositorOutputSurface::SwapBuffers(
141 const ui::LatencyInfo& info) { 138 const ui::LatencyInfo& info) {
142 context3d()->shallowFlushCHROMIUM(); 139 context3d()->shallowFlushCHROMIUM();
143 did_swap_buffer_ = true; 140 did_swap_buffer_ = true;
144 } 141 }
145 142
146 void SynchronousCompositorOutputSurface::SetClient(
147 SynchronousCompositorClient* compositor_client) {
148 DCHECK(CalledOnValidThread());
149 compositor_client_ = compositor_client;
150 UpdateCompositorClientSettings();
151 }
152
153 bool SynchronousCompositorOutputSurface::IsHwReady() { 143 bool SynchronousCompositorOutputSurface::IsHwReady() {
154 return context3d() != NULL; 144 return context3d() != NULL;
155 } 145 }
156 146
157 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { 147 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
158 DCHECK(CalledOnValidThread()); 148 DCHECK(CalledOnValidThread());
159 DCHECK(canvas); 149 DCHECK(canvas);
160 DCHECK(!current_sw_canvas_); 150 DCHECK(!current_sw_canvas_);
161 current_sw_canvas_ = canvas; 151 current_sw_canvas_ = canvas;
162 152
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void SynchronousCompositorOutputSurface::InvokeComposite( 185 void SynchronousCompositorOutputSurface::InvokeComposite(
196 const gfx::Transform& transform, 186 const gfx::Transform& transform,
197 gfx::Rect damage_area) { 187 gfx::Rect damage_area) {
198 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the 188 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
199 // whole view. Tracking bug to implement this: crbug.com/230463. 189 // whole view. Tracking bug to implement this: crbug.com/230463.
200 client_->SetNeedsRedrawRect(damage_area); 190 client_->SetNeedsRedrawRect(damage_area);
201 if (needs_begin_frame_) 191 if (needs_begin_frame_)
202 client_->BeginFrame(base::TimeTicks::Now()); 192 client_->BeginFrame(base::TimeTicks::Now());
203 } 193 }
204 194
205 void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() {
206 if (compositor_client_) {
207 compositor_client_->SetContinuousInvalidate(needs_begin_frame_);
208 }
209 }
210
211 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 195 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
212 // requirement: SynchronousCompositorOutputSurface() must only be used by 196 // requirement: SynchronousCompositorOutputSurface() must only be used by
213 // embedders that supply their own compositor loop via 197 // embedders that supply their own compositor loop via
214 // OverrideCompositorMessageLoop(). 198 // OverrideCompositorMessageLoop().
215 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 199 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
216 return base::MessageLoop::current() && (base::MessageLoop::current() == 200 return base::MessageLoop::current() && (base::MessageLoop::current() ==
217 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); 201 GetContentClient()->renderer()->OverrideCompositorMessageLoop());
218 } 202 }
219 203
220 } // namespace content 204 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698