| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layers/texture_layer_impl.h" | 5 #include "cc/layers/texture_layer_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "cc/layers/quad_sink.h" | 10 #include "cc/layers/quad_sink.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 resource_provider->best_texture_format()); | 117 resource_provider->best_texture_format()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (texture_copy_->id()) { | 120 if (texture_copy_->id()) { |
| 121 std::vector<uint8> swizzled; | 121 std::vector<uint8> swizzled; |
| 122 uint8* pixels = | 122 uint8* pixels = |
| 123 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); | 123 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); |
| 124 | 124 |
| 125 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 125 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
| 126 // Swizzle colors. This is slow, but should be really uncommon. | 126 // Swizzle colors. This is slow, but should be really uncommon. |
| 127 swizzled.resize(texture_mailbox_.SharedMemorySizeInBytes()); | 127 size_t bytes = texture_mailbox_.SharedMemorySizeInBytes(); |
| 128 for (size_t i = 0; i < texture_mailbox_.SharedMemorySizeInBytes(); | 128 swizzled.resize(bytes); |
| 129 i += 4) { | 129 for (size_t i = 0; i < bytes; i += 4) { |
| 130 swizzled[i] = pixels[i + 2]; | 130 swizzled[i] = pixels[i + 2]; |
| 131 swizzled[i + 1] = pixels[i + 1]; | 131 swizzled[i + 1] = pixels[i + 1]; |
| 132 swizzled[i + 2] = pixels[i]; | 132 swizzled[i + 2] = pixels[i]; |
| 133 swizzled[i + 3] = pixels[i + 3]; | 133 swizzled[i + 3] = pixels[i + 3]; |
| 134 } | 134 } |
| 135 pixels = &swizzled[0]; | 135 pixels = &swizzled[0]; |
| 136 } | 136 } |
| 137 | 137 |
| 138 resource_provider->SetPixels( | 138 resource_provider->SetPixels( |
| 139 texture_copy_->id(), | 139 texture_copy_->id(), |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } else if (external_texture_resource_) { | 287 } else if (external_texture_resource_) { |
| 288 DCHECK(!own_mailbox_); | 288 DCHECK(!own_mailbox_); |
| 289 ResourceProvider* resource_provider = | 289 ResourceProvider* resource_provider = |
| 290 layer_tree_impl()->resource_provider(); | 290 layer_tree_impl()->resource_provider(); |
| 291 resource_provider->DeleteResource(external_texture_resource_); | 291 resource_provider->DeleteResource(external_texture_resource_); |
| 292 external_texture_resource_ = 0; | 292 external_texture_resource_ = 0; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace cc | 296 } // namespace cc |
| OLD | NEW |