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 "cc/resources/texture_uploader.h" | 5 #include "cc/resources/texture_uploader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 double TextureUploader::EstimatedTexturesPerSecond() { | 109 double TextureUploader::EstimatedTexturesPerSecond() { |
110 ProcessQueries(); | 110 ProcessQueries(); |
111 | 111 |
112 // Use the median as our estimate. | 112 // Use the median as our estimate. |
113 std::multiset<double>::iterator median = textures_per_second_history_.begin(); | 113 std::multiset<double>::iterator median = textures_per_second_history_.begin(); |
114 std::advance(median, textures_per_second_history_.size() / 2); | 114 std::advance(median, textures_per_second_history_.size() / 2); |
115 return *median; | 115 return *median; |
116 } | 116 } |
117 | 117 |
118 void TextureUploader::BeginQuery() { | 118 void TextureUploader::BeginQuery() { |
| 119 // Check to see if any of the pending queries are free before allocating a |
| 120 // new one. If this is not done, queries may be allocated without bound. |
| 121 // http://crbug.com/398072 |
| 122 if (available_queries_.empty()) |
| 123 ProcessQueries(); |
| 124 |
119 if (available_queries_.empty()) | 125 if (available_queries_.empty()) |
120 available_queries_.push_back(Query::Create(gl_)); | 126 available_queries_.push_back(Query::Create(gl_)); |
121 | 127 |
122 available_queries_.front()->Begin(); | 128 available_queries_.front()->Begin(); |
123 } | 129 } |
124 | 130 |
125 void TextureUploader::EndQuery() { | 131 void TextureUploader::EndQuery() { |
126 available_queries_.front()->End(); | 132 available_queries_.front()->End(); |
127 pending_queries_.push_back(available_queries_.take_front()); | 133 pending_queries_.push_back(available_queries_.take_front()); |
128 num_blocking_texture_uploads_++; | 134 num_blocking_texture_uploads_++; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 textures_per_second_history_.erase(textures_per_second_history_.begin()); | 330 textures_per_second_history_.erase(textures_per_second_history_.begin()); |
325 textures_per_second_history_.erase(--textures_per_second_history_.end()); | 331 textures_per_second_history_.erase(--textures_per_second_history_.end()); |
326 } | 332 } |
327 textures_per_second_history_.insert(textures_per_second); | 333 textures_per_second_history_.insert(textures_per_second); |
328 | 334 |
329 available_queries_.push_back(pending_queries_.take_front()); | 335 available_queries_.push_back(pending_queries_.take_front()); |
330 } | 336 } |
331 } | 337 } |
332 | 338 |
333 } // namespace cc | 339 } // namespace cc |
OLD | NEW |