Chromium Code Reviews| 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 | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "cc/resources/ui_resource_bitmap.h" | 45 #include "cc/resources/ui_resource_bitmap.h" |
| 46 #include "cc/scheduler/delay_based_time_source.h" | 46 #include "cc/scheduler/delay_based_time_source.h" |
| 47 #include "cc/scheduler/texture_uploader.h" | 47 #include "cc/scheduler/texture_uploader.h" |
| 48 #include "cc/trees/damage_tracker.h" | 48 #include "cc/trees/damage_tracker.h" |
| 49 #include "cc/trees/layer_tree_host.h" | 49 #include "cc/trees/layer_tree_host.h" |
| 50 #include "cc/trees/layer_tree_host_common.h" | 50 #include "cc/trees/layer_tree_host_common.h" |
| 51 #include "cc/trees/layer_tree_impl.h" | 51 #include "cc/trees/layer_tree_impl.h" |
| 52 #include "cc/trees/quad_culler.h" | 52 #include "cc/trees/quad_culler.h" |
| 53 #include "cc/trees/single_thread_proxy.h" | 53 #include "cc/trees/single_thread_proxy.h" |
| 54 #include "cc/trees/tree_synchronizer.h" | 54 #include "cc/trees/tree_synchronizer.h" |
| 55 #include "gpu/GLES2/gl2extchromium.h" | |
| 55 #include "ui/gfx/size_conversions.h" | 56 #include "ui/gfx/size_conversions.h" |
| 56 #include "ui/gfx/vector2d_conversions.h" | 57 #include "ui/gfx/vector2d_conversions.h" |
| 57 | 58 |
| 58 namespace { | 59 namespace { |
| 59 | 60 |
| 60 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { | 61 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { |
| 61 if (visible) { | 62 if (visible) { |
| 62 TRACE_EVENT_ASYNC_BEGIN1("webkit", | 63 TRACE_EVENT_ASYNC_BEGIN1("webkit", |
| 63 "LayerTreeHostImpl::SetVisible", | 64 "LayerTreeHostImpl::SetVisible", |
| 64 id, | 65 id, |
| (...skipping 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2579 debug_state_ = new_debug_state; | 2580 debug_state_ = new_debug_state; |
| 2580 SetFullRootLayerDamage(); | 2581 SetFullRootLayerDamage(); |
| 2581 } | 2582 } |
| 2582 | 2583 |
| 2583 void LayerTreeHostImpl::CreateUIResource( | 2584 void LayerTreeHostImpl::CreateUIResource( |
| 2584 UIResourceId uid, | 2585 UIResourceId uid, |
| 2585 scoped_refptr<UIResourceBitmap> bitmap) { | 2586 scoped_refptr<UIResourceBitmap> bitmap) { |
| 2586 DCHECK_GT(uid, 0); | 2587 DCHECK_GT(uid, 0); |
| 2587 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); | 2588 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); |
| 2588 | 2589 |
| 2590 GLint wrap_mode = 0; | |
| 2591 switch (bitmap->GetWrapMode()) { | |
| 2592 case UIResourceBitmap::CLAMP_TO_EDGE: | |
| 2593 wrap_mode = GL_CLAMP_TO_EDGE; | |
| 2594 break; | |
| 2595 case UIResourceBitmap::REPEAT: | |
| 2596 wrap_mode = GL_REPEAT; | |
| 2597 break; | |
| 2598 default: | |
| 2599 NOTREACHED(); | |
| 2600 break; | |
| 2601 } | |
| 2602 | |
| 2589 // Allow for multiple creation requests with the same UIResourceId. The | 2603 // Allow for multiple creation requests with the same UIResourceId. The |
| 2590 // previous resource is simply deleted. | 2604 // previous resource is simply deleted. |
| 2591 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2605 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2592 if (id) | 2606 if (id) |
| 2593 DeleteUIResource(uid); | 2607 DeleteUIResource(uid); |
| 2594 id = resource_provider_->CreateResource( | 2608 id = resource_provider_->CreateGLTexture( |
|
enne (OOO)
2013/09/03 22:18:52
This seems like an unfortunate restriction to only
ccameron
2013/09/03 22:52:08
Good point -- done (crbug.com/284796).
| |
| 2595 bitmap->GetSize(), | 2609 bitmap->GetSize(), |
| 2596 resource_provider_->best_texture_format(), | 2610 resource_provider_->best_texture_format(), |
| 2611 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | |
| 2612 wrap_mode, | |
| 2597 ResourceProvider::TextureUsageAny); | 2613 ResourceProvider::TextureUsageAny); |
| 2598 | 2614 |
| 2599 ui_resource_map_[uid] = id; | 2615 ui_resource_map_[uid] = id; |
| 2600 resource_provider_->SetPixels(id, | 2616 resource_provider_->SetPixels(id, |
| 2601 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), | 2617 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
| 2602 gfx::Rect(bitmap->GetSize()), | 2618 gfx::Rect(bitmap->GetSize()), |
| 2603 gfx::Rect(bitmap->GetSize()), | 2619 gfx::Rect(bitmap->GetSize()), |
| 2604 gfx::Vector2d(0, 0)); | 2620 gfx::Vector2d(0, 0)); |
| 2605 } | 2621 } |
| 2606 | 2622 |
| 2607 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2623 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2608 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2624 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2609 if (id) { | 2625 if (id) { |
| 2610 resource_provider_->DeleteResource(id); | 2626 resource_provider_->DeleteResource(id); |
| 2611 ui_resource_map_.erase(uid); | 2627 ui_resource_map_.erase(uid); |
| 2612 } | 2628 } |
| 2613 } | 2629 } |
| 2614 | 2630 |
| 2615 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2631 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2616 UIResourceId uid) const { | 2632 UIResourceId uid) const { |
| 2617 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2633 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2618 if (iter != ui_resource_map_.end()) | 2634 if (iter != ui_resource_map_.end()) |
| 2619 return iter->second; | 2635 return iter->second; |
| 2620 return 0; | 2636 return 0; |
| 2621 } | 2637 } |
| 2622 | 2638 |
| 2623 } // namespace cc | 2639 } // namespace cc |
| OLD | NEW |