| OLD | NEW |
| 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 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 const LayerTreeDebugState& new_debug_state) { | 2611 const LayerTreeDebugState& new_debug_state) { |
| 2612 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 2612 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
| 2613 return; | 2613 return; |
| 2614 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 2614 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
| 2615 paint_time_counter_->ClearHistory(); | 2615 paint_time_counter_->ClearHistory(); |
| 2616 | 2616 |
| 2617 debug_state_ = new_debug_state; | 2617 debug_state_ = new_debug_state; |
| 2618 SetFullRootLayerDamage(); | 2618 SetFullRootLayerDamage(); |
| 2619 } | 2619 } |
| 2620 | 2620 |
| 2621 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, | 2621 void LayerTreeHostImpl::CreateUIResource( |
| 2622 const UIResourceBitmap& bitmap) { | 2622 UIResourceId uid, |
| 2623 scoped_refptr<UIResourceBitmap> bitmap) { |
| 2623 DCHECK_GT(uid, 0); | 2624 DCHECK_GT(uid, 0); |
| 2624 DCHECK_EQ(bitmap.GetFormat(), UIResourceBitmap::RGBA8); | 2625 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); |
| 2625 | 2626 |
| 2626 GLint wrap_mode = 0; | 2627 GLint wrap_mode = 0; |
| 2627 switch (bitmap.GetWrapMode()) { | 2628 switch (bitmap->GetWrapMode()) { |
| 2628 case UIResourceBitmap::CLAMP_TO_EDGE: | 2629 case UIResourceBitmap::CLAMP_TO_EDGE: |
| 2629 wrap_mode = GL_CLAMP_TO_EDGE; | 2630 wrap_mode = GL_CLAMP_TO_EDGE; |
| 2630 break; | 2631 break; |
| 2631 case UIResourceBitmap::REPEAT: | 2632 case UIResourceBitmap::REPEAT: |
| 2632 wrap_mode = GL_REPEAT; | 2633 wrap_mode = GL_REPEAT; |
| 2633 break; | 2634 break; |
| 2634 } | 2635 } |
| 2635 | 2636 |
| 2636 // Allow for multiple creation requests with the same UIResourceId. The | 2637 // Allow for multiple creation requests with the same UIResourceId. The |
| 2637 // previous resource is simply deleted. | 2638 // previous resource is simply deleted. |
| 2638 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2639 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2639 if (id) | 2640 if (id) |
| 2640 DeleteUIResource(uid); | 2641 DeleteUIResource(uid); |
| 2641 id = resource_provider_->CreateResource( | 2642 id = resource_provider_->CreateResource( |
| 2642 bitmap.GetSize(), | 2643 bitmap->GetSize(), |
| 2643 resource_provider_->best_texture_format(), | 2644 resource_provider_->best_texture_format(), |
| 2644 wrap_mode, | 2645 wrap_mode, |
| 2645 ResourceProvider::TextureUsageAny); | 2646 ResourceProvider::TextureUsageAny); |
| 2646 | 2647 |
| 2647 ui_resource_map_[uid] = id; | 2648 ui_resource_map_[uid] = id; |
| 2648 resource_provider_->SetPixels(id, | 2649 resource_provider_->SetPixels(id, |
| 2649 bitmap.GetPixels(), | 2650 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
| 2650 gfx::Rect(bitmap.GetSize()), | 2651 gfx::Rect(bitmap->GetSize()), |
| 2651 gfx::Rect(bitmap.GetSize()), | 2652 gfx::Rect(bitmap->GetSize()), |
| 2652 gfx::Vector2d(0, 0)); | 2653 gfx::Vector2d(0, 0)); |
| 2653 MarkUIResourceNotEvicted(uid); | 2654 MarkUIResourceNotEvicted(uid); |
| 2654 } | 2655 } |
| 2655 | 2656 |
| 2656 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2657 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2657 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2658 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2658 if (id) { | 2659 if (id) { |
| 2659 resource_provider_->DeleteResource(id); | 2660 resource_provider_->DeleteResource(id); |
| 2660 ui_resource_map_.erase(uid); | 2661 ui_resource_map_.erase(uid); |
| 2661 } | 2662 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 std::set<UIResourceId>::iterator found_in_evicted = | 2696 std::set<UIResourceId>::iterator found_in_evicted = |
| 2696 evicted_ui_resources_.find(uid); | 2697 evicted_ui_resources_.find(uid); |
| 2697 if (found_in_evicted == evicted_ui_resources_.end()) | 2698 if (found_in_evicted == evicted_ui_resources_.end()) |
| 2698 return; | 2699 return; |
| 2699 evicted_ui_resources_.erase(found_in_evicted); | 2700 evicted_ui_resources_.erase(found_in_evicted); |
| 2700 if (evicted_ui_resources_.empty()) | 2701 if (evicted_ui_resources_.empty()) |
| 2701 client_->OnCanDrawStateChanged(CanDraw()); | 2702 client_->OnCanDrawStateChanged(CanDraw()); |
| 2702 } | 2703 } |
| 2703 | 2704 |
| 2704 } // namespace cc | 2705 } // namespace cc |
| OLD | NEW |