| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/texture_uploader.h" | 7 #include "cc/texture_uploader.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "IntSize.h" | |
| 13 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
| 14 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 15 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 16 #include "cc/texture.h" | 15 #include "cc/texture.h" |
| 17 #include "cc/prioritized_texture.h" | 16 #include "cc/prioritized_texture.h" |
| 18 #include "third_party/khronos/GLES2/gl2.h" | 17 #include "third_party/khronos/GLES2/gl2.h" |
| 19 #include "third_party/khronos/GLES2/gl2ext.h" | 18 #include "third_party/khronos/GLES2/gl2ext.h" |
| 20 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/vector2d.h" | 20 #include "ui/gfx/vector2d.h" |
| 22 #include <public/WebGraphicsContext3D.h> | 21 #include <public/WebGraphicsContext3D.h> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 base::debug::Alias(&source_rect_height); | 199 base::debug::Alias(&source_rect_height); |
| 201 base::debug::Alias(&image_rect_x); | 200 base::debug::Alias(&image_rect_x); |
| 202 base::debug::Alias(&image_rect_y); | 201 base::debug::Alias(&image_rect_y); |
| 203 base::debug::Alias(&image_rect_width); | 202 base::debug::Alias(&image_rect_width); |
| 204 base::debug::Alias(&image_rect_height); | 203 base::debug::Alias(&image_rect_height); |
| 205 base::debug::Alias(&dest_offset_x); | 204 base::debug::Alias(&dest_offset_x); |
| 206 base::debug::Alias(&dest_offset_y); | 205 base::debug::Alias(&dest_offset_y); |
| 207 TRACE_EVENT0("cc", "TextureUploader::uploadWithTexSubImage"); | 206 TRACE_EVENT0("cc", "TextureUploader::uploadWithTexSubImage"); |
| 208 | 207 |
| 209 // Offset from image-rect to source-rect. | 208 // Offset from image-rect to source-rect. |
| 210 IntPoint offset(source_rect.x() - image_rect.x(), | 209 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); |
| 211 source_rect.y() - image_rect.y()); | |
| 212 | 210 |
| 213 const uint8_t* pixel_source; | 211 const uint8_t* pixel_source; |
| 214 unsigned int bytes_per_pixel = Texture::bytesPerPixel(format); | 212 unsigned int bytes_per_pixel = Texture::bytesPerPixel(format); |
| 215 | 213 |
| 216 if (image_rect.width() == source_rect.width() && !offset.x()) { | 214 if (image_rect.width() == source_rect.width() && !offset.x()) { |
| 217 pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()]
; | 215 pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()]
; |
| 218 } else { | 216 } else { |
| 219 size_t needed_size = source_rect.width() * source_rect.height() * bytes_
per_pixel; | 217 size_t needed_size = source_rect.width() * source_rect.height() * bytes_
per_pixel; |
| 220 if (m_subImageSize < needed_size) { | 218 if (m_subImageSize < needed_size) { |
| 221 m_subImage.reset(new uint8_t[needed_size]); | 219 m_subImage.reset(new uint8_t[needed_size]); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 base::debug::Alias(&image_rect_x); | 266 base::debug::Alias(&image_rect_x); |
| 269 base::debug::Alias(&image_rect_y); | 267 base::debug::Alias(&image_rect_y); |
| 270 base::debug::Alias(&image_rect_width); | 268 base::debug::Alias(&image_rect_width); |
| 271 base::debug::Alias(&image_rect_height); | 269 base::debug::Alias(&image_rect_height); |
| 272 base::debug::Alias(&dest_offset_x); | 270 base::debug::Alias(&dest_offset_x); |
| 273 base::debug::Alias(&dest_offset_y); | 271 base::debug::Alias(&dest_offset_y); |
| 274 | 272 |
| 275 TRACE_EVENT0("cc", "TextureUploader::uploadWithMapTexSubImage"); | 273 TRACE_EVENT0("cc", "TextureUploader::uploadWithMapTexSubImage"); |
| 276 | 274 |
| 277 // Offset from image-rect to source-rect. | 275 // Offset from image-rect to source-rect. |
| 278 IntPoint offset(source_rect.x() - image_rect.x(), | 276 gfx::Vector2d offset(source_rect.origin() - image_rect.origin()); |
| 279 source_rect.y() - image_rect.y()); | |
| 280 | 277 |
| 281 // Upload tile data via a mapped transfer buffer | 278 // Upload tile data via a mapped transfer buffer |
| 282 uint8_t* pixel_dest = static_cast<uint8_t*>( | 279 uint8_t* pixel_dest = static_cast<uint8_t*>( |
| 283 m_context->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D, | 280 m_context->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D, |
| 284 0, | 281 0, |
| 285 dest_offset.x(), | 282 dest_offset.x(), |
| 286 dest_offset.y(), | 283 dest_offset.y(), |
| 287 source_rect.width(), | 284 source_rect.width(), |
| 288 source_rect.height(), | 285 source_rect.height(), |
| 289 format, | 286 format, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin())
; | 330 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin())
; |
| 334 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end())
; | 331 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end())
; |
| 335 } | 332 } |
| 336 m_texturesPerSecondHistory.insert(texturesPerSecond); | 333 m_texturesPerSecondHistory.insert(texturesPerSecond); |
| 337 | 334 |
| 338 m_availableQueries.append(m_pendingQueries.takeFirst()); | 335 m_availableQueries.append(m_pendingQueries.takeFirst()); |
| 339 } | 336 } |
| 340 } | 337 } |
| 341 | 338 |
| 342 } | 339 } |
| OLD | NEW |