| 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" |  | 
| 10 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" | 
| 11 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" | 
| 12 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" | 
| 13 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" | 
| 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 
| 15 #include "content/browser/gpu/compositor_util.h" | 14 #include "content/browser/gpu/compositor_util.h" | 
| 16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" | 
| 17 #include "content/renderer/gpu/frame_swap_message_queue.h" | 16 #include "content/renderer/gpu/frame_swap_message_queue.h" | 
| 18 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" | 
| 19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 18 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 66 | 65 | 
| 67   DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 66   DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); | 
| 68 }; | 67 }; | 
| 69 | 68 | 
| 70 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 69 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 
| 71     int routing_id, | 70     int routing_id, | 
| 72     scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | 71     scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) | 
| 73     : cc::OutputSurface( | 72     : cc::OutputSurface( | 
| 74           scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 73           scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 
| 75       routing_id_(routing_id), | 74       routing_id_(routing_id), | 
| 76       needs_begin_frame_(false), |  | 
| 77       invoking_composite_(false), |  | 
| 78       current_sw_canvas_(NULL), | 75       current_sw_canvas_(NULL), | 
| 79       memory_policy_(0), | 76       memory_policy_(0), | 
| 80       output_surface_client_(NULL), | 77       output_surface_client_(NULL), | 
| 81       frame_swap_message_queue_(frame_swap_message_queue) { | 78       frame_swap_message_queue_(frame_swap_message_queue) { | 
| 82   capabilities_.deferred_gl_initialization = true; | 79   capabilities_.deferred_gl_initialization = true; | 
| 83   capabilities_.draw_and_swap_full_viewport_every_frame = true; | 80   capabilities_.draw_and_swap_full_viewport_every_frame = true; | 
| 84   capabilities_.adjust_deadline_for_parent = false; | 81   capabilities_.adjust_deadline_for_parent = false; | 
| 85   capabilities_.delegated_rendering = true; | 82   capabilities_.delegated_rendering = true; | 
| 86   capabilities_.max_frames_pending = 1; | 83   capabilities_.max_frames_pending = 1; | 
| 87   // Cannot call out to GetDelegate() here as the output surface is not | 84   // Cannot call out to GetDelegate() here as the output surface is not | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 114     delegate->DidBindOutputSurface(this); | 111     delegate->DidBindOutputSurface(this); | 
| 115 | 112 | 
| 116   return true; | 113   return true; | 
| 117 } | 114 } | 
| 118 | 115 | 
| 119 void SynchronousCompositorOutputSurface::Reshape( | 116 void SynchronousCompositorOutputSurface::Reshape( | 
| 120     const gfx::Size& size, float scale_factor) { | 117     const gfx::Size& size, float scale_factor) { | 
| 121   // Intentional no-op: surface size is controlled by the embedder. | 118   // Intentional no-op: surface size is controlled by the embedder. | 
| 122 } | 119 } | 
| 123 | 120 | 
| 124 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |  | 
| 125   DCHECK(CalledOnValidThread()); |  | 
| 126   needs_begin_frame_ = enable; |  | 
| 127   SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |  | 
| 128   if (delegate && !invoking_composite_) |  | 
| 129     delegate->SetContinuousInvalidate(needs_begin_frame_); |  | 
| 130 } |  | 
| 131 |  | 
| 132 void SynchronousCompositorOutputSurface::SwapBuffers( | 121 void SynchronousCompositorOutputSurface::SwapBuffers( | 
| 133     cc::CompositorFrame* frame) { | 122     cc::CompositorFrame* frame) { | 
| 134   DCHECK(CalledOnValidThread()); | 123   DCHECK(CalledOnValidThread()); | 
| 135 | 124 | 
| 136   frame_holder_.reset(new cc::CompositorFrame); | 125   frame_holder_.reset(new cc::CompositorFrame); | 
| 137   frame->AssignTo(frame_holder_.get()); | 126   frame->AssignTo(frame_holder_.get()); | 
| 138 | 127 | 
| 139   client_->DidSwapBuffers(); | 128   client_->DidSwapBuffers(); | 
| 140 } | 129 } | 
| 141 | 130 | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213   return frame_holder_.Pass(); | 202   return frame_holder_.Pass(); | 
| 214 } | 203 } | 
| 215 | 204 | 
| 216 void SynchronousCompositorOutputSurface::InvokeComposite( | 205 void SynchronousCompositorOutputSurface::InvokeComposite( | 
| 217     const gfx::Transform& transform, | 206     const gfx::Transform& transform, | 
| 218     gfx::Rect viewport, | 207     gfx::Rect viewport, | 
| 219     gfx::Rect clip, | 208     gfx::Rect clip, | 
| 220     gfx::Rect viewport_rect_for_tile_priority, | 209     gfx::Rect viewport_rect_for_tile_priority, | 
| 221     gfx::Transform transform_for_tile_priority, | 210     gfx::Transform transform_for_tile_priority, | 
| 222     bool hardware_draw) { | 211     bool hardware_draw) { | 
| 223   DCHECK(!invoking_composite_); |  | 
| 224   DCHECK(!frame_holder_.get()); | 212   DCHECK(!frame_holder_.get()); | 
| 225   base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); |  | 
| 226 | 213 | 
| 227   gfx::Transform adjusted_transform = transform; | 214   gfx::Transform adjusted_transform = transform; | 
| 228   AdjustTransform(&adjusted_transform, viewport); | 215   AdjustTransform(&adjusted_transform, viewport); | 
| 229   SetExternalDrawConstraints(adjusted_transform, | 216   SetExternalDrawConstraints(adjusted_transform, | 
| 230                              viewport, | 217                              viewport, | 
| 231                              clip, | 218                              clip, | 
| 232                              viewport_rect_for_tile_priority, | 219                              viewport_rect_for_tile_priority, | 
| 233                              transform_for_tile_priority, | 220                              transform_for_tile_priority, | 
| 234                              !hardware_draw); | 221                              !hardware_draw); | 
| 235   SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 222   SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 
| 236   client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |  | 
| 237 | 223 | 
| 238   // After software draws (which might move the viewport arbitrarily), restore | 224   // After software draws (which might move the viewport arbitrarily), restore | 
| 239   // the previous hardware viewport to allow CC's tile manager to prioritize | 225   // the previous hardware viewport to allow CC's tile manager to prioritize | 
| 240   // properly. | 226   // properly. | 
| 241   if (hardware_draw) { | 227   if (hardware_draw) { | 
| 242     cached_hw_transform_ = adjusted_transform; | 228     cached_hw_transform_ = adjusted_transform; | 
| 243     cached_hw_viewport_ = viewport; | 229     cached_hw_viewport_ = viewport; | 
| 244     cached_hw_clip_ = clip; | 230     cached_hw_clip_ = clip; | 
| 245     cached_hw_viewport_rect_for_tile_priority_ = | 231     cached_hw_viewport_rect_for_tile_priority_ = | 
| 246         viewport_rect_for_tile_priority; | 232         viewport_rect_for_tile_priority; | 
| 247     cached_hw_transform_for_tile_priority_ = transform_for_tile_priority; | 233     cached_hw_transform_for_tile_priority_ = transform_for_tile_priority; | 
| 248   } else { | 234   } else { | 
| 249     bool resourceless_software_draw = false; | 235     bool resourceless_software_draw = false; | 
| 250     SetExternalDrawConstraints(cached_hw_transform_, | 236     SetExternalDrawConstraints(cached_hw_transform_, | 
| 251                                cached_hw_viewport_, | 237                                cached_hw_viewport_, | 
| 252                                cached_hw_clip_, | 238                                cached_hw_clip_, | 
| 253                                cached_hw_viewport_rect_for_tile_priority_, | 239                                cached_hw_viewport_rect_for_tile_priority_, | 
| 254                                cached_hw_transform_for_tile_priority_, | 240                                cached_hw_transform_for_tile_priority_, | 
| 255                                resourceless_software_draw); | 241                                resourceless_software_draw); | 
| 256   } | 242   } | 
| 257 | 243 | 
| 258   if (frame_holder_.get()) | 244   if (frame_holder_.get()) | 
| 259     client_->DidSwapBuffersComplete(); | 245     client_->DidSwapBuffersComplete(); | 
| 260 |  | 
| 261   SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |  | 
| 262   if (delegate) |  | 
| 263     delegate->SetContinuousInvalidate(needs_begin_frame_); |  | 
| 264 } | 246 } | 
| 265 | 247 | 
| 266 void SynchronousCompositorOutputSurface::ReturnResources( | 248 void SynchronousCompositorOutputSurface::ReturnResources( | 
| 267     const cc::CompositorFrameAck& frame_ack) { | 249     const cc::CompositorFrameAck& frame_ack) { | 
| 268   ReclaimResources(&frame_ack); | 250   ReclaimResources(&frame_ack); | 
| 269 } | 251 } | 
| 270 | 252 | 
| 271 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 253 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 
| 272     const SynchronousCompositorMemoryPolicy& policy) { | 254     const SynchronousCompositorMemoryPolicy& policy) { | 
| 273   DCHECK(CalledOnValidThread()); | 255   DCHECK(CalledOnValidThread()); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 292 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 274 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 
| 293   return BrowserThread::CurrentlyOn(BrowserThread::UI); | 275   return BrowserThread::CurrentlyOn(BrowserThread::UI); | 
| 294 } | 276 } | 
| 295 | 277 | 
| 296 SynchronousCompositorOutputSurfaceDelegate* | 278 SynchronousCompositorOutputSurfaceDelegate* | 
| 297 SynchronousCompositorOutputSurface::GetDelegate() { | 279 SynchronousCompositorOutputSurface::GetDelegate() { | 
| 298   return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 280   return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 
| 299 } | 281 } | 
| 300 | 282 | 
| 301 }  // namespace content | 283 }  // namespace content | 
| OLD | NEW | 
|---|