OLD | NEW |
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 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { | 155 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { |
156 DCHECK(CalledOnValidThread()); | 156 DCHECK(CalledOnValidThread()); |
157 cc::OutputSurface::ReleaseGL(); | 157 cc::OutputSurface::ReleaseGL(); |
158 } | 158 } |
159 | 159 |
160 scoped_ptr<cc::CompositorFrame> | 160 scoped_ptr<cc::CompositorFrame> |
161 SynchronousCompositorOutputSurface::DemandDrawHw( | 161 SynchronousCompositorOutputSurface::DemandDrawHw( |
162 gfx::Size surface_size, | 162 gfx::Size surface_size, |
163 const gfx::Transform& transform, | 163 const gfx::Transform& transform, |
164 gfx::Rect viewport, | 164 gfx::Rect viewport, |
165 gfx::Rect clip) { | 165 gfx::Rect clip, |
| 166 gfx::Rect device_rect_for_tiling) { |
166 DCHECK(CalledOnValidThread()); | 167 DCHECK(CalledOnValidThread()); |
167 DCHECK(HasClient()); | 168 DCHECK(HasClient()); |
168 DCHECK(context_provider_); | 169 DCHECK(context_provider_); |
169 | 170 |
170 surface_size_ = surface_size; | 171 surface_size_ = surface_size; |
171 InvokeComposite(transform, viewport, clip, true); | 172 InvokeComposite(transform, viewport, clip, device_rect_for_tiling, true); |
172 | 173 |
173 return frame_holder_.Pass(); | 174 return frame_holder_.Pass(); |
174 } | 175 } |
175 | 176 |
176 scoped_ptr<cc::CompositorFrame> | 177 scoped_ptr<cc::CompositorFrame> |
177 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { | 178 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { |
178 DCHECK(CalledOnValidThread()); | 179 DCHECK(CalledOnValidThread()); |
179 DCHECK(canvas); | 180 DCHECK(canvas); |
180 DCHECK(!current_sw_canvas_); | 181 DCHECK(!current_sw_canvas_); |
181 base::AutoReset<SkCanvas*> canvas_resetter(¤t_sw_canvas_, canvas); | 182 base::AutoReset<SkCanvas*> canvas_resetter(¤t_sw_canvas_, canvas); |
182 | 183 |
183 SkIRect canvas_clip; | 184 SkIRect canvas_clip; |
184 canvas->getClipDeviceBounds(&canvas_clip); | 185 canvas->getClipDeviceBounds(&canvas_clip); |
185 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); | 186 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); |
186 | 187 |
187 gfx::Transform transform(gfx::Transform::kSkipInitialization); | 188 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
188 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. | 189 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. |
189 | 190 |
190 surface_size_ = gfx::Size(canvas->getDeviceSize().width(), | 191 surface_size_ = gfx::Size(canvas->getDeviceSize().width(), |
191 canvas->getDeviceSize().height()); | 192 canvas->getDeviceSize().height()); |
192 | 193 |
193 InvokeComposite(transform, clip, clip, false); | 194 // Resourceless software draw does not need viewport_for_tiling. |
| 195 gfx::Rect empty; |
| 196 InvokeComposite(transform, clip, clip, empty, false); |
194 | 197 |
195 return frame_holder_.Pass(); | 198 return frame_holder_.Pass(); |
196 } | 199 } |
197 | 200 |
198 void SynchronousCompositorOutputSurface::InvokeComposite( | 201 void SynchronousCompositorOutputSurface::InvokeComposite( |
199 const gfx::Transform& transform, | 202 const gfx::Transform& transform, |
200 gfx::Rect viewport, | 203 gfx::Rect viewport, |
201 gfx::Rect clip, | 204 gfx::Rect clip, |
| 205 gfx::Rect device_rect_for_tiling, |
202 bool hardware_draw) { | 206 bool hardware_draw) { |
203 DCHECK(!invoking_composite_); | 207 DCHECK(!invoking_composite_); |
204 DCHECK(!frame_holder_.get()); | 208 DCHECK(!frame_holder_.get()); |
205 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); | 209 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); |
206 | 210 |
207 gfx::Transform adjusted_transform = transform; | 211 gfx::Transform adjusted_transform = transform; |
208 AdjustTransform(&adjusted_transform, viewport); | 212 AdjustTransform(&adjusted_transform, viewport); |
209 SetExternalDrawConstraints( | 213 SetExternalDrawConstraints(adjusted_transform, |
210 adjusted_transform, viewport, clip, !hardware_draw); | 214 viewport, |
| 215 clip, |
| 216 device_rect_for_tiling, |
| 217 !hardware_draw); |
211 SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 218 SetNeedsRedrawRect(gfx::Rect(viewport.size())); |
212 client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); | 219 client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |
213 | 220 |
214 // After software draws (which might move the viewport arbitrarily), restore | 221 // After software draws (which might move the viewport arbitrarily), restore |
215 // the previous hardware viewport to allow CC's tile manager to prioritize | 222 // the previous hardware viewport to allow CC's tile manager to prioritize |
216 // properly. | 223 // properly. |
217 if (hardware_draw) { | 224 if (hardware_draw) { |
218 cached_hw_transform_ = adjusted_transform; | 225 cached_hw_transform_ = adjusted_transform; |
219 cached_hw_viewport_ = viewport; | 226 cached_hw_viewport_ = viewport; |
220 cached_hw_clip_ = clip; | 227 cached_hw_clip_ = clip; |
| 228 cached_hw_device_rect_for_tiling_ = device_rect_for_tiling; |
221 } else { | 229 } else { |
222 bool resourceless_software_draw = false; | 230 bool resourceless_software_draw = false; |
223 SetExternalDrawConstraints(cached_hw_transform_, | 231 SetExternalDrawConstraints(cached_hw_transform_, |
224 cached_hw_viewport_, | 232 cached_hw_viewport_, |
225 cached_hw_clip_, | 233 cached_hw_clip_, |
| 234 cached_hw_device_rect_for_tiling_, |
226 resourceless_software_draw); | 235 resourceless_software_draw); |
227 } | 236 } |
228 | 237 |
229 if (frame_holder_.get()) | 238 if (frame_holder_.get()) |
230 client_->DidSwapBuffersComplete(); | 239 client_->DidSwapBuffersComplete(); |
231 | 240 |
232 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 241 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
233 if (delegate) | 242 if (delegate) |
234 delegate->SetContinuousInvalidate(needs_begin_frame_); | 243 delegate->SetContinuousInvalidate(needs_begin_frame_); |
235 } | 244 } |
(...skipping 19 matching lines...) Expand all Loading... |
255 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 264 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
256 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 265 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
257 } | 266 } |
258 | 267 |
259 SynchronousCompositorOutputSurfaceDelegate* | 268 SynchronousCompositorOutputSurfaceDelegate* |
260 SynchronousCompositorOutputSurface::GetDelegate() { | 269 SynchronousCompositorOutputSurface::GetDelegate() { |
261 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 270 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
262 } | 271 } |
263 | 272 |
264 } // namespace content | 273 } // namespace content |
OLD | NEW |