| 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), | 75 invoking_composite_(false), |
| 78 current_sw_canvas_(NULL), | 76 current_sw_canvas_(NULL), |
| 79 memory_policy_(0), | 77 memory_policy_(0), |
| 80 output_surface_client_(NULL), | 78 output_surface_client_(NULL), |
| 81 frame_swap_message_queue_(frame_swap_message_queue) { | 79 frame_swap_message_queue_(frame_swap_message_queue) { |
| 82 capabilities_.deferred_gl_initialization = true; | 80 capabilities_.deferred_gl_initialization = true; |
| 83 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 81 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| 84 capabilities_.adjust_deadline_for_parent = false; | 82 capabilities_.adjust_deadline_for_parent = false; |
| 85 capabilities_.delegated_rendering = true; | 83 capabilities_.delegated_rendering = true; |
| 86 capabilities_.max_frames_pending = 1; | 84 capabilities_.max_frames_pending = 1; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 delegate->DidBindOutputSurface(this); | 112 delegate->DidBindOutputSurface(this); |
| 115 | 113 |
| 116 return true; | 114 return true; |
| 117 } | 115 } |
| 118 | 116 |
| 119 void SynchronousCompositorOutputSurface::Reshape( | 117 void SynchronousCompositorOutputSurface::Reshape( |
| 120 const gfx::Size& size, float scale_factor) { | 118 const gfx::Size& size, float scale_factor) { |
| 121 // Intentional no-op: surface size is controlled by the embedder. | 119 // Intentional no-op: surface size is controlled by the embedder. |
| 122 } | 120 } |
| 123 | 121 |
| 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( | 122 void SynchronousCompositorOutputSurface::SwapBuffers( |
| 133 cc::CompositorFrame* frame) { | 123 cc::CompositorFrame* frame) { |
| 134 DCHECK(CalledOnValidThread()); | 124 DCHECK(CalledOnValidThread()); |
| 135 | 125 |
| 136 frame_holder_.reset(new cc::CompositorFrame); | 126 frame_holder_.reset(new cc::CompositorFrame); |
| 137 frame->AssignTo(frame_holder_.get()); | 127 frame->AssignTo(frame_holder_.get()); |
| 138 | 128 |
| 139 client_->DidSwapBuffers(); | 129 client_->DidSwapBuffers(); |
| 140 } | 130 } |
| 141 | 131 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 216 |
| 227 gfx::Transform adjusted_transform = transform; | 217 gfx::Transform adjusted_transform = transform; |
| 228 AdjustTransform(&adjusted_transform, viewport); | 218 AdjustTransform(&adjusted_transform, viewport); |
| 229 SetExternalDrawConstraints(adjusted_transform, | 219 SetExternalDrawConstraints(adjusted_transform, |
| 230 viewport, | 220 viewport, |
| 231 clip, | 221 clip, |
| 232 viewport_rect_for_tile_priority, | 222 viewport_rect_for_tile_priority, |
| 233 transform_for_tile_priority, | 223 transform_for_tile_priority, |
| 234 !hardware_draw); | 224 !hardware_draw); |
| 235 SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 225 SetNeedsRedrawRect(gfx::Rect(viewport.size())); |
| 236 client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); | 226 |
| 227 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 228 if (delegate) |
| 229 delegate->BeginFrame(); |
| 237 | 230 |
| 238 // After software draws (which might move the viewport arbitrarily), restore | 231 // After software draws (which might move the viewport arbitrarily), restore |
| 239 // the previous hardware viewport to allow CC's tile manager to prioritize | 232 // the previous hardware viewport to allow CC's tile manager to prioritize |
| 240 // properly. | 233 // properly. |
| 241 if (hardware_draw) { | 234 if (hardware_draw) { |
| 242 cached_hw_transform_ = adjusted_transform; | 235 cached_hw_transform_ = adjusted_transform; |
| 243 cached_hw_viewport_ = viewport; | 236 cached_hw_viewport_ = viewport; |
| 244 cached_hw_clip_ = clip; | 237 cached_hw_clip_ = clip; |
| 245 cached_hw_viewport_rect_for_tile_priority_ = | 238 cached_hw_viewport_rect_for_tile_priority_ = |
| 246 viewport_rect_for_tile_priority; | 239 viewport_rect_for_tile_priority; |
| 247 cached_hw_transform_for_tile_priority_ = transform_for_tile_priority; | 240 cached_hw_transform_for_tile_priority_ = transform_for_tile_priority; |
| 248 } else { | 241 } else { |
| 249 bool resourceless_software_draw = false; | 242 bool resourceless_software_draw = false; |
| 250 SetExternalDrawConstraints(cached_hw_transform_, | 243 SetExternalDrawConstraints(cached_hw_transform_, |
| 251 cached_hw_viewport_, | 244 cached_hw_viewport_, |
| 252 cached_hw_clip_, | 245 cached_hw_clip_, |
| 253 cached_hw_viewport_rect_for_tile_priority_, | 246 cached_hw_viewport_rect_for_tile_priority_, |
| 254 cached_hw_transform_for_tile_priority_, | 247 cached_hw_transform_for_tile_priority_, |
| 255 resourceless_software_draw); | 248 resourceless_software_draw); |
| 256 } | 249 } |
| 257 | 250 |
| 258 if (frame_holder_.get()) | 251 if (frame_holder_.get()) |
| 259 client_->DidSwapBuffersComplete(); | 252 client_->DidSwapBuffersComplete(); |
| 260 | 253 |
| 261 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | |
| 262 if (delegate) | 254 if (delegate) |
| 263 delegate->SetContinuousInvalidate(needs_begin_frame_); | 255 delegate->UpdateContinuousInvalidate(); |
| 264 } | 256 } |
| 265 | 257 |
| 266 void SynchronousCompositorOutputSurface::ReturnResources( | 258 void SynchronousCompositorOutputSurface::ReturnResources( |
| 267 const cc::CompositorFrameAck& frame_ack) { | 259 const cc::CompositorFrameAck& frame_ack) { |
| 268 ReclaimResources(&frame_ack); | 260 ReclaimResources(&frame_ack); |
| 269 } | 261 } |
| 270 | 262 |
| 271 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 263 void SynchronousCompositorOutputSurface::SetMemoryPolicy( |
| 272 const SynchronousCompositorMemoryPolicy& policy) { | 264 const SynchronousCompositorMemoryPolicy& policy) { |
| 273 DCHECK(CalledOnValidThread()); | 265 DCHECK(CalledOnValidThread()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 292 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 284 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 293 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 285 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 294 } | 286 } |
| 295 | 287 |
| 296 SynchronousCompositorOutputSurfaceDelegate* | 288 SynchronousCompositorOutputSurfaceDelegate* |
| 297 SynchronousCompositorOutputSurface::GetDelegate() { | 289 SynchronousCompositorOutputSurface::GetDelegate() { |
| 298 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 290 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 299 } | 291 } |
| 300 | 292 |
| 301 } // namespace content | 293 } // namespace content |
| OLD | NEW |