OLD | NEW |
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 int32 routing_id) |
91 : cc::OutputSurface(CreateWebGraphicsContext3D(), | 91 : cc::OutputSurface(CreateWebGraphicsContext3D(), |
92 scoped_ptr<cc::SoftwareOutputDevice>( | 92 scoped_ptr<cc::SoftwareOutputDevice>( |
93 new SoftwareDevice(this))), | 93 new SoftwareDevice(this))), |
94 compositor_client_(NULL), | 94 compositor_client_(NULL), |
95 routing_id_(routing_id), | 95 routing_id_(routing_id), |
96 vsync_enabled_(false), | 96 needs_begin_frame_(false), |
97 did_swap_buffer_(false), | 97 did_swap_buffer_(false), |
98 current_sw_canvas_(NULL) { | 98 current_sw_canvas_(NULL) { |
99 capabilities_.deferred_gl_initialization = true; | 99 capabilities_.deferred_gl_initialization = true; |
100 } | 100 } |
101 | 101 |
102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
103 DCHECK(CalledOnValidThread()); | 103 DCHECK(CalledOnValidThread()); |
104 if (compositor_client_) | 104 if (compositor_client_) |
105 compositor_client_->DidDestroyCompositor(this); | 105 compositor_client_->DidDestroyCompositor(this); |
106 } | 106 } |
(...skipping 15 matching lines...) Expand all Loading... |
122 void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) { | 122 void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) { |
123 // Intentional no-op: surface size is controlled by the embedder. | 123 // Intentional no-op: surface size is controlled by the embedder. |
124 } | 124 } |
125 | 125 |
126 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( | 126 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( |
127 cc::CompositorFrame* frame) { | 127 cc::CompositorFrame* frame) { |
128 NOTREACHED(); | 128 NOTREACHED(); |
129 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 | 129 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 |
130 } | 130 } |
131 | 131 |
132 void SynchronousCompositorOutputSurface::EnableVSyncNotification( | 132 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame( |
133 bool enable_vsync) { | 133 bool enable) { |
134 DCHECK(CalledOnValidThread()); | 134 DCHECK(CalledOnValidThread()); |
135 vsync_enabled_ = enable_vsync; | 135 needs_begin_frame_ = enable; |
136 UpdateCompositorClientSettings(); | 136 UpdateCompositorClientSettings(); |
137 } | 137 } |
138 | 138 |
139 void SynchronousCompositorOutputSurface::SwapBuffers( | 139 void SynchronousCompositorOutputSurface::SwapBuffers( |
140 const cc::LatencyInfo& info) { | 140 const cc::LatencyInfo& info) { |
141 context3d()->shallowFlushCHROMIUM(); | 141 context3d()->shallowFlushCHROMIUM(); |
142 did_swap_buffer_ = true; | 142 did_swap_buffer_ = true; |
143 } | 143 } |
144 | 144 |
145 void SynchronousCompositorOutputSurface::SetClient( | 145 void SynchronousCompositorOutputSurface::SetClient( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 return did_swap_buffer_; | 191 return did_swap_buffer_; |
192 } | 192 } |
193 | 193 |
194 void SynchronousCompositorOutputSurface::InvokeComposite( | 194 void SynchronousCompositorOutputSurface::InvokeComposite( |
195 const gfx::Transform& transform, | 195 const gfx::Transform& transform, |
196 gfx::Rect damage_area) { | 196 gfx::Rect damage_area) { |
197 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the | 197 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the |
198 // whole view. Tracking bug to implement this: crbug.com/230463. | 198 // whole view. Tracking bug to implement this: crbug.com/230463. |
199 client_->SetNeedsRedrawRect(damage_area); | 199 client_->SetNeedsRedrawRect(damage_area); |
200 if (vsync_enabled_) | 200 if (needs_begin_frame_) |
201 client_->DidVSync(base::TimeTicks::Now()); | 201 client_->BeginFrame(base::TimeTicks::Now()); |
202 } | 202 } |
203 | 203 |
204 void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() { | 204 void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() { |
205 if (compositor_client_) { | 205 if (compositor_client_) { |
206 compositor_client_->SetContinuousInvalidate(vsync_enabled_); | 206 compositor_client_->SetContinuousInvalidate(needs_begin_frame_); |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 210 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
211 // requirement: SynchronousCompositorOutputSurface() must only be used by | 211 // requirement: SynchronousCompositorOutputSurface() must only be used by |
212 // embedders that supply their own compositor loop via | 212 // embedders that supply their own compositor loop via |
213 // OverrideCompositorMessageLoop(). | 213 // OverrideCompositorMessageLoop(). |
214 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 214 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
215 return base::MessageLoop::current() && (base::MessageLoop::current() == | 215 return base::MessageLoop::current() && (base::MessageLoop::current() == |
216 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); | 216 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); |
217 } | 217 } |
218 | 218 |
219 } // namespace content | 219 } // namespace content |
OLD | NEW |