OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "config.h" | 5 #include "config.h" |
6 #include "ThrottledTextureUploader.h" | 6 #include "ThrottledTextureUploader.h" |
7 | 7 |
8 #include "Extensions3DChromium.h" | 8 #include "Extensions3DChromium.h" |
9 #include "TraceEvent.h" | 9 #include "TraceEvent.h" |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 { | 106 { |
107 for (Deque<OwnPtr<Query> >::iterator it = m_pendingQueries.begin(); | 107 for (Deque<OwnPtr<Query> >::iterator it = m_pendingQueries.begin(); |
108 it != m_pendingQueries.end(); ++it) { | 108 it != m_pendingQueries.end(); ++it) { |
109 if (it->get()->isNonBlocking()) | 109 if (it->get()->isNonBlocking()) |
110 continue; | 110 continue; |
111 | 111 |
112 m_numBlockingTextureUploads--; | 112 m_numBlockingTextureUploads--; |
113 it->get()->markAsNonBlocking(); | 113 it->get()->markAsNonBlocking(); |
114 } | 114 } |
115 | 115 |
116 ASSERT(!m_numBlockingTextureUploads); | 116 DCHECK(!m_numBlockingTextureUploads); |
117 } | 117 } |
118 | 118 |
119 double ThrottledTextureUploader::estimatedTexturesPerSecond() | 119 double ThrottledTextureUploader::estimatedTexturesPerSecond() |
120 { | 120 { |
121 processQueries(); | 121 processQueries(); |
122 | 122 |
123 // The history should never be empty because we initialize all elements with
an estimate. | 123 // The history should never be empty because we initialize all elements with
an estimate. |
124 ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize); | 124 DCHECK(m_texturesPerSecondHistory.size() == uploadHistorySize); |
125 | 125 |
126 // Sort the history and use the median as our estimate. | 126 // Sort the history and use the median as our estimate. |
127 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), | 127 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), |
128 m_texturesPerSecondHistory.end()); | 128 m_texturesPerSecondHistory.end()); |
129 std::sort(sortedHistory.begin(), sortedHistory.end()); | 129 std::sort(sortedHistory.begin(), sortedHistory.end()); |
130 | 130 |
131 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 /
3]; | 131 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 /
3]; |
132 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon
dGlobal); | 132 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon
dGlobal); |
133 return estimatedTexturesPerSecondGlobal; | 133 return estimatedTexturesPerSecondGlobal; |
134 } | 134 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Remove the oldest values from our history and insert the new one | 177 // Remove the oldest values from our history and insert the new one |
178 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); | 178 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); |
179 m_texturesPerSecondHistory.pop_back(); | 179 m_texturesPerSecondHistory.pop_back(); |
180 m_texturesPerSecondHistory.push_front(texturesPerSecond); | 180 m_texturesPerSecondHistory.push_front(texturesPerSecond); |
181 | 181 |
182 m_availableQueries.append(m_pendingQueries.takeFirst()); | 182 m_availableQueries.append(m_pendingQueries.takeFirst()); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 } | 186 } |
OLD | NEW |