| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/browser_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | 33 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
| 34 : OutputSurface(software_device.Pass()), | 34 : OutputSurface(software_device.Pass()), |
| 35 surface_id_(surface_id), | 35 surface_id_(surface_id), |
| 36 output_surface_map_(output_surface_map), | 36 output_surface_map_(output_surface_map), |
| 37 vsync_manager_(vsync_manager) { | 37 vsync_manager_(vsync_manager) { |
| 38 Initialize(); | 38 Initialize(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 41 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
| 42 DCHECK(CalledOnValidThread()); | 42 DCHECK(CalledOnValidThread()); |
| 43 if (reflector_) |
| 44 reflector_->DetachFromOutputSurface(); |
| 45 DCHECK(!reflector_); |
| 43 if (!HasClient()) | 46 if (!HasClient()) |
| 44 return; | 47 return; |
| 45 output_surface_map_->Remove(surface_id_); | 48 output_surface_map_->Remove(surface_id_); |
| 46 vsync_manager_->RemoveObserver(this); | 49 vsync_manager_->RemoveObserver(this); |
| 47 } | 50 } |
| 48 | 51 |
| 49 void BrowserCompositorOutputSurface::Initialize() { | 52 void BrowserCompositorOutputSurface::Initialize() { |
| 50 capabilities_.max_frames_pending = 1; | 53 capabilities_.max_frames_pending = 1; |
| 51 capabilities_.adjust_deadline_for_parent = false; | 54 capabilities_.adjust_deadline_for_parent = false; |
| 52 | 55 |
| 53 DetachFromThread(); | 56 DetachFromThread(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 bool BrowserCompositorOutputSurface::BindToClient( | 59 bool BrowserCompositorOutputSurface::BindToClient( |
| 57 cc::OutputSurfaceClient* client) { | 60 cc::OutputSurfaceClient* client) { |
| 58 DCHECK(CalledOnValidThread()); | 61 DCHECK(CalledOnValidThread()); |
| 59 | 62 |
| 60 if (!OutputSurface::BindToClient(client)) | 63 if (!OutputSurface::BindToClient(client)) |
| 61 return false; | 64 return false; |
| 62 | 65 |
| 63 output_surface_map_->AddWithID(this, surface_id_); | 66 output_surface_map_->AddWithID(this, surface_id_); |
| 64 if (reflector_) | 67 if (reflector_) |
| 65 reflector_->OnSourceSurfaceReady(surface_id_); | 68 reflector_->OnSourceSurfaceReady(this); |
| 66 vsync_manager_->AddObserver(this); | 69 vsync_manager_->AddObserver(this); |
| 67 return true; | 70 return true; |
| 68 } | 71 } |
| 69 | 72 |
| 70 void BrowserCompositorOutputSurface::Reshape(const gfx::Size& size, | |
| 71 float scale_factor) { | |
| 72 OutputSurface::Reshape(size, scale_factor); | |
| 73 if (reflector_.get()) | |
| 74 reflector_->OnReshape(size); | |
| 75 } | |
| 76 | |
| 77 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( | 73 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( |
| 78 base::TimeTicks timebase, | 74 base::TimeTicks timebase, |
| 79 base::TimeDelta interval) { | 75 base::TimeDelta interval) { |
| 80 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
| 81 DCHECK(HasClient()); | 77 DCHECK(HasClient()); |
| 82 CommitVSyncParameters(timebase, interval); | 78 CommitVSyncParameters(timebase, interval); |
| 83 } | 79 } |
| 84 | 80 |
| 85 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | 81 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
| 86 base::TimeTicks timebase, | 82 base::TimeTicks timebase, |
| 87 base::TimeDelta interval) { | 83 base::TimeDelta interval) { |
| 88 DCHECK(CalledOnValidThread()); | 84 DCHECK(CalledOnValidThread()); |
| 89 DCHECK(HasClient()); | 85 DCHECK(HasClient()); |
| 90 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 86 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { | 89 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { |
| 94 reflector_ = reflector; | 90 reflector_ = reflector; |
| 95 } | 91 } |
| 96 | 92 |
| 97 } // namespace content | 93 } // namespace content |
| OLD | NEW |