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

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

Issue 817673004: cc: TextureUploader - Reset GL_UNPACK_ALIGNMENT to 4 before uploading images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (source_rect.IsEmpty()) 189 if (source_rect.IsEmpty())
190 return; 190 return;
191 DCHECK(image); 191 DCHECK(image);
192 192
193 // Offset from image-rect to source-rect. 193 // Offset from image-rect to source-rect.
194 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); 194 gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
195 195
196 const uint8* pixel_source; 196 const uint8* pixel_source;
197 unsigned bytes_per_pixel = BitsPerPixel(format) / 8; 197 unsigned bytes_per_pixel = BitsPerPixel(format) / 8;
198 // Use 4-byte row alignment (OpenGL default) for upload performance. 198 // Use 4-byte row alignment (OpenGL default) for upload performance.
199 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. 199 // Assuming that GL_UNPACK_ALIGNMENT = 4 is set in UploadWithMapTexSubImage.
200 unsigned upload_image_stride = 200 unsigned upload_image_stride =
201 RoundUp(bytes_per_pixel * source_rect.width(), 4u); 201 RoundUp(bytes_per_pixel * source_rect.width(), 4u);
202 202
203 if (upload_image_stride == image_rect.width() * bytes_per_pixel && 203 if (upload_image_stride == image_rect.width() * bytes_per_pixel &&
204 !offset.x()) { 204 !offset.x()) {
205 pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()]; 205 pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()];
206 } else { 206 } else {
207 size_t needed_size = upload_image_stride * source_rect.height(); 207 size_t needed_size = upload_image_stride * source_rect.height();
208 if (sub_image_size_ < needed_size) { 208 if (sub_image_size_ < needed_size) {
209 sub_image_.reset(new uint8[needed_size]); 209 sub_image_.reset(new uint8[needed_size]);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return; 244 return;
245 DCHECK(image); 245 DCHECK(image);
246 // Compressed textures have no implementation of mapTexSubImage. 246 // Compressed textures have no implementation of mapTexSubImage.
247 DCHECK_NE(ETC1, format); 247 DCHECK_NE(ETC1, format);
248 248
249 // Offset from image-rect to source-rect. 249 // Offset from image-rect to source-rect.
250 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); 250 gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
251 251
252 unsigned bytes_per_pixel = BitsPerPixel(format) / 8; 252 unsigned bytes_per_pixel = BitsPerPixel(format) / 8;
253 // Use 4-byte row alignment (OpenGL default) for upload performance. 253 // Use 4-byte row alignment (OpenGL default) for upload performance.
254 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. 254 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
danakj 2014/12/19 20:00:46 Should we do this when we take control of the cont
vmiura 2014/12/19 21:28:16 If there's a good spot we could do that. Discussi
255 unsigned upload_image_stride = 255 unsigned upload_image_stride =
256 RoundUp(bytes_per_pixel * source_rect.width(), 4u); 256 RoundUp(bytes_per_pixel * source_rect.width(), 4u);
257 257
258 // Upload tile data via a mapped transfer buffer 258 // Upload tile data via a mapped transfer buffer
259 uint8* pixel_dest = 259 uint8* pixel_dest =
260 static_cast<uint8*>(gl_->MapTexSubImage2DCHROMIUM(GL_TEXTURE_2D, 260 static_cast<uint8*>(gl_->MapTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
261 0, 261 0,
262 dest_offset.x(), 262 dest_offset.x(),
263 dest_offset.y(), 263 dest_offset.y(),
264 source_rect.width(), 264 source_rect.width(),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 textures_per_second_history_.erase(textures_per_second_history_.begin()); 329 textures_per_second_history_.erase(textures_per_second_history_.begin());
330 textures_per_second_history_.erase(--textures_per_second_history_.end()); 330 textures_per_second_history_.erase(--textures_per_second_history_.end());
331 } 331 }
332 textures_per_second_history_.insert(textures_per_second); 332 textures_per_second_history_.insert(textures_per_second);
333 333
334 available_queries_.push_back(pending_queries_.take_front()); 334 available_queries_.push_back(pending_queries_.take_front());
335 } 335 }
336 } 336 }
337 337
338 } // namespace cc 338 } // 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