| 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> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // hardware draw. | 104 // hardware draw. |
| 105 if (!texture_copy_) | 105 if (!texture_copy_) |
| 106 texture_copy_ = ScopedResource::Create(resource_provider); | 106 texture_copy_ = ScopedResource::Create(resource_provider); |
| 107 if (texture_copy_->size() != texture_mailbox_.size_in_pixels() || | 107 if (texture_copy_->size() != texture_mailbox_.size_in_pixels() || |
| 108 resource_provider->InUseByConsumer(texture_copy_->id())) | 108 resource_provider->InUseByConsumer(texture_copy_->id())) |
| 109 texture_copy_->Free(); | 109 texture_copy_->Free(); |
| 110 | 110 |
| 111 if (!texture_copy_->id()) { | 111 if (!texture_copy_->id()) { |
| 112 texture_copy_->Allocate(texture_mailbox_.size_in_pixels(), | 112 texture_copy_->Allocate(texture_mailbox_.size_in_pixels(), |
| 113 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 113 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 114 resource_provider->best_texture_format()); | 114 resource_provider->best_texture_format(), |
| 115 gfx::ColorSpace()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 if (texture_copy_->id()) { | 118 if (texture_copy_->id()) { |
| 118 std::vector<uint8_t> swizzled; | 119 std::vector<uint8_t> swizzled; |
| 119 uint8_t* pixels = texture_mailbox_.shared_bitmap()->pixels(); | 120 uint8_t* pixels = texture_mailbox_.shared_bitmap()->pixels(); |
| 120 | 121 |
| 121 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { | 122 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { |
| 122 // Swizzle colors. This is slow, but should be really uncommon. | 123 // Swizzle colors. This is slow, but should be really uncommon. |
| 123 size_t bytes = texture_mailbox_.SharedMemorySizeInBytes(); | 124 size_t bytes = texture_mailbox_.SharedMemorySizeInBytes(); |
| 124 swizzled.resize(bytes); | 125 swizzled.resize(bytes); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } else if (external_texture_resource_) { | 260 } else if (external_texture_resource_) { |
| 260 DCHECK(!own_mailbox_); | 261 DCHECK(!own_mailbox_); |
| 261 ResourceProvider* resource_provider = | 262 ResourceProvider* resource_provider = |
| 262 layer_tree_impl()->resource_provider(); | 263 layer_tree_impl()->resource_provider(); |
| 263 resource_provider->DeleteResource(external_texture_resource_); | 264 resource_provider->DeleteResource(external_texture_resource_); |
| 264 external_texture_resource_ = 0; | 265 external_texture_resource_ = 0; |
| 265 } | 266 } |
| 266 } | 267 } |
| 267 | 268 |
| 268 } // namespace cc | 269 } // namespace cc |
| OLD | NEW |