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

Side by Side Diff: cc/texture_uploader.cc

Issue 11418108: cc: Make the ScopedPtrVector and ScopedPtrDeque containers act like STL vector and deque. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 "cc/texture_uploader.h" 5 #include "cc/texture_uploader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // Use the median as our estimate. 135 // Use the median as our estimate.
136 std::multiset<double>::iterator median = m_texturesPerSecondHistory.begin(); 136 std::multiset<double>::iterator median = m_texturesPerSecondHistory.begin();
137 std::advance(median, m_texturesPerSecondHistory.size() / 2); 137 std::advance(median, m_texturesPerSecondHistory.size() / 2);
138 TRACE_COUNTER_ID1("cc", "EstimatedTexturesPerSecond", m_context, *median); 138 TRACE_COUNTER_ID1("cc", "EstimatedTexturesPerSecond", m_context, *median);
139 return *median; 139 return *median;
140 } 140 }
141 141
142 void TextureUploader::beginQuery() 142 void TextureUploader::beginQuery()
143 { 143 {
144 if (m_availableQueries.isEmpty()) 144 if (m_availableQueries.empty())
145 m_availableQueries.append(Query::create(m_context)); 145 m_availableQueries.push_back(Query::create(m_context));
146 146
147 m_availableQueries.first()->begin(); 147 m_availableQueries.front()->begin();
148 } 148 }
149 149
150 void TextureUploader::endQuery() 150 void TextureUploader::endQuery()
151 { 151 {
152 m_availableQueries.first()->end(); 152 m_availableQueries.front()->end();
153 m_pendingQueries.append(m_availableQueries.takeFirst()); 153 m_pendingQueries.push_back(m_availableQueries.take_front());
154 m_numBlockingTextureUploads++; 154 m_numBlockingTextureUploads++;
155 } 155 }
156 156
157 void TextureUploader::upload(const uint8* image, 157 void TextureUploader::upload(const uint8* image,
158 const gfx::Rect& image_rect, 158 const gfx::Rect& image_rect,
159 const gfx::Rect& source_rect, 159 const gfx::Rect& source_rect,
160 const gfx::Vector2d& dest_offset, 160 const gfx::Vector2d& dest_offset,
161 GLenum format, 161 GLenum format,
162 const gfx::Size& size) 162 const gfx::Size& size)
163 { 163 {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 &image[bytes_per_pixel * (offset.x() + 326 &image[bytes_per_pixel * (offset.x() +
327 (offset.y() + row) * image_rect.width())], 327 (offset.y() + row) * image_rect.width())],
328 source_rect.width() * bytes_per_pixel); 328 source_rect.width() * bytes_per_pixel);
329 } 329 }
330 330
331 m_context->unmapTexSubImage2DCHROMIUM(pixel_dest); 331 m_context->unmapTexSubImage2DCHROMIUM(pixel_dest);
332 } 332 }
333 333
334 void TextureUploader::processQueries() 334 void TextureUploader::processQueries()
335 { 335 {
336 while (!m_pendingQueries.isEmpty()) { 336 while (!m_pendingQueries.empty()) {
337 if (m_pendingQueries.first()->isPending()) 337 if (m_pendingQueries.front()->isPending())
338 break; 338 break;
339 339
340 unsigned usElapsed = m_pendingQueries.first()->value(); 340 unsigned usElapsed = m_pendingQueries.front()->value();
341 HISTOGRAM_CUSTOM_COUNTS("Renderer4.TextureGpuUploadTimeUS", usElapsed, 0 , 100000, 50); 341 HISTOGRAM_CUSTOM_COUNTS("Renderer4.TextureGpuUploadTimeUS", usElapsed, 0 , 100000, 50);
342 342
343 if (!m_pendingQueries.first()->isNonBlocking()) 343 if (!m_pendingQueries.front()->isNonBlocking())
344 m_numBlockingTextureUploads--; 344 m_numBlockingTextureUploads--;
345 345
346 // Remove the min and max value from our history and insert the new one. 346 // Remove the min and max value from our history and insert the new one.
347 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); 347 double texturesPerSecond = 1.0 / (usElapsed * 1e-6);
348 if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) { 348 if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) {
349 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin()) ; 349 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin()) ;
350 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end()) ; 350 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end()) ;
351 } 351 }
352 m_texturesPerSecondHistory.insert(texturesPerSecond); 352 m_texturesPerSecondHistory.insert(texturesPerSecond);
353 353
354 m_availableQueries.append(m_pendingQueries.takeFirst()); 354 m_availableQueries.push_back(m_pendingQueries.take_front());
355 } 355 }
356 } 356 }
357 357
358 } // namespace cc 358 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698