Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1155)

Side by Side Diff: cc/resources/texture_uploader.cc

Issue 642993002: Fix unbounded allocation of GL queries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698