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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Have to upload a copy to a texture for it to be used in a | 104 // Have to upload a copy to a texture for it to be used in a |
105 // hardware draw. | 105 // hardware draw. |
106 if (!texture_copy_) | 106 if (!texture_copy_) |
107 texture_copy_ = ScopedResource::create(resource_provider); | 107 texture_copy_ = ScopedResource::create(resource_provider); |
108 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || | 108 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || |
109 resource_provider->InUseByConsumer(texture_copy_->id())) | 109 resource_provider->InUseByConsumer(texture_copy_->id())) |
110 texture_copy_->Free(); | 110 texture_copy_->Free(); |
111 | 111 |
112 if (!texture_copy_->id()) { | 112 if (!texture_copy_->id()) { |
113 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), | 113 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), |
114 resource_provider->best_texture_format(), | 114 ResourceProvider::TextureUsageAny, |
115 ResourceProvider::TextureUsageAny); | 115 resource_provider->best_texture_format()); |
116 } | 116 } |
117 | 117 |
118 if (texture_copy_->id()) { | 118 if (texture_copy_->id()) { |
119 std::vector<uint8> swizzled; | 119 std::vector<uint8> swizzled; |
120 uint8* pixels = | 120 uint8* pixels = |
121 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); | 121 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); |
122 | 122 |
123 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 123 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
124 // Swizzle colors. This is slow, but should be really uncommon. | 124 // Swizzle colors. This is slow, but should be really uncommon. |
125 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes()); | 125 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } else if (external_texture_resource_) { | 245 } else if (external_texture_resource_) { |
246 DCHECK(!own_mailbox_); | 246 DCHECK(!own_mailbox_); |
247 ResourceProvider* resource_provider = | 247 ResourceProvider* resource_provider = |
248 layer_tree_impl()->resource_provider(); | 248 layer_tree_impl()->resource_provider(); |
249 resource_provider->DeleteResource(external_texture_resource_); | 249 resource_provider->DeleteResource(external_texture_resource_); |
250 external_texture_resource_ = 0; | 250 external_texture_resource_ = 0; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 } // namespace cc | 254 } // namespace cc |
OLD | NEW |