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/output/renderer.h" | 10 #include "cc/output/renderer.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Have to upload a copy to a texture for it to be used in a | 96 // Have to upload a copy to a texture for it to be used in a |
97 // hardware draw. | 97 // hardware draw. |
98 if (!texture_copy_) | 98 if (!texture_copy_) |
99 texture_copy_ = ScopedResource::Create(resource_provider); | 99 texture_copy_ = ScopedResource::Create(resource_provider); |
100 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || | 100 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || |
101 resource_provider->InUseByConsumer(texture_copy_->id())) | 101 resource_provider->InUseByConsumer(texture_copy_->id())) |
102 texture_copy_->Free(); | 102 texture_copy_->Free(); |
103 | 103 |
104 if (!texture_copy_->id()) { | 104 if (!texture_copy_->id()) { |
105 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), | 105 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), |
106 ResourceProvider::TextureUsageAny, | 106 ResourceProvider::TextureHintImmutable, |
107 resource_provider->best_texture_format()); | 107 resource_provider->best_texture_format()); |
108 } | 108 } |
109 | 109 |
110 if (texture_copy_->id()) { | 110 if (texture_copy_->id()) { |
111 std::vector<uint8> swizzled; | 111 std::vector<uint8> swizzled; |
112 uint8* pixels = | 112 uint8* pixels = |
113 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); | 113 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); |
114 | 114 |
115 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 115 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
116 // Swizzle colors. This is slow, but should be really uncommon. | 116 // Swizzle colors. This is slow, but should be really uncommon. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } else if (external_texture_resource_) { | 247 } else if (external_texture_resource_) { |
248 DCHECK(!own_mailbox_); | 248 DCHECK(!own_mailbox_); |
249 ResourceProvider* resource_provider = | 249 ResourceProvider* resource_provider = |
250 layer_tree_impl()->resource_provider(); | 250 layer_tree_impl()->resource_provider(); |
251 resource_provider->DeleteResource(external_texture_resource_); | 251 resource_provider->DeleteResource(external_texture_resource_); |
252 external_texture_resource_ = 0; | 252 external_texture_resource_ = 0; |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 } // namespace cc | 256 } // namespace cc |
OLD | NEW |