| 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/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 frame_swap_message_queue_(frame_swap_message_queue) { | 76 frame_swap_message_queue_(frame_swap_message_queue) { |
| 77 capabilities_.draw_and_swap_full_viewport_every_frame = true; | 77 capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| 78 capabilities_.adjust_deadline_for_parent = false; | 78 capabilities_.adjust_deadline_for_parent = false; |
| 79 capabilities_.delegated_rendering = true; | 79 capabilities_.delegated_rendering = true; |
| 80 capabilities_.max_frames_pending = 1; | 80 capabilities_.max_frames_pending = 1; |
| 81 memory_policy_.priority_cutoff_when_visible = | 81 memory_policy_.priority_cutoff_when_visible = |
| 82 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 82 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 83 } | 83 } |
| 84 | 84 |
| 85 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 85 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
| 86 DCHECK(CalledOnValidThread()); |
| 87 if (registered_) { |
| 88 SynchronousCompositorRegistry::GetInstance()->UnregisterOutputSurface( |
| 89 routing_id_, this); |
| 90 } |
| 86 } | 91 } |
| 87 | 92 |
| 88 bool SynchronousCompositorOutputSurface::BindToClient( | 93 bool SynchronousCompositorOutputSurface::BindToClient( |
| 89 cc::OutputSurfaceClient* surface_client) { | 94 cc::OutputSurfaceClient* surface_client) { |
| 90 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
| 91 if (!cc::OutputSurface::BindToClient(surface_client)) | 96 if (!cc::OutputSurface::BindToClient(surface_client)) |
| 92 return false; | 97 return false; |
| 93 | 98 |
| 94 client_->SetMemoryPolicy(memory_policy_); | 99 client_->SetMemoryPolicy(memory_policy_); |
| 95 | 100 |
| 96 SynchronousCompositorRegistry::GetInstance()->RegisterOutputSurface( | 101 SynchronousCompositorRegistry::GetInstance()->RegisterOutputSurface( |
| 97 routing_id_, this); | 102 routing_id_, this); |
| 98 registered_ = true; | 103 registered_ = true; |
| 99 | 104 |
| 100 return true; | 105 return true; |
| 101 } | 106 } |
| 102 | 107 |
| 103 void SynchronousCompositorOutputSurface::DetachFromClient() { | |
| 104 DCHECK(CalledOnValidThread()); | |
| 105 if (registered_) { | |
| 106 SynchronousCompositorRegistry::GetInstance()->UnregisterOutputSurface( | |
| 107 routing_id_, this); | |
| 108 } | |
| 109 cc::OutputSurface::DetachFromClient(); | |
| 110 } | |
| 111 | |
| 112 void SynchronousCompositorOutputSurface::SetCompositor( | 108 void SynchronousCompositorOutputSurface::SetCompositor( |
| 113 SynchronousCompositorImpl* compositor) { | 109 SynchronousCompositorImpl* compositor) { |
| 114 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
| 115 compositor_ = compositor; | 111 compositor_ = compositor; |
| 116 } | 112 } |
| 117 | 113 |
| 118 void SynchronousCompositorOutputSurface::Reshape( | 114 void SynchronousCompositorOutputSurface::Reshape( |
| 119 const gfx::Size& size, float scale_factor) { | 115 const gfx::Size& size, float scale_factor) { |
| 120 // Intentional no-op: surface size is controlled by the embedder. | 116 // Intentional no-op: surface size is controlled by the embedder. |
| 121 } | 117 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 279 } |
| 284 | 280 |
| 285 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 281 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 286 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 282 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
| 287 // thread. | 283 // thread. |
| 288 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 284 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 289 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 285 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 290 } | 286 } |
| 291 | 287 |
| 292 } // namespace content | 288 } // namespace content |
| OLD | NEW |