| OLD | NEW |
| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 base::debug::Alias(&image_rect_width); | 221 base::debug::Alias(&image_rect_width); |
| 222 base::debug::Alias(&image_rect_height); | 222 base::debug::Alias(&image_rect_height); |
| 223 base::debug::Alias(&dest_offset_x); | 223 base::debug::Alias(&dest_offset_x); |
| 224 base::debug::Alias(&dest_offset_y); | 224 base::debug::Alias(&dest_offset_y); |
| 225 TRACE_EVENT0("cc", "TextureUploader::uploadWithTexSubImage"); | 225 TRACE_EVENT0("cc", "TextureUploader::uploadWithTexSubImage"); |
| 226 | 226 |
| 227 // Offset from image-rect to source-rect. | 227 // Offset from image-rect to source-rect. |
| 228 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); | 228 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); |
| 229 | 229 |
| 230 const uint8* pixel_source; | 230 const uint8* pixel_source; |
| 231 unsigned int bytes_per_pixel = Resource::bytesPerPixel(format); | 231 unsigned int bytes_per_pixel = Resource::BytesPerPixel(format); |
| 232 | 232 |
| 233 if (image_rect.width() == source_rect.width() && !offset.x()) { | 233 if (image_rect.width() == source_rect.width() && !offset.x()) { |
| 234 pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()]
; | 234 pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()]
; |
| 235 } else { | 235 } else { |
| 236 size_t needed_size = source_rect.width() * source_rect.height() * bytes_
per_pixel; | 236 size_t needed_size = source_rect.width() * source_rect.height() * bytes_
per_pixel; |
| 237 if (m_subImageSize < needed_size) { | 237 if (m_subImageSize < needed_size) { |
| 238 m_subImage.reset(new uint8[needed_size]); | 238 m_subImage.reset(new uint8[needed_size]); |
| 239 m_subImageSize = needed_size; | 239 m_subImageSize = needed_size; |
| 240 } | 240 } |
| 241 // Strides not equal, so do a row-by-row memcpy from the | 241 // Strides not equal, so do a row-by-row memcpy from the |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 format, | 305 format, |
| 306 GL_UNSIGNED_BYTE, | 306 GL_UNSIGNED_BYTE, |
| 307 GL_WRITE_ONLY)); | 307 GL_WRITE_ONLY)); |
| 308 | 308 |
| 309 if (!pixel_dest) { | 309 if (!pixel_dest) { |
| 310 uploadWithTexSubImage( | 310 uploadWithTexSubImage( |
| 311 image, image_rect, source_rect, dest_offset, format); | 311 image, image_rect, source_rect, dest_offset, format); |
| 312 return; | 312 return; |
| 313 } | 313 } |
| 314 | 314 |
| 315 unsigned int bytes_per_pixel = Resource::bytesPerPixel(format); | 315 unsigned int bytes_per_pixel = Resource::BytesPerPixel(format); |
| 316 | 316 |
| 317 if (image_rect.width() == source_rect.width() && !offset.x()) { | 317 if (image_rect.width() == source_rect.width() && !offset.x()) { |
| 318 memcpy(pixel_dest, | 318 memcpy(pixel_dest, |
| 319 &image[offset.y() * image_rect.width() * bytes_per_pixel], | 319 &image[offset.y() * image_rect.width() * bytes_per_pixel], |
| 320 image_rect.width() * source_rect.height() * bytes_per_pixel); | 320 image_rect.width() * source_rect.height() * bytes_per_pixel); |
| 321 } else { | 321 } else { |
| 322 // Strides not equal, so do a row-by-row memcpy from the | 322 // Strides not equal, so do a row-by-row memcpy from the |
| 323 // paint results into the pixelDest | 323 // paint results into the pixelDest |
| 324 for (int row = 0; row < source_rect.height(); ++row) | 324 for (int row = 0; row < source_rect.height(); ++row) |
| 325 memcpy(&pixel_dest[source_rect.width() * row * bytes_per_pixel], | 325 memcpy(&pixel_dest[source_rect.width() * row * bytes_per_pixel], |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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.append(m_pendingQueries.takeFirst()); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 } // namespace cc | 358 } // namespace cc |
| OLD | NEW |