Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Side by Side Diff: cc/layers/texture_layer_impl.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move stride check to RWP Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) {
104 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), 106 texture_copy_->Allocate(texture_mailbox_.shared_memory_size(),
105 resource_provider->best_texture_format(), 107 ResourceProvider::TextureUsageAny,
106 ResourceProvider::TextureUsageAny); 108 resource_provider->best_texture_format());
107 } 109 }
108 110
109 if (texture_copy_->id()) { 111 if (texture_copy_->id()) {
110 std::vector<uint8> swizzled; 112 std::vector<uint8> swizzled;
111 uint8* pixels = 113 uint8* pixels =
112 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory()); 114 static_cast<uint8*>(texture_mailbox_.shared_memory()->memory());
113 115
114 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) { 116 if (!PlatformColor::SameComponentOrder(texture_copy_->format())) {
115 // Swizzle colors. This is slow, but should be really uncommon. 117 // Swizzle colors. This is slow, but should be really uncommon.
116 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes()); 118 swizzled.resize(texture_mailbox_.shared_memory_size_in_bytes());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } else if (external_texture_resource_) { 235 } else if (external_texture_resource_) {
234 DCHECK(!own_mailbox_); 236 DCHECK(!own_mailbox_);
235 ResourceProvider* resource_provider = 237 ResourceProvider* resource_provider =
236 layer_tree_impl()->resource_provider(); 238 layer_tree_impl()->resource_provider();
237 resource_provider->DeleteResource(external_texture_resource_); 239 resource_provider->DeleteResource(external_texture_resource_);
238 external_texture_resource_ = 0; 240 external_texture_resource_ = 0;
239 } 241 }
240 } 242 }
241 243
242 } // namespace cc 244 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698