| 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/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/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/compositor_frame_ack.h" | 12 #include "cc/output/compositor_frame_ack.h" |
| 12 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 13 #include "cc/output/output_surface_client.h" | 14 #include "cc/output/output_surface_client.h" |
| 14 #include "cc/output/software_output_device.h" | 15 #include "cc/output/software_output_device.h" |
| 15 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 16 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 17 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 17 #include "content/public/browser/android/synchronous_compositor_client.h" | 18 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( | 85 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
| 85 int routing_id) | 86 int routing_id) |
| 86 : cc::OutputSurface( | 87 : cc::OutputSurface( |
| 87 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 88 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
| 88 routing_id_(routing_id), | 89 routing_id_(routing_id), |
| 89 needs_begin_frame_(false), | 90 needs_begin_frame_(false), |
| 90 did_swap_buffer_(false), | 91 did_swap_buffer_(false), |
| 91 current_sw_canvas_(NULL) { | 92 current_sw_canvas_(NULL) { |
| 92 capabilities_.deferred_gl_initialization = true; | 93 capabilities_.deferred_gl_initialization = true; |
| 94 capabilities_.has_parent_compositor = false; |
| 93 // Cannot call out to GetDelegate() here as the output surface is not | 95 // Cannot call out to GetDelegate() here as the output surface is not |
| 94 // constructed on the correct thread. | 96 // constructed on the correct thread. |
| 95 } | 97 } |
| 96 | 98 |
| 97 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 99 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
| 98 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 99 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 101 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 100 if (delegate) | 102 if (delegate) |
| 101 delegate->DidDestroySynchronousOutputSurface(this); | 103 delegate->DidDestroySynchronousOutputSurface(this); |
| 102 } | 104 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 214 |
| 213 current_sw_canvas_ = NULL; | 215 current_sw_canvas_ = NULL; |
| 214 return did_swap_buffer_; | 216 return did_swap_buffer_; |
| 215 } | 217 } |
| 216 | 218 |
| 217 void SynchronousCompositorOutputSurface::InvokeComposite( | 219 void SynchronousCompositorOutputSurface::InvokeComposite( |
| 218 gfx::Size damage_size) { | 220 gfx::Size damage_size) { |
| 219 did_swap_buffer_ = false; | 221 did_swap_buffer_ = false; |
| 220 SetNeedsRedrawRect(gfx::Rect(damage_size)); | 222 SetNeedsRedrawRect(gfx::Rect(damage_size)); |
| 221 if (needs_begin_frame_) | 223 if (needs_begin_frame_) |
| 222 BeginFrame(base::TimeTicks::Now()); | 224 BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |
| 223 | 225 |
| 224 if (did_swap_buffer_) | 226 if (did_swap_buffer_) |
| 225 OnSwapBuffersComplete(NULL); | 227 OnSwapBuffersComplete(NULL); |
| 226 } | 228 } |
| 227 | 229 |
| 228 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 230 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 229 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 231 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
| 230 // thread. | 232 // thread. |
| 231 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 233 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 232 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 234 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 233 } | 235 } |
| 234 | 236 |
| 235 SynchronousCompositorOutputSurfaceDelegate* | 237 SynchronousCompositorOutputSurfaceDelegate* |
| 236 SynchronousCompositorOutputSurface::GetDelegate() { | 238 SynchronousCompositorOutputSurface::GetDelegate() { |
| 237 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 239 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 238 } | 240 } |
| 239 | 241 |
| 240 } // namespace content | 242 } // namespace content |
| OLD | NEW |