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" |
11 #include "content/common/gpu/client/context_provider_command_buffer.h" | 11 #include "content/common/gpu/client/context_provider_command_buffer.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 15 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
16 const scoped_refptr<cc::ContextProvider>& context_provider, | 16 const scoped_refptr<cc::ContextProvider>& context_provider) |
17 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | |
18 : OutputSurface(context_provider), | 17 : OutputSurface(context_provider), |
19 vsync_manager_(vsync_manager), | |
20 reflector_(nullptr) { | 18 reflector_(nullptr) { |
21 Initialize(); | 19 Initialize(); |
22 } | 20 } |
23 | 21 |
24 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
25 scoped_ptr<cc::SoftwareOutputDevice> software_device, | 23 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
26 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | |
27 : OutputSurface(software_device.Pass()), | 24 : OutputSurface(software_device.Pass()), |
28 vsync_manager_(vsync_manager), | |
29 reflector_(nullptr) { | 25 reflector_(nullptr) { |
30 Initialize(); | 26 Initialize(); |
31 } | 27 } |
32 | 28 |
33 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 29 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
34 if (reflector_) | 30 if (reflector_) |
35 reflector_->DetachFromOutputSurface(); | 31 reflector_->DetachFromOutputSurface(); |
36 DCHECK(!reflector_); | 32 DCHECK(!reflector_); |
37 if (!HasClient()) | 33 if (!HasClient()) |
brianderson
2015/03/02 22:38:16
This if can be removed now.
simonhong
2015/03/03 22:54:12
Done.
| |
38 return; | 34 return; |
39 vsync_manager_->RemoveObserver(this); | |
40 } | 35 } |
41 | 36 |
42 void BrowserCompositorOutputSurface::Initialize() { | 37 void BrowserCompositorOutputSurface::Initialize() { |
43 capabilities_.max_frames_pending = 1; | 38 capabilities_.max_frames_pending = 1; |
44 capabilities_.adjust_deadline_for_parent = false; | 39 capabilities_.adjust_deadline_for_parent = false; |
45 } | 40 } |
46 | 41 |
47 bool BrowserCompositorOutputSurface::BindToClient( | 42 bool BrowserCompositorOutputSurface::BindToClient( |
48 cc::OutputSurfaceClient* client) { | 43 cc::OutputSurfaceClient* client) { |
49 if (!OutputSurface::BindToClient(client)) | 44 if (!OutputSurface::BindToClient(client)) |
50 return false; | 45 return false; |
51 // Don't want vsync notifications until there is a client. | 46 // Don't want vsync notifications until there is a client. |
brianderson
2015/03/02 22:38:16
This comment can be removed.
simonhong
2015/03/03 22:54:12
Done.
| |
52 vsync_manager_->AddObserver(this); | |
53 return true; | 47 return true; |
54 } | 48 } |
55 | 49 |
56 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( | 50 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
57 base::TimeTicks timebase, | 51 base::TimeTicks timebase, |
58 base::TimeDelta interval) { | 52 base::TimeDelta interval) { |
59 DCHECK(HasClient()); | 53 DCHECK(HasClient()); |
60 CommitVSyncParameters(timebase, interval); | 54 CommitVSyncParameters(timebase, interval); |
61 } | 55 } |
62 | 56 |
63 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | |
64 base::TimeTicks timebase, | |
65 base::TimeDelta interval) { | |
66 DCHECK(HasClient()); | |
67 vsync_manager_->UpdateVSyncParameters(timebase, interval); | |
68 } | |
69 | |
70 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { | 57 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { |
71 reflector_ = reflector; | 58 reflector_ = reflector; |
72 } | 59 } |
73 | 60 |
74 } // namespace content | 61 } // namespace content |
OLD | NEW |