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> | |
vangelis
2013/09/11 06:11:37
Is this new include needed?
kaanb
2013/09/12 07:53:44
include-what-you-use presubmit script asked me to
vangelis
2013/09/12 16:41:56
Hmm... Maybe from some previous incarnation of the
kaanb
2013/09/13 00:11:08
vector is being used in line 116. I think the pres
| |
8 | |
7 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
8 #include "cc/layers/quad_sink.h" | 10 #include "cc/layers/quad_sink.h" |
9 #include "cc/output/renderer.h" | 11 #include "cc/output/renderer.h" |
10 #include "cc/quads/texture_draw_quad.h" | 12 #include "cc/quads/texture_draw_quad.h" |
11 #include "cc/resources/platform_color.h" | 13 #include "cc/resources/platform_color.h" |
12 #include "cc/resources/scoped_resource.h" | 14 #include "cc/resources/scoped_resource.h" |
13 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
14 | 16 |
15 namespace cc { | 17 namespace cc { |
16 | 18 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 DCHECK(!external_texture_resource_); | 96 DCHECK(!external_texture_resource_); |
95 // Have to upload a copy to a texture for it to be used in a | 97 // Have to upload a copy to a texture for it to be used in a |
96 // hardware draw. | 98 // hardware draw. |
97 if (!texture_copy_) | 99 if (!texture_copy_) |
98 texture_copy_ = ScopedResource::create(resource_provider); | 100 texture_copy_ = ScopedResource::create(resource_provider); |
99 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || | 101 if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || |
100 resource_provider->InUseByConsumer(texture_copy_->id())) | 102 resource_provider->InUseByConsumer(texture_copy_->id())) |
101 texture_copy_->Free(); | 103 texture_copy_->Free(); |
102 | 104 |
103 if (!texture_copy_->id()) { | 105 if (!texture_copy_->id()) { |
106 GLenum best_texture_format = resource_provider->best_texture_format(); | |
104 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), | 107 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), |
105 resource_provider->best_texture_format(), | 108 best_texture_format, |
106 ResourceProvider::TextureUsageAny); | 109 ResourceProvider::TextureUsageAny, |
110 best_texture_format == GL_RGBA ? | |
111 ResourceProvider::RGBA_8888 : | |
112 ResourceProvider::RGBA_4444); | |
107 } | 113 } |
108 | 114 |
109 if (texture_copy_->id()) { | 115 if (texture_copy_->id()) { |
110 std::vector<uint8> swizzled; | 116 std::vector<uint8> swizzled; |
111 uint8* pixels = | 117 uint8* pixels = |
112 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); | 118 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); |
113 | 119 |
114 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 120 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
115 // Swizzle colors. This is slow, but should be really uncommon. | 121 // Swizzle colors. This is slow, but should be really uncommon. |
116 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes()); | 122 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 } else if (external_texture_resource_) { | 239 } else if (external_texture_resource_) { |
234 DCHECK(!own_mailbox_); | 240 DCHECK(!own_mailbox_); |
235 ResourceProvider* resource_provider = | 241 ResourceProvider* resource_provider = |
236 layer_tree_impl()->resource_provider(); | 242 layer_tree_impl()->resource_provider(); |
237 resource_provider->DeleteResource(external_texture_resource_); | 243 resource_provider->DeleteResource(external_texture_resource_); |
238 external_texture_resource_ = 0; | 244 external_texture_resource_ = 0; |
239 } | 245 } |
240 } | 246 } |
241 | 247 |
242 } // namespace cc | 248 } // namespace cc |
OLD | NEW |