| 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/scheduler/texture_uploader.h" | 5 #include "cc/scheduler/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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 available_queries_.front()->End(); | 126 available_queries_.front()->End(); |
| 127 pending_queries_.push_back(available_queries_.take_front()); | 127 pending_queries_.push_back(available_queries_.take_front()); |
| 128 num_blocking_texture_uploads_++; | 128 num_blocking_texture_uploads_++; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void TextureUploader::Upload(const uint8* image, | 131 void TextureUploader::Upload(const uint8* image, |
| 132 const gfx::Rect& image_rect, | 132 const gfx::Rect& image_rect, |
| 133 const gfx::Rect& source_rect, | 133 const gfx::Rect& source_rect, |
| 134 gfx::Vector2d dest_offset, | 134 gfx::Vector2d dest_offset, |
| 135 ResourceFormat format, | 135 ResourceFormat format, |
| 136 const gfx::Size& size) { | 136 gfx::Size size) { |
| 137 CHECK(image_rect.Contains(source_rect)); | 137 CHECK(image_rect.Contains(source_rect)); |
| 138 | 138 |
| 139 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size; | 139 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size; |
| 140 | 140 |
| 141 if (is_full_upload) | 141 if (is_full_upload) |
| 142 BeginQuery(); | 142 BeginQuery(); |
| 143 | 143 |
| 144 if (format == ETC1) { | 144 if (format == ETC1) { |
| 145 // ETC1 does not support subimage uploads. | 145 // ETC1 does not support subimage uploads. |
| 146 DCHECK(is_full_upload); | 146 DCHECK(is_full_upload); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 &image[bytes_per_pixel * | 280 &image[bytes_per_pixel * |
| 281 (offset.x() + (offset.y() + row) * image_rect.width())], | 281 (offset.x() + (offset.y() + row) * image_rect.width())], |
| 282 source_rect.width() * bytes_per_pixel); | 282 source_rect.width() * bytes_per_pixel); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 gl_->UnmapTexSubImage2DCHROMIUM(pixel_dest); | 286 gl_->UnmapTexSubImage2DCHROMIUM(pixel_dest); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void TextureUploader::UploadWithTexImageETC1(const uint8* image, | 289 void TextureUploader::UploadWithTexImageETC1(const uint8* image, |
| 290 const gfx::Size& size) { | 290 gfx::Size size) { |
| 291 TRACE_EVENT0("cc", "TextureUploader::UploadWithTexImageETC1"); | 291 TRACE_EVENT0("cc", "TextureUploader::UploadWithTexImageETC1"); |
| 292 DCHECK_EQ(0, size.width() % 4); | 292 DCHECK_EQ(0, size.width() % 4); |
| 293 DCHECK_EQ(0, size.height() % 4); | 293 DCHECK_EQ(0, size.height() % 4); |
| 294 | 294 |
| 295 gl_->CompressedTexImage2D(GL_TEXTURE_2D, | 295 gl_->CompressedTexImage2D(GL_TEXTURE_2D, |
| 296 0, | 296 0, |
| 297 GLInternalFormat(ETC1), | 297 GLInternalFormat(ETC1), |
| 298 size.width(), | 298 size.width(), |
| 299 size.height(), | 299 size.height(), |
| 300 0, | 300 0, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 324 textures_per_second_history_.erase(textures_per_second_history_.begin()); | 324 textures_per_second_history_.erase(textures_per_second_history_.begin()); |
| 325 textures_per_second_history_.erase(--textures_per_second_history_.end()); | 325 textures_per_second_history_.erase(--textures_per_second_history_.end()); |
| 326 } | 326 } |
| 327 textures_per_second_history_.insert(textures_per_second); | 327 textures_per_second_history_.insert(textures_per_second); |
| 328 | 328 |
| 329 available_queries_.push_back(pending_queries_.take_front()); | 329 available_queries_.push_back(pending_queries_.take_front()); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace cc | 333 } // namespace cc |
| OLD | NEW |