| OLD | NEW |
| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 void TextureUploader::EndQuery() { | 130 void TextureUploader::EndQuery() { |
| 131 available_queries_.front()->End(); | 131 available_queries_.front()->End(); |
| 132 pending_queries_.push_back(available_queries_.take_front()); | 132 pending_queries_.push_back(available_queries_.take_front()); |
| 133 num_blocking_texture_uploads_++; | 133 num_blocking_texture_uploads_++; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void TextureUploader::Upload(const uint8* image, | 136 void TextureUploader::Upload(const uint8* image, |
| 137 const gfx::Rect& image_rect, | 137 const gfx::Rect& image_rect, |
| 138 const gfx::Rect& source_rect, | 138 const gfx::Rect& source_rect, |
| 139 gfx::Vector2d dest_offset, | 139 const gfx::Vector2d& dest_offset, |
| 140 ResourceFormat format, | 140 ResourceFormat format, |
| 141 const gfx::Size& size) { | 141 const gfx::Size& size) { |
| 142 CHECK(image_rect.Contains(source_rect)); | 142 CHECK(image_rect.Contains(source_rect)); |
| 143 | 143 |
| 144 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size; | 144 bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size; |
| 145 | 145 |
| 146 if (is_full_upload) | 146 if (is_full_upload) |
| 147 BeginQuery(); | 147 BeginQuery(); |
| 148 | 148 |
| 149 UploadWithMapTexSubImage(image, image_rect, source_rect, dest_offset, format); | 149 UploadWithMapTexSubImage(image, image_rect, source_rect, dest_offset, format); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TextureUploader::ReleaseCachedQueries() { | 168 void TextureUploader::ReleaseCachedQueries() { |
| 169 ProcessQueries(); | 169 ProcessQueries(); |
| 170 available_queries_.clear(); | 170 available_queries_.clear(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void TextureUploader::UploadWithTexSubImage(const uint8* image, | 173 void TextureUploader::UploadWithTexSubImage(const uint8* image, |
| 174 const gfx::Rect& image_rect, | 174 const gfx::Rect& image_rect, |
| 175 const gfx::Rect& source_rect, | 175 const gfx::Rect& source_rect, |
| 176 gfx::Vector2d dest_offset, | 176 const gfx::Vector2d& dest_offset, |
| 177 ResourceFormat format) { | 177 ResourceFormat format) { |
| 178 TRACE_EVENT0("cc", "TextureUploader::UploadWithTexSubImage"); | 178 TRACE_EVENT0("cc", "TextureUploader::UploadWithTexSubImage"); |
| 179 | 179 |
| 180 // Early-out if this is a no-op, and assert that |image| be valid if this is | 180 // Early-out if this is a no-op, and assert that |image| be valid if this is |
| 181 // not a no-op. | 181 // not a no-op. |
| 182 if (source_rect.IsEmpty()) | 182 if (source_rect.IsEmpty()) |
| 183 return; | 183 return; |
| 184 DCHECK(image); | 184 DCHECK(image); |
| 185 | 185 |
| 186 // Offset from image-rect to source-rect. | 186 // Offset from image-rect to source-rect. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 source_rect.width(), | 220 source_rect.width(), |
| 221 source_rect.height(), | 221 source_rect.height(), |
| 222 GLDataFormat(format), | 222 GLDataFormat(format), |
| 223 GLDataType(format), | 223 GLDataType(format), |
| 224 pixel_source); | 224 pixel_source); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TextureUploader::UploadWithMapTexSubImage(const uint8* image, | 227 void TextureUploader::UploadWithMapTexSubImage(const uint8* image, |
| 228 const gfx::Rect& image_rect, | 228 const gfx::Rect& image_rect, |
| 229 const gfx::Rect& source_rect, | 229 const gfx::Rect& source_rect, |
| 230 gfx::Vector2d dest_offset, | 230 const gfx::Vector2d& dest_offset, |
| 231 ResourceFormat format) { | 231 ResourceFormat format) { |
| 232 TRACE_EVENT0("cc", "TextureUploader::UploadWithMapTexSubImage"); | 232 TRACE_EVENT0("cc", "TextureUploader::UploadWithMapTexSubImage"); |
| 233 | 233 |
| 234 // Early-out if this is a no-op, and assert that |image| be valid if this is | 234 // Early-out if this is a no-op, and assert that |image| be valid if this is |
| 235 // not a no-op. | 235 // not a no-op. |
| 236 if (source_rect.IsEmpty()) | 236 if (source_rect.IsEmpty()) |
| 237 return; | 237 return; |
| 238 DCHECK(image); | 238 DCHECK(image); |
| 239 // Compressed textures have no implementation of mapTexSubImage. | 239 // Compressed textures have no implementation of mapTexSubImage. |
| 240 DCHECK_NE(ETC1, format); | 240 DCHECK_NE(ETC1, format); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 textures_per_second_history_.erase(textures_per_second_history_.begin()); | 306 textures_per_second_history_.erase(textures_per_second_history_.begin()); |
| 307 textures_per_second_history_.erase(--textures_per_second_history_.end()); | 307 textures_per_second_history_.erase(--textures_per_second_history_.end()); |
| 308 } | 308 } |
| 309 textures_per_second_history_.insert(textures_per_second); | 309 textures_per_second_history_.insert(textures_per_second); |
| 310 | 310 |
| 311 available_queries_.push_back(pending_queries_.take_front()); | 311 available_queries_.push_back(pending_queries_.take_front()); |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace cc | 315 } // namespace cc |
| OLD | NEW |