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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « cc/resources/scoped_resource_unittest.cc ('k') | cc/resources/tile.h » ('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 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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 gfx::Vector2d dest_offset, 139 gfx::Vector2d dest_offset,
140 ResourceFormat format, 140 ResourceFormat format,
141 const gfx::Size& size) { 141 const gfx::Size& size) {
142 CHECK(image_rect.Contains(source_rect)); 142 CHECK(image_rect.Contains(source_rect));
143 143
144 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size; 144 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size;
145 145
146 if (is_full_upload) 146 if (is_full_upload)
147 BeginQuery(); 147 BeginQuery();
148 148
149 UploadWithMapTexSubImage(image, image_rect, source_rect, dest_offset, format); 149 if (format == ETC1) {
150 // ETC1 does not support subimage uploads.
151 DCHECK(is_full_upload);
152 UploadWithTexImageETC1(image, size);
153 } else {
154 UploadWithMapTexSubImage(
155 image, image_rect, source_rect, dest_offset, format);
156 }
150 157
151 if (is_full_upload) 158 if (is_full_upload)
152 EndQuery(); 159 EndQuery();
153 160
154 num_texture_uploads_since_last_flush_++; 161 num_texture_uploads_since_last_flush_++;
155 if (num_texture_uploads_since_last_flush_ >= kTextureUploadFlushPeriod) 162 if (num_texture_uploads_since_last_flush_ >= kTextureUploadFlushPeriod)
156 Flush(); 163 Flush();
157 } 164 }
158 165
159 void TextureUploader::Flush() { 166 void TextureUploader::Flush() {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 memcpy(&pixel_dest[upload_image_stride * row], 284 memcpy(&pixel_dest[upload_image_stride * row],
278 &image[bytes_per_pixel * 285 &image[bytes_per_pixel *
279 (offset.x() + (offset.y() + row) * image_rect.width())], 286 (offset.x() + (offset.y() + row) * image_rect.width())],
280 source_rect.width() * bytes_per_pixel); 287 source_rect.width() * bytes_per_pixel);
281 } 288 }
282 } 289 }
283 290
284 gl_->UnmapTexSubImage2DCHROMIUM(pixel_dest); 291 gl_->UnmapTexSubImage2DCHROMIUM(pixel_dest);
285 } 292 }
286 293
294 void TextureUploader::UploadWithTexImageETC1(const uint8* image,
295 const gfx::Size& size) {
296 TRACE_EVENT0("cc", "TextureUploader::UploadWithTexImageETC1");
297 DCHECK_EQ(0, size.width() % 4);
298 DCHECK_EQ(0, size.height() % 4);
299
300 gl_->CompressedTexImage2D(GL_TEXTURE_2D,
301 0,
302 GLInternalFormat(ETC1),
303 size.width(),
304 size.height(),
305 0,
306 Resource::MemorySizeBytes(size, ETC1),
307 image);
308 }
309
287 void TextureUploader::ProcessQueries() { 310 void TextureUploader::ProcessQueries() {
288 while (!pending_queries_.empty()) { 311 while (!pending_queries_.empty()) {
289 if (pending_queries_.front()->IsPending()) 312 if (pending_queries_.front()->IsPending())
290 break; 313 break;
291 314
292 unsigned us_elapsed = pending_queries_.front()->Value(); 315 unsigned us_elapsed = pending_queries_.front()->Value();
293 UMA_HISTOGRAM_CUSTOM_COUNTS( 316 UMA_HISTOGRAM_CUSTOM_COUNTS(
294 "Renderer4.TextureGpuUploadTimeUS", us_elapsed, 0, 100000, 50); 317 "Renderer4.TextureGpuUploadTimeUS", us_elapsed, 0, 100000, 50);
295 318
296 // Clamp the queries to saner values in case the queries fail. 319 // Clamp the queries to saner values in case the queries fail.
297 us_elapsed = std::max(1u, us_elapsed); 320 us_elapsed = std::max(1u, us_elapsed);
298 us_elapsed = std::min(15000u, us_elapsed); 321 us_elapsed = std::min(15000u, us_elapsed);
299 322
300 if (!pending_queries_.front()->is_non_blocking()) 323 if (!pending_queries_.front()->is_non_blocking())
301 num_blocking_texture_uploads_--; 324 num_blocking_texture_uploads_--;
302 325
303 // Remove the min and max value from our history and insert the new one. 326 // Remove the min and max value from our history and insert the new one.
304 double textures_per_second = 1.0 / (us_elapsed * 1e-6); 327 double textures_per_second = 1.0 / (us_elapsed * 1e-6);
305 if (textures_per_second_history_.size() >= kUploadHistorySizeMax) { 328 if (textures_per_second_history_.size() >= kUploadHistorySizeMax) {
306 textures_per_second_history_.erase(textures_per_second_history_.begin()); 329 textures_per_second_history_.erase(textures_per_second_history_.begin());
307 textures_per_second_history_.erase(--textures_per_second_history_.end()); 330 textures_per_second_history_.erase(--textures_per_second_history_.end());
308 } 331 }
309 textures_per_second_history_.insert(textures_per_second); 332 textures_per_second_history_.insert(textures_per_second);
310 333
311 available_queries_.push_back(pending_queries_.take_front()); 334 available_queries_.push_back(pending_queries_.take_front());
312 } 335 }
313 } 336 }
314 337
315 } // namespace cc 338 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/scoped_resource_unittest.cc ('k') | cc/resources/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698