OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "cc/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/debug/trace_event_argument.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" |
20 #include "cc/output/compositor_frame_ack.h" | 21 #include "cc/output/compositor_frame_ack.h" |
21 #include "cc/output/managed_memory_policy.h" | 22 #include "cc/output/managed_memory_policy.h" |
22 #include "cc/output/output_surface_client.h" | 23 #include "cc/output/output_surface_client.h" |
23 #include "cc/scheduler/delay_based_time_source.h" | 24 #include "cc/scheduler/delay_based_time_source.h" |
(...skipping 12 matching lines...) Expand all Loading... |
36 | 37 |
37 const size_t kGpuLatencyHistorySize = 60; | 38 const size_t kGpuLatencyHistorySize = 60; |
38 const double kGpuLatencyEstimationPercentile = 90.0; | 39 const double kGpuLatencyEstimationPercentile = 90.0; |
39 } | 40 } |
40 | 41 |
41 namespace cc { | 42 namespace cc { |
42 | 43 |
43 OutputSurface::OutputSurface( | 44 OutputSurface::OutputSurface( |
44 const scoped_refptr<ContextProvider>& context_provider) | 45 const scoped_refptr<ContextProvider>& context_provider) |
45 : client_(NULL), | 46 : client_(NULL), |
| 47 vsync_observer_(NULL), |
| 48 begin_frame_observer_(NULL), |
46 context_provider_(context_provider), | 49 context_provider_(context_provider), |
47 device_scale_factor_(-1), | 50 device_scale_factor_(-1), |
48 external_stencil_test_enabled_(false), | 51 external_stencil_test_enabled_(false), |
49 weak_ptr_factory_(this), | 52 weak_ptr_factory_(this), |
50 gpu_latency_history_(kGpuLatencyHistorySize) { | 53 gpu_latency_history_(kGpuLatencyHistorySize) { |
51 } | 54 } |
52 | 55 |
53 OutputSurface::OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) | 56 OutputSurface::OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) |
54 : client_(NULL), | 57 : client_(NULL), |
| 58 vsync_observer_(NULL), |
| 59 begin_frame_observer_(NULL), |
55 software_device_(software_device.Pass()), | 60 software_device_(software_device.Pass()), |
56 device_scale_factor_(-1), | 61 device_scale_factor_(-1), |
57 external_stencil_test_enabled_(false), | 62 external_stencil_test_enabled_(false), |
58 weak_ptr_factory_(this), | 63 weak_ptr_factory_(this), |
59 gpu_latency_history_(kGpuLatencyHistorySize) { | 64 gpu_latency_history_(kGpuLatencyHistorySize) { |
60 } | 65 } |
61 | 66 |
62 OutputSurface::OutputSurface( | 67 OutputSurface::OutputSurface( |
63 const scoped_refptr<ContextProvider>& context_provider, | 68 const scoped_refptr<ContextProvider>& context_provider, |
64 scoped_ptr<SoftwareOutputDevice> software_device) | 69 scoped_ptr<SoftwareOutputDevice> software_device) |
65 : client_(NULL), | 70 : client_(NULL), |
| 71 vsync_observer_(NULL), |
| 72 begin_frame_observer_(NULL), |
66 context_provider_(context_provider), | 73 context_provider_(context_provider), |
67 software_device_(software_device.Pass()), | 74 software_device_(software_device.Pass()), |
68 device_scale_factor_(-1), | 75 device_scale_factor_(-1), |
69 external_stencil_test_enabled_(false), | 76 external_stencil_test_enabled_(false), |
70 weak_ptr_factory_(this), | 77 weak_ptr_factory_(this), |
71 gpu_latency_history_(kGpuLatencyHistorySize) { | 78 gpu_latency_history_(kGpuLatencyHistorySize) { |
72 } | 79 } |
73 | 80 |
74 void OutputSurface::CommitVSyncParameters(base::TimeTicks timebase, | 81 void OutputSurface::CommitVSyncParameters(base::TimeTicks timebase, |
75 base::TimeDelta interval) { | 82 base::TimeDelta interval) { |
76 TRACE_EVENT2("cc", | 83 TRACE_EVENT2("cc", |
77 "OutputSurface::CommitVSyncParameters", | 84 "OutputSurface::CommitVSyncParameters", |
78 "timebase", | 85 "timebase", |
79 (timebase - base::TimeTicks()).InSecondsF(), | 86 (timebase - base::TimeTicks()).InSecondsF(), |
80 "interval", | 87 "interval", |
81 interval.InSecondsF()); | 88 interval.InSecondsF()); |
82 client_->CommitVSyncParameters(timebase, interval); | 89 if (vsync_observer_) |
| 90 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); |
| 91 } |
| 92 |
| 93 void OutputSurface::SetNeedsBeginFrames(bool needs_begin_frames) { |
| 94 needs_begin_frames_ = needs_begin_frames; |
| 95 } |
| 96 bool OutputSurface::NeedsBeginFrames() const { |
| 97 return needs_begin_frames_; |
| 98 } |
| 99 void OutputSurface::AsValueInto(base::debug::TracedValue* dict) const { |
| 100 dict->SetString("type", "OutputSurface"); |
83 } | 101 } |
84 | 102 |
85 // Forwarded to OutputSurfaceClient | 103 // Forwarded to OutputSurfaceClient |
86 void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 104 void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
87 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect"); | 105 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect"); |
88 client_->SetNeedsRedrawRect(damage_rect); | 106 client_->SetNeedsRedrawRect(damage_rect); |
89 } | 107 } |
90 | 108 |
91 void OutputSurface::ReclaimResources(const CompositorFrameAck* ack) { | 109 void OutputSurface::ReclaimResources(const CompositorFrameAck* ack) { |
92 client_->ReclaimResources(ack); | 110 client_->ReclaimResources(ack); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", | 378 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", |
361 "bytes_limit_when_visible", policy.bytes_limit_when_visible); | 379 "bytes_limit_when_visible", policy.bytes_limit_when_visible); |
362 // Just ignore the memory manager when it says to set the limit to zero | 380 // Just ignore the memory manager when it says to set the limit to zero |
363 // bytes. This will happen when the memory manager thinks that the renderer | 381 // bytes. This will happen when the memory manager thinks that the renderer |
364 // is not visible (which the renderer knows better). | 382 // is not visible (which the renderer knows better). |
365 if (policy.bytes_limit_when_visible) | 383 if (policy.bytes_limit_when_visible) |
366 client_->SetMemoryPolicy(policy); | 384 client_->SetMemoryPolicy(policy); |
367 } | 385 } |
368 | 386 |
369 } // namespace cc | 387 } // namespace cc |
OLD | NEW |