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

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: Incorporate review feedback 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/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 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 debug_state_ = new_debug_state; 2579 debug_state_ = new_debug_state;
2580 SetFullRootLayerDamage(); 2580 SetFullRootLayerDamage();
2581 } 2581 }
2582 2582
2583 void LayerTreeHostImpl::CreateUIResource( 2583 void LayerTreeHostImpl::CreateUIResource(
2584 UIResourceId uid, 2584 UIResourceId uid,
2585 scoped_refptr<UIResourceBitmap> bitmap) { 2585 scoped_refptr<UIResourceBitmap> bitmap) {
2586 DCHECK_GT(uid, 0); 2586 DCHECK_GT(uid, 0);
2587 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); 2587 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8);
2588 2588
2589 GLint wrap_mode = 0;
2590 switch (bitmap->GetWrapMode()) {
2591 case UIResourceBitmap::CLAMP_TO_EDGE:
2592 wrap_mode = GL_CLAMP_TO_EDGE;
2593 break;
2594 case UIResourceBitmap::REPEAT:
2595 wrap_mode = GL_REPEAT;
2596 break;
2597 default:
enne (OOO) 2013/09/04 17:36:56 Can you remove this default case so that the compi
ccameron 2013/09/04 20:00:39 Done.
2598 NOTREACHED();
2599 break;
2600 }
2601
2589 // Allow for multiple creation requests with the same UIResourceId. The 2602 // Allow for multiple creation requests with the same UIResourceId. The
2590 // previous resource is simply deleted. 2603 // previous resource is simply deleted.
2591 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2604 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2592 if (id) 2605 if (id)
2593 DeleteUIResource(uid); 2606 DeleteUIResource(uid);
2594 id = resource_provider_->CreateResource( 2607 id = resource_provider_->CreateResource(
2595 bitmap->GetSize(), 2608 bitmap->GetSize(),
2596 resource_provider_->best_texture_format(), 2609 resource_provider_->best_texture_format(),
2610 wrap_mode,
2597 ResourceProvider::TextureUsageAny); 2611 ResourceProvider::TextureUsageAny);
2598 2612
2599 ui_resource_map_[uid] = id; 2613 ui_resource_map_[uid] = id;
2600 resource_provider_->SetPixels(id, 2614 resource_provider_->SetPixels(id,
2601 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), 2615 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2602 gfx::Rect(bitmap->GetSize()), 2616 gfx::Rect(bitmap->GetSize()),
2603 gfx::Rect(bitmap->GetSize()), 2617 gfx::Rect(bitmap->GetSize()),
2604 gfx::Vector2d(0, 0)); 2618 gfx::Vector2d(0, 0));
2605 } 2619 }
2606 2620
2607 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 2621 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2608 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2622 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2609 if (id) { 2623 if (id) {
2610 resource_provider_->DeleteResource(id); 2624 resource_provider_->DeleteResource(id);
2611 ui_resource_map_.erase(uid); 2625 ui_resource_map_.erase(uid);
2612 } 2626 }
2613 } 2627 }
2614 2628
2615 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2629 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2616 UIResourceId uid) const { 2630 UIResourceId uid) const {
2617 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2631 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2618 if (iter != ui_resource_map_.end()) 2632 if (iter != ui_resource_map_.end())
2619 return iter->second; 2633 return iter->second;
2620 return 0; 2634 return 0;
2621 } 2635 }
2622 2636
2623 } // namespace cc 2637 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698