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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ccameron's fix for exisiting nine-patch uses 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 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 const LayerTreeDebugState& new_debug_state) { 2610 const LayerTreeDebugState& new_debug_state) {
2611 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2611 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2612 return; 2612 return;
2613 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2613 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2614 paint_time_counter_->ClearHistory(); 2614 paint_time_counter_->ClearHistory();
2615 2615
2616 debug_state_ = new_debug_state; 2616 debug_state_ = new_debug_state;
2617 SetFullRootLayerDamage(); 2617 SetFullRootLayerDamage();
2618 } 2618 }
2619 2619
2620 void LayerTreeHostImpl::CreateUIResource( 2620 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid,
2621 UIResourceId uid, 2621 const UIResourceBitmap& bitmap) {
2622 scoped_refptr<UIResourceBitmap> bitmap) {
2623 DCHECK_GT(uid, 0); 2622 DCHECK_GT(uid, 0);
2624 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); 2623 DCHECK_EQ(bitmap.GetFormat(), UIResourceBitmap::RGBA8);
2625 2624
2626 GLint wrap_mode = 0; 2625 GLint wrap_mode = 0;
2627 switch (bitmap->GetWrapMode()) { 2626 switch (bitmap.GetWrapMode()) {
2628 case UIResourceBitmap::CLAMP_TO_EDGE: 2627 case UIResourceBitmap::CLAMP_TO_EDGE:
2629 wrap_mode = GL_CLAMP_TO_EDGE; 2628 wrap_mode = GL_CLAMP_TO_EDGE;
2630 break; 2629 break;
2631 case UIResourceBitmap::REPEAT: 2630 case UIResourceBitmap::REPEAT:
2632 wrap_mode = GL_REPEAT; 2631 wrap_mode = GL_REPEAT;
2633 break; 2632 break;
2634 } 2633 }
2635 2634
2636 // Allow for multiple creation requests with the same UIResourceId. The 2635 // Allow for multiple creation requests with the same UIResourceId. The
2637 // previous resource is simply deleted. 2636 // previous resource is simply deleted.
2638 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2637 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2639 if (id) 2638 if (id)
2640 DeleteUIResource(uid); 2639 DeleteUIResource(uid);
2641 id = resource_provider_->CreateResource( 2640 id = resource_provider_->CreateResource(
2642 bitmap->GetSize(), 2641 bitmap.GetSize(),
2643 resource_provider_->best_texture_format(), 2642 resource_provider_->best_texture_format(),
2644 wrap_mode, 2643 wrap_mode,
2645 ResourceProvider::TextureUsageAny); 2644 ResourceProvider::TextureUsageAny);
2646 2645
2647 ui_resource_map_[uid] = id; 2646 ui_resource_map_[uid] = id;
2648 resource_provider_->SetPixels(id, 2647 resource_provider_->SetPixels(id,
2649 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), 2648 bitmap.GetPixels(),
2650 gfx::Rect(bitmap->GetSize()), 2649 gfx::Rect(bitmap.GetSize()),
2651 gfx::Rect(bitmap->GetSize()), 2650 gfx::Rect(bitmap.GetSize()),
2652 gfx::Vector2d(0, 0)); 2651 gfx::Vector2d(0, 0));
2653 MarkUIResourceNotEvicted(uid); 2652 MarkUIResourceNotEvicted(uid);
2654 } 2653 }
2655 2654
2656 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 2655 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2657 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2656 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2658 if (id) { 2657 if (id) {
2659 resource_provider_->DeleteResource(id); 2658 resource_provider_->DeleteResource(id);
2660 ui_resource_map_.erase(uid); 2659 ui_resource_map_.erase(uid);
2661 } 2660 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2695 std::set<UIResourceId>::iterator found_in_evicted = 2694 std::set<UIResourceId>::iterator found_in_evicted =
2696 evicted_ui_resources_.find(uid); 2695 evicted_ui_resources_.find(uid);
2697 if (found_in_evicted == evicted_ui_resources_.end()) 2696 if (found_in_evicted == evicted_ui_resources_.end())
2698 return; 2697 return;
2699 evicted_ui_resources_.erase(found_in_evicted); 2698 evicted_ui_resources_.erase(found_in_evicted);
2700 if (evicted_ui_resources_.empty()) 2699 if (evicted_ui_resources_.empty())
2701 client_->OnCanDrawStateChanged(CanDraw()); 2700 client_->OnCanDrawStateChanged(CanDraw());
2702 } 2701 }
2703 2702
2704 } // namespace cc 2703 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698