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

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

Issue 793693003: Tile Compression (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 | « cc/resources/texture_compress/texture_compress_perftest.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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // not a no-op. 188 // not a no-op.
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 DCHECK(bytes_per_pixel);
198 // Use 4-byte row alignment (OpenGL default) for upload performance. 199 // Use 4-byte row alignment (OpenGL default) for upload performance.
199 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. 200 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
200 unsigned upload_image_stride = 201 unsigned upload_image_stride =
201 RoundUp(bytes_per_pixel * source_rect.width(), 4u); 202 RoundUp(bytes_per_pixel * source_rect.width(), 4u);
202 203
203 if (upload_image_stride == image_rect.width() * bytes_per_pixel && 204 if (upload_image_stride == image_rect.width() * bytes_per_pixel &&
204 !offset.x()) { 205 !offset.x()) {
205 pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()]; 206 pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()];
206 } else { 207 } else {
207 size_t needed_size = upload_image_stride * source_rect.height(); 208 size_t needed_size = upload_image_stride * source_rect.height();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (source_rect.IsEmpty()) 244 if (source_rect.IsEmpty())
244 return; 245 return;
245 DCHECK(image); 246 DCHECK(image);
246 // Compressed textures have no implementation of mapTexSubImage. 247 // Compressed textures have no implementation of mapTexSubImage.
247 DCHECK_NE(ETC1, format); 248 DCHECK_NE(ETC1, format);
248 249
249 // Offset from image-rect to source-rect. 250 // Offset from image-rect to source-rect.
250 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); 251 gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
251 252
252 unsigned bytes_per_pixel = BitsPerPixel(format) / 8; 253 unsigned bytes_per_pixel = BitsPerPixel(format) / 8;
254 DCHECK(bytes_per_pixel);
253 // Use 4-byte row alignment (OpenGL default) for upload performance. 255 // Use 4-byte row alignment (OpenGL default) for upload performance.
254 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. 256 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
255 unsigned upload_image_stride = 257 unsigned upload_image_stride =
256 RoundUp(bytes_per_pixel * source_rect.width(), 4u); 258 RoundUp(bytes_per_pixel * source_rect.width(), 4u);
257 259
258 // Upload tile data via a mapped transfer buffer 260 // Upload tile data via a mapped transfer buffer
259 uint8* pixel_dest = 261 uint8* pixel_dest =
260 static_cast<uint8*>(gl_->MapTexSubImage2DCHROMIUM(GL_TEXTURE_2D, 262 static_cast<uint8*>(gl_->MapTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
261 0, 263 0,
262 dest_offset.x(), 264 dest_offset.x(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 textures_per_second_history_.erase(textures_per_second_history_.begin()); 331 textures_per_second_history_.erase(textures_per_second_history_.begin());
330 textures_per_second_history_.erase(--textures_per_second_history_.end()); 332 textures_per_second_history_.erase(--textures_per_second_history_.end());
331 } 333 }
332 textures_per_second_history_.insert(textures_per_second); 334 textures_per_second_history_.insert(textures_per_second);
333 335
334 available_queries_.push_back(pending_queries_.take_front()); 336 available_queries_.push_back(pending_queries_.take_front());
335 } 337 }
336 } 338 }
337 339
338 } // namespace cc 340 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/texture_compress/texture_compress_perftest.cc ('k') | cc/resources/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698