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

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: android!! Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 // Use the median as our estimate. 136 // Use the median as our estimate.
137 std::multiset<double>::iterator median = m_texturesPerSecondHistory.begin(); 137 std::multiset<double>::iterator median = m_texturesPerSecondHistory.begin();
138 std::advance(median, m_texturesPerSecondHistory.size() / 2); 138 std::advance(median, m_texturesPerSecondHistory.size() / 2);
139 TRACE_COUNTER_ID1("cc", "EstimatedTexturesPerSecond", m_context, *median); 139 TRACE_COUNTER_ID1("cc", "EstimatedTexturesPerSecond", m_context, *median);
140 return *median; 140 return *median;
141 } 141 }
142 142
143 void TextureUploader::beginQuery() 143 void TextureUploader::beginQuery()
144 { 144 {
145 if (m_availableQueries.isEmpty()) 145 if (m_availableQueries.empty())
146 m_availableQueries.append(Query::create(m_context)); 146 m_availableQueries.push_back(Query::create(m_context));
147 147
148 m_availableQueries.first()->begin(); 148 m_availableQueries.front()->begin();
149 } 149 }
150 150
151 void TextureUploader::endQuery() 151 void TextureUploader::endQuery()
152 { 152 {
153 m_availableQueries.first()->end(); 153 m_availableQueries.front()->end();
154 m_pendingQueries.append(m_availableQueries.takeFirst()); 154 m_pendingQueries.push_back(m_availableQueries.take_front());
155 m_numBlockingTextureUploads++; 155 m_numBlockingTextureUploads++;
156 } 156 }
157 157
158 void TextureUploader::upload(const uint8* image, 158 void TextureUploader::upload(const uint8* image,
159 const gfx::Rect& image_rect, 159 const gfx::Rect& image_rect,
160 const gfx::Rect& source_rect, 160 const gfx::Rect& source_rect,
161 const gfx::Vector2d& dest_offset, 161 const gfx::Vector2d& dest_offset,
162 GLenum format, 162 GLenum format,
163 const gfx::Size& size) 163 const gfx::Size& size)
164 { 164 {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 &image[bytes_per_pixel * (offset.x() + 335 &image[bytes_per_pixel * (offset.x() +
336 (offset.y() + row) * image_rect.width())], 336 (offset.y() + row) * image_rect.width())],
337 source_rect.width() * bytes_per_pixel); 337 source_rect.width() * bytes_per_pixel);
338 } 338 }
339 339
340 m_context->unmapTexSubImage2DCHROMIUM(pixel_dest); 340 m_context->unmapTexSubImage2DCHROMIUM(pixel_dest);
341 } 341 }
342 342
343 void TextureUploader::processQueries() 343 void TextureUploader::processQueries()
344 { 344 {
345 while (!m_pendingQueries.isEmpty()) { 345 while (!m_pendingQueries.empty()) {
346 if (m_pendingQueries.first()->isPending()) 346 if (m_pendingQueries.front()->isPending())
347 break; 347 break;
348 348
349 unsigned usElapsed = m_pendingQueries.first()->value(); 349 unsigned usElapsed = m_pendingQueries.front()->value();
350 HISTOGRAM_CUSTOM_COUNTS("Renderer4.TextureGpuUploadTimeUS", usElapsed, 0 , 100000, 50); 350 HISTOGRAM_CUSTOM_COUNTS("Renderer4.TextureGpuUploadTimeUS", usElapsed, 0 , 100000, 50);
351 351
352 // Clamp the queries to saner values in case the queries fail. 352 // Clamp the queries to saner values in case the queries fail.
353 usElapsed = std::max(1u, usElapsed); 353 usElapsed = std::max(1u, usElapsed);
354 usElapsed = std::min(15000u, usElapsed); 354 usElapsed = std::min(15000u, usElapsed);
355 355
356 if (!m_pendingQueries.first()->isNonBlocking()) 356 if (!m_pendingQueries.front()->isNonBlocking())
357 m_numBlockingTextureUploads--; 357 m_numBlockingTextureUploads--;
358 358
359 // Remove the min and max value from our history and insert the new one. 359 // Remove the min and max value from our history and insert the new one.
360 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); 360 double texturesPerSecond = 1.0 / (usElapsed * 1e-6);
361 if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) { 361 if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) {
362 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin()) ; 362 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin()) ;
363 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end()) ; 363 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end()) ;
364 } 364 }
365 m_texturesPerSecondHistory.insert(texturesPerSecond); 365 m_texturesPerSecondHistory.insert(texturesPerSecond);
366 366
367 m_availableQueries.append(m_pendingQueries.takeFirst()); 367 m_availableQueries.push_back(m_pendingQueries.take_front());
368 } 368 }
369 } 369 }
370 370
371 } // namespace cc 371 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698