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