| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "content/browser/compositor/reflector_impl.h" | 10 #include "content/browser/compositor/reflector_impl.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | 31 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
| 32 : OutputSurface(software_device.Pass()), | 32 : OutputSurface(software_device.Pass()), |
| 33 surface_id_(surface_id), | 33 surface_id_(surface_id), |
| 34 output_surface_map_(output_surface_map), | 34 output_surface_map_(output_surface_map), |
| 35 vsync_manager_(vsync_manager) { | 35 vsync_manager_(vsync_manager) { |
| 36 Initialize(); | 36 Initialize(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 39 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
| 40 DCHECK(CalledOnValidThread()); | 40 DCHECK(CalledOnValidThread()); |
| 41 if (reflector_) | 41 if (reflector_.get()) |
| 42 reflector_->DetachFromOutputSurface(); | 42 reflector_->DetachFromOutputSurface(); |
| 43 DCHECK(!reflector_); | 43 DCHECK(!reflector_.get()); |
| 44 if (!HasClient()) | 44 if (!HasClient()) |
| 45 return; | 45 return; |
| 46 output_surface_map_->Remove(surface_id_); | 46 output_surface_map_->Remove(surface_id_); |
| 47 vsync_manager_->RemoveObserver(this); | 47 vsync_manager_->RemoveObserver(this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void BrowserCompositorOutputSurface::Initialize() { | 50 void BrowserCompositorOutputSurface::Initialize() { |
| 51 capabilities_.max_frames_pending = 1; | 51 capabilities_.max_frames_pending = 1; |
| 52 capabilities_.adjust_deadline_for_parent = false; | 52 capabilities_.adjust_deadline_for_parent = false; |
| 53 | 53 |
| 54 DetachFromThread(); | 54 DetachFromThread(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool BrowserCompositorOutputSurface::BindToClient( | 57 bool BrowserCompositorOutputSurface::BindToClient( |
| 58 cc::OutputSurfaceClient* client) { | 58 cc::OutputSurfaceClient* client) { |
| 59 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
| 60 | 60 |
| 61 if (!OutputSurface::BindToClient(client)) | 61 if (!OutputSurface::BindToClient(client)) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 output_surface_map_->AddWithID(this, surface_id_); | 64 output_surface_map_->AddWithID(this, surface_id_); |
| 65 if (reflector_) | 65 if (reflector_.get()) |
| 66 reflector_->OnSourceSurfaceReady(this); | 66 reflector_->OnSourceSurfaceReady(this); |
| 67 vsync_manager_->AddObserver(this); | 67 vsync_manager_->AddObserver(this); |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void BrowserCompositorOutputSurface::OnSwapBuffersComplete() { | 71 void BrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
| 72 // On Mac, delay acknowledging the swap to the output surface client until | 72 // On Mac, delay acknowledging the swap to the output surface client until |
| 73 // it has been drawn. | 73 // it has been drawn. |
| 74 #if !defined(OS_MACOSX) | 74 #if !defined(OS_MACOSX) |
| 75 cc::OutputSurface::OnSwapBuffersComplete(); | 75 cc::OutputSurface::OnSwapBuffersComplete(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 96 reflector_ = reflector; | 96 reflector_ = reflector; |
| 97 } | 97 } |
| 98 | 98 |
| 99 #if defined(OS_MACOSX) | 99 #if defined(OS_MACOSX) |
| 100 void BrowserCompositorOutputSurface::OnSurfaceDisplayed() { | 100 void BrowserCompositorOutputSurface::OnSurfaceDisplayed() { |
| 101 cc::OutputSurface::OnSwapBuffersComplete(); | 101 cc::OutputSurface::OnSwapBuffersComplete(); |
| 102 } | 102 } |
| 103 #endif | 103 #endif |
| 104 | 104 |
| 105 } // namespace content | 105 } // namespace content |
| OLD | NEW |