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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
10 #include "cc/output/renderer.h" | 13 #include "cc/output/renderer.h" |
11 #include "cc/quads/texture_draw_quad.h" | 14 #include "cc/quads/texture_draw_quad.h" |
12 #include "cc/resources/platform_color.h" | 15 #include "cc/resources/platform_color.h" |
13 #include "cc/resources/scoped_resource.h" | 16 #include "cc/resources/scoped_resource.h" |
14 #include "cc/resources/single_release_callback_impl.h" | 17 #include "cc/resources/single_release_callback_impl.h" |
15 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
16 #include "cc/trees/occlusion.h" | 19 #include "cc/trees/occlusion.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 resource_provider->InUseByConsumer(texture_copy_->id())) | 106 resource_provider->InUseByConsumer(texture_copy_->id())) |
104 texture_copy_->Free(); | 107 texture_copy_->Free(); |
105 | 108 |
106 if (!texture_copy_->id()) { | 109 if (!texture_copy_->id()) { |
107 texture_copy_->Allocate(texture_mailbox_.size_in_pixels(), | 110 texture_copy_->Allocate(texture_mailbox_.size_in_pixels(), |
108 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 111 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
109 resource_provider->best_texture_format()); | 112 resource_provider->best_texture_format()); |
110 } | 113 } |
111 | 114 |
112 if (texture_copy_->id()) { | 115 if (texture_copy_->id()) { |
113 std::vector<uint8> swizzled; | 116 std::vector<uint8_t> swizzled; |
114 uint8* pixels = texture_mailbox_.shared_bitmap()->pixels(); | 117 uint8_t* pixels = texture_mailbox_.shared_bitmap()->pixels(); |
115 | 118 |
116 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 119 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
117 // Swizzle colors. This is slow, but should be really uncommon. | 120 // Swizzle colors. This is slow, but should be really uncommon. |
118 size_t bytes = texture_mailbox_.SharedMemorySizeInBytes(); | 121 size_t bytes = texture_mailbox_.SharedMemorySizeInBytes(); |
119 swizzled.resize(bytes); | 122 swizzled.resize(bytes); |
120 for (size_t i = 0; i < bytes; i += 4) { | 123 for (size_t i = 0; i < bytes; i += 4) { |
121 swizzled[i] = pixels[i + 2]; | 124 swizzled[i] = pixels[i + 2]; |
122 swizzled[i + 1] = pixels[i + 1]; | 125 swizzled[i + 1] = pixels[i + 1]; |
123 swizzled[i + 2] = pixels[i]; | 126 swizzled[i + 2] = pixels[i]; |
124 swizzled[i + 3] = pixels[i + 3]; | 127 swizzled[i + 3] = pixels[i + 3]; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } else if (external_texture_resource_) { | 260 } else if (external_texture_resource_) { |
258 DCHECK(!own_mailbox_); | 261 DCHECK(!own_mailbox_); |
259 ResourceProvider* resource_provider = | 262 ResourceProvider* resource_provider = |
260 layer_tree_impl()->resource_provider(); | 263 layer_tree_impl()->resource_provider(); |
261 resource_provider->DeleteResource(external_texture_resource_); | 264 resource_provider->DeleteResource(external_texture_resource_); |
262 external_texture_resource_ = 0; | 265 external_texture_resource_ = 0; |
263 } | 266 } |
264 } | 267 } |
265 | 268 |
266 } // namespace cc | 269 } // namespace cc |
OLD | NEW |