| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), | 72 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), |
| 73 routing_id_(routing_id), | 73 routing_id_(routing_id), |
| 74 needs_begin_frame_(false), | 74 needs_begin_frame_(false), |
| 75 invoking_composite_(false), | 75 invoking_composite_(false), |
| 76 current_sw_canvas_(NULL), | 76 current_sw_canvas_(NULL), |
| 77 memory_policy_(0), | 77 memory_policy_(0), |
| 78 output_surface_client_(NULL) { | 78 output_surface_client_(NULL) { |
| 79 capabilities_.deferred_gl_initialization = true; | 79 capabilities_.deferred_gl_initialization = true; |
| 80 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 80 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| 81 capabilities_.adjust_deadline_for_parent = false; | 81 capabilities_.adjust_deadline_for_parent = false; |
| 82 if (IsDelegatedRendererEnabled()) { | 82 capabilities_.delegated_rendering = true; |
| 83 capabilities_.delegated_rendering = true; | 83 capabilities_.max_frames_pending = 1; |
| 84 capabilities_.max_frames_pending = 1; | |
| 85 } | |
| 86 // 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 |
| 87 // constructed on the correct thread. | 85 // constructed on the correct thread. |
| 88 | 86 |
| 89 memory_policy_.priority_cutoff_when_visible = | 87 memory_policy_.priority_cutoff_when_visible = |
| 90 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 88 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 91 } | 89 } |
| 92 | 90 |
| 93 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 91 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
| 94 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 95 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 93 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 DCHECK(CalledOnValidThread()); | 130 DCHECK(CalledOnValidThread()); |
| 133 needs_begin_frame_ = enable; | 131 needs_begin_frame_ = enable; |
| 134 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 132 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 135 if (delegate && !invoking_composite_) | 133 if (delegate && !invoking_composite_) |
| 136 delegate->SetContinuousInvalidate(needs_begin_frame_); | 134 delegate->SetContinuousInvalidate(needs_begin_frame_); |
| 137 } | 135 } |
| 138 | 136 |
| 139 void SynchronousCompositorOutputSurface::SwapBuffers( | 137 void SynchronousCompositorOutputSurface::SwapBuffers( |
| 140 cc::CompositorFrame* frame) { | 138 cc::CompositorFrame* frame) { |
| 141 DCHECK(CalledOnValidThread()); | 139 DCHECK(CalledOnValidThread()); |
| 142 if (!ForcedDrawToSoftwareDevice() && !IsDelegatedRendererEnabled()) { | |
| 143 DCHECK(context_provider_); | |
| 144 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | |
| 145 } | |
| 146 | 140 |
| 147 frame_holder_.reset(new cc::CompositorFrame); | 141 frame_holder_.reset(new cc::CompositorFrame); |
| 148 frame->AssignTo(frame_holder_.get()); | 142 frame->AssignTo(frame_holder_.get()); |
| 149 | 143 |
| 150 client_->DidSwapBuffers(); | 144 client_->DidSwapBuffers(); |
| 151 } | 145 } |
| 152 | 146 |
| 153 namespace { | 147 namespace { |
| 154 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { | 148 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { |
| 155 // CC's draw origin starts at the viewport. | 149 // CC's draw origin starts at the viewport. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 263 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 270 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 264 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 271 } | 265 } |
| 272 | 266 |
| 273 SynchronousCompositorOutputSurfaceDelegate* | 267 SynchronousCompositorOutputSurfaceDelegate* |
| 274 SynchronousCompositorOutputSurface::GetDelegate() { | 268 SynchronousCompositorOutputSurface::GetDelegate() { |
| 275 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 269 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 276 } | 270 } |
| 277 | 271 |
| 278 } // namespace content | 272 } // namespace content |
| OLD | NEW |