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

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: rebased 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_impl.h ('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 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 const LayerTreeDebugState& new_debug_state) { 2622 const LayerTreeDebugState& new_debug_state) {
2623 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2623 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2624 return; 2624 return;
2625 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2625 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2626 paint_time_counter_->ClearHistory(); 2626 paint_time_counter_->ClearHistory();
2627 2627
2628 debug_state_ = new_debug_state; 2628 debug_state_ = new_debug_state;
2629 SetFullRootLayerDamage(); 2629 SetFullRootLayerDamage();
2630 } 2630 }
2631 2631
2632 void LayerTreeHostImpl::CreateUIResource( 2632 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid,
2633 UIResourceId uid, 2633 const UIResourceBitmap& bitmap) {
2634 scoped_refptr<UIResourceBitmap> bitmap) {
2635 DCHECK_GT(uid, 0); 2634 DCHECK_GT(uid, 0);
2636 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); 2635 DCHECK_EQ(bitmap.GetFormat(), UIResourceBitmap::RGBA8);
2637 2636
2638 GLint wrap_mode = 0; 2637 GLint wrap_mode = 0;
2639 switch (bitmap->GetWrapMode()) { 2638 switch (bitmap.GetWrapMode()) {
2640 case UIResourceBitmap::CLAMP_TO_EDGE: 2639 case UIResourceBitmap::CLAMP_TO_EDGE:
2641 wrap_mode = GL_CLAMP_TO_EDGE; 2640 wrap_mode = GL_CLAMP_TO_EDGE;
2642 break; 2641 break;
2643 case UIResourceBitmap::REPEAT: 2642 case UIResourceBitmap::REPEAT:
2644 wrap_mode = GL_REPEAT; 2643 wrap_mode = GL_REPEAT;
2645 break; 2644 break;
2646 } 2645 }
2647 2646
2648 // Allow for multiple creation requests with the same UIResourceId. The 2647 // Allow for multiple creation requests with the same UIResourceId. The
2649 // previous resource is simply deleted. 2648 // previous resource is simply deleted.
2650 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2649 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2651 if (id) 2650 if (id)
2652 DeleteUIResource(uid); 2651 DeleteUIResource(uid);
2653 id = resource_provider_->CreateResource( 2652 id = resource_provider_->CreateResource(
2654 bitmap->GetSize(), 2653 bitmap.GetSize(),
2655 wrap_mode, 2654 wrap_mode,
2656 ResourceProvider::TextureUsageAny, 2655 ResourceProvider::TextureUsageAny,
2657 resource_provider_->best_texture_format()); 2656 resource_provider_->best_texture_format());
2658 2657
2659 ui_resource_map_[uid] = id; 2658 ui_resource_map_[uid] = id;
2660 resource_provider_->SetPixels(id, 2659 resource_provider_->SetPixels(id,
2661 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), 2660 bitmap.GetPixels(),
2662 gfx::Rect(bitmap->GetSize()), 2661 gfx::Rect(bitmap.GetSize()),
2663 gfx::Rect(bitmap->GetSize()), 2662 gfx::Rect(bitmap.GetSize()),
2664 gfx::Vector2d(0, 0)); 2663 gfx::Vector2d(0, 0));
2665 MarkUIResourceNotEvicted(uid); 2664 MarkUIResourceNotEvicted(uid);
2666 } 2665 }
2667 2666
2668 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 2667 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2669 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2668 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2670 if (id) { 2669 if (id) {
2671 resource_provider_->DeleteResource(id); 2670 resource_provider_->DeleteResource(id);
2672 ui_resource_map_.erase(uid); 2671 ui_resource_map_.erase(uid);
2673 } 2672 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 std::set<UIResourceId>::iterator found_in_evicted = 2706 std::set<UIResourceId>::iterator found_in_evicted =
2708 evicted_ui_resources_.find(uid); 2707 evicted_ui_resources_.find(uid);
2709 if (found_in_evicted == evicted_ui_resources_.end()) 2708 if (found_in_evicted == evicted_ui_resources_.end())
2710 return; 2709 return;
2711 evicted_ui_resources_.erase(found_in_evicted); 2710 evicted_ui_resources_.erase(found_in_evicted);
2712 if (evicted_ui_resources_.empty()) 2711 if (evicted_ui_resources_.empty())
2713 client_->OnCanDrawStateChanged(CanDraw()); 2712 client_->OnCanDrawStateChanged(CanDraw());
2714 } 2713 }
2715 2714
2716 } // namespace cc 2715 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698