| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "cc/resources/ui_resource_bitmap.h" | 43 #include "cc/resources/ui_resource_bitmap.h" |
| 44 #include "cc/scheduler/delay_based_time_source.h" | 44 #include "cc/scheduler/delay_based_time_source.h" |
| 45 #include "cc/scheduler/texture_uploader.h" | 45 #include "cc/scheduler/texture_uploader.h" |
| 46 #include "cc/trees/damage_tracker.h" | 46 #include "cc/trees/damage_tracker.h" |
| 47 #include "cc/trees/layer_tree_host.h" | 47 #include "cc/trees/layer_tree_host.h" |
| 48 #include "cc/trees/layer_tree_host_common.h" | 48 #include "cc/trees/layer_tree_host_common.h" |
| 49 #include "cc/trees/layer_tree_impl.h" | 49 #include "cc/trees/layer_tree_impl.h" |
| 50 #include "cc/trees/quad_culler.h" | 50 #include "cc/trees/quad_culler.h" |
| 51 #include "cc/trees/single_thread_proxy.h" | 51 #include "cc/trees/single_thread_proxy.h" |
| 52 #include "cc/trees/tree_synchronizer.h" | 52 #include "cc/trees/tree_synchronizer.h" |
| 53 #include "gpu/GLES2/gl2extchromium.h" |
| 53 #include "ui/gfx/size_conversions.h" | 54 #include "ui/gfx/size_conversions.h" |
| 54 #include "ui/gfx/vector2d_conversions.h" | 55 #include "ui/gfx/vector2d_conversions.h" |
| 55 | 56 |
| 56 namespace { | 57 namespace { |
| 57 | 58 |
| 58 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { | 59 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { |
| 59 if (visible) { | 60 if (visible) { |
| 60 TRACE_EVENT_ASYNC_BEGIN1("webkit", | 61 TRACE_EVENT_ASYNC_BEGIN1("webkit", |
| 61 "LayerTreeHostImpl::SetVisible", | 62 "LayerTreeHostImpl::SetVisible", |
| 62 id, | 63 id, |
| (...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 debug_state_ = new_debug_state; | 2466 debug_state_ = new_debug_state; |
| 2466 SetFullRootLayerDamage(); | 2467 SetFullRootLayerDamage(); |
| 2467 } | 2468 } |
| 2468 | 2469 |
| 2469 void LayerTreeHostImpl::CreateUIResource( | 2470 void LayerTreeHostImpl::CreateUIResource( |
| 2470 UIResourceId uid, | 2471 UIResourceId uid, |
| 2471 scoped_refptr<UIResourceBitmap> bitmap) { | 2472 scoped_refptr<UIResourceBitmap> bitmap) { |
| 2472 DCHECK_GT(uid, 0); | 2473 DCHECK_GT(uid, 0); |
| 2473 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); | 2474 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); |
| 2474 | 2475 |
| 2476 GLint wrap_mode = 0; |
| 2477 switch (bitmap->GetWrapMode()) { |
| 2478 case UIResourceBitmap::ClampToEdge: |
| 2479 wrap_mode = GL_CLAMP_TO_EDGE; |
| 2480 break; |
| 2481 case UIResourceBitmap::Repeat: |
| 2482 wrap_mode = GL_REPEAT; |
| 2483 break; |
| 2484 default: |
| 2485 NOTREACHED(); |
| 2486 break; |
| 2487 } |
| 2488 |
| 2475 // Allow for multiple creation requests with the same UIResourceId. The | 2489 // Allow for multiple creation requests with the same UIResourceId. The |
| 2476 // previous resource is simply deleted. | 2490 // previous resource is simply deleted. |
| 2477 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2491 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2478 if (id) | 2492 if (id) |
| 2479 DeleteUIResource(uid); | 2493 DeleteUIResource(uid); |
| 2480 id = resource_provider_->CreateResource( | 2494 id = resource_provider_->CreateGLTexture(bitmap->GetSize(), |
| 2481 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny); | 2495 GL_RGBA, |
| 2482 | 2496 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
| 2497 wrap_mode, |
| 2498 ResourceProvider::TextureUsageAny); |
| 2483 ui_resource_map_[uid] = id; | 2499 ui_resource_map_[uid] = id; |
| 2484 resource_provider_->SetPixels(id, | 2500 resource_provider_->SetPixels(id, |
| 2485 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), | 2501 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
| 2486 gfx::Rect(bitmap->GetSize()), | 2502 gfx::Rect(bitmap->GetSize()), |
| 2487 gfx::Rect(bitmap->GetSize()), | 2503 gfx::Rect(bitmap->GetSize()), |
| 2488 gfx::Vector2d(0, 0)); | 2504 gfx::Vector2d(0, 0)); |
| 2489 } | 2505 } |
| 2490 | 2506 |
| 2491 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2507 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2492 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2508 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2493 if (id) { | 2509 if (id) { |
| 2494 resource_provider_->DeleteResource(id); | 2510 resource_provider_->DeleteResource(id); |
| 2495 ui_resource_map_.erase(uid); | 2511 ui_resource_map_.erase(uid); |
| 2496 } | 2512 } |
| 2497 } | 2513 } |
| 2498 | 2514 |
| 2499 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2515 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2500 UIResourceId uid) const { | 2516 UIResourceId uid) const { |
| 2501 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2517 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2502 if (iter != ui_resource_map_.end()) | 2518 if (iter != ui_resource_map_.end()) |
| 2503 return iter->second; | 2519 return iter->second; |
| 2504 return 0; | 2520 return 0; |
| 2505 } | 2521 } |
| 2506 | 2522 |
| 2507 } // namespace cc | 2523 } // namespace cc |
| OLD | NEW |