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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 22529002: [cc] Allow resources and ui resources to specify wrap mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix botched resolve 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
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 debug_state_ = new_debug_state; 2595 debug_state_ = new_debug_state;
2596 SetFullRootLayerDamage(); 2596 SetFullRootLayerDamage();
2597 } 2597 }
2598 2598
2599 void LayerTreeHostImpl::CreateUIResource( 2599 void LayerTreeHostImpl::CreateUIResource(
2600 UIResourceId uid, 2600 UIResourceId uid,
2601 scoped_refptr<UIResourceBitmap> bitmap) { 2601 scoped_refptr<UIResourceBitmap> bitmap) {
2602 DCHECK_GT(uid, 0); 2602 DCHECK_GT(uid, 0);
2603 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); 2603 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8);
2604 2604
2605 GLint wrap_mode = 0;
2606 switch (bitmap->GetWrapMode()) {
2607 case UIResourceBitmap::CLAMP_TO_EDGE:
2608 wrap_mode = GL_CLAMP_TO_EDGE;
2609 break;
2610 case UIResourceBitmap::REPEAT:
2611 wrap_mode = GL_REPEAT;
2612 break;
2613 }
2614
2605 // Allow for multiple creation requests with the same UIResourceId. The 2615 // Allow for multiple creation requests with the same UIResourceId. The
2606 // previous resource is simply deleted. 2616 // previous resource is simply deleted.
2607 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2617 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2608 if (id) 2618 if (id)
2609 DeleteUIResource(uid); 2619 DeleteUIResource(uid);
2610 id = resource_provider_->CreateResource( 2620 id = resource_provider_->CreateResource(
2611 bitmap->GetSize(), 2621 bitmap->GetSize(),
2612 resource_provider_->best_texture_format(), 2622 resource_provider_->best_texture_format(),
2623 wrap_mode,
2613 ResourceProvider::TextureUsageAny); 2624 ResourceProvider::TextureUsageAny);
2614 2625
2615 ui_resource_map_[uid] = id; 2626 ui_resource_map_[uid] = id;
2616 resource_provider_->SetPixels(id, 2627 resource_provider_->SetPixels(id,
2617 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), 2628 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2618 gfx::Rect(bitmap->GetSize()), 2629 gfx::Rect(bitmap->GetSize()),
2619 gfx::Rect(bitmap->GetSize()), 2630 gfx::Rect(bitmap->GetSize()),
2620 gfx::Vector2d(0, 0)); 2631 gfx::Vector2d(0, 0));
2621 } 2632 }
2622 2633
2623 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 2634 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2624 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2635 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2625 if (id) { 2636 if (id) {
2626 resource_provider_->DeleteResource(id); 2637 resource_provider_->DeleteResource(id);
2627 ui_resource_map_.erase(uid); 2638 ui_resource_map_.erase(uid);
2628 } 2639 }
2629 } 2640 }
2630 2641
2631 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2642 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2632 UIResourceId uid) const { 2643 UIResourceId uid) const {
2633 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2644 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2634 if (iter != ui_resource_map_.end()) 2645 if (iter != ui_resource_map_.end())
2635 return iter->second; 2646 return iter->second;
2636 return 0; 2647 return 0;
2637 } 2648 }
2638 2649
2639 } // namespace cc 2650 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698