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 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3279 case UIResourceBitmap::CLAMP_TO_EDGE: | 3279 case UIResourceBitmap::CLAMP_TO_EDGE: |
3280 wrap_mode = GL_CLAMP_TO_EDGE; | 3280 wrap_mode = GL_CLAMP_TO_EDGE; |
3281 break; | 3281 break; |
3282 case UIResourceBitmap::REPEAT: | 3282 case UIResourceBitmap::REPEAT: |
3283 wrap_mode = GL_REPEAT; | 3283 wrap_mode = GL_REPEAT; |
3284 break; | 3284 break; |
3285 } | 3285 } |
3286 | 3286 |
3287 // Allow for multiple creation requests with the same UIResourceId. The | 3287 // Allow for multiple creation requests with the same UIResourceId. The |
3288 // previous resource is simply deleted. | 3288 // previous resource is simply deleted. |
3289 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 3289 ResourceId id = ResourceIdForUIResource(uid); |
3290 if (id) | 3290 if (id) |
3291 DeleteUIResource(uid); | 3291 DeleteUIResource(uid); |
3292 | 3292 |
3293 ResourceFormat format = resource_provider_->best_texture_format(); | 3293 ResourceFormat format = resource_provider_->best_texture_format(); |
3294 switch (bitmap.GetFormat()) { | 3294 switch (bitmap.GetFormat()) { |
3295 case UIResourceBitmap::RGBA8: | 3295 case UIResourceBitmap::RGBA8: |
3296 break; | 3296 break; |
3297 case UIResourceBitmap::ALPHA_8: | 3297 case UIResourceBitmap::ALPHA_8: |
3298 format = ALPHA_8; | 3298 format = ALPHA_8; |
3299 break; | 3299 break; |
(...skipping 12 matching lines...) Expand all Loading... |
3312 | 3312 |
3313 ui_resource_map_[uid] = data; | 3313 ui_resource_map_[uid] = data; |
3314 | 3314 |
3315 AutoLockUIResourceBitmap bitmap_lock(bitmap); | 3315 AutoLockUIResourceBitmap bitmap_lock(bitmap); |
3316 resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), | 3316 resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), |
3317 bitmap.GetSize()); | 3317 bitmap.GetSize()); |
3318 MarkUIResourceNotEvicted(uid); | 3318 MarkUIResourceNotEvicted(uid); |
3319 } | 3319 } |
3320 | 3320 |
3321 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 3321 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
3322 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 3322 ResourceId id = ResourceIdForUIResource(uid); |
3323 if (id) { | 3323 if (id) { |
3324 resource_provider_->DeleteResource(id); | 3324 resource_provider_->DeleteResource(id); |
3325 ui_resource_map_.erase(uid); | 3325 ui_resource_map_.erase(uid); |
3326 } | 3326 } |
3327 MarkUIResourceNotEvicted(uid); | 3327 MarkUIResourceNotEvicted(uid); |
3328 } | 3328 } |
3329 | 3329 |
3330 void LayerTreeHostImpl::EvictAllUIResources() { | 3330 void LayerTreeHostImpl::EvictAllUIResources() { |
3331 if (ui_resource_map_.empty()) | 3331 if (ui_resource_map_.empty()) |
3332 return; | 3332 return; |
3333 | 3333 |
3334 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 3334 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
3335 iter != ui_resource_map_.end(); | 3335 iter != ui_resource_map_.end(); |
3336 ++iter) { | 3336 ++iter) { |
3337 evicted_ui_resources_.insert(iter->first); | 3337 evicted_ui_resources_.insert(iter->first); |
3338 resource_provider_->DeleteResource(iter->second.resource_id); | 3338 resource_provider_->DeleteResource(iter->second.resource_id); |
3339 } | 3339 } |
3340 ui_resource_map_.clear(); | 3340 ui_resource_map_.clear(); |
3341 | 3341 |
3342 client_->SetNeedsCommitOnImplThread(); | 3342 client_->SetNeedsCommitOnImplThread(); |
3343 client_->OnCanDrawStateChanged(CanDraw()); | 3343 client_->OnCanDrawStateChanged(CanDraw()); |
3344 client_->RenewTreePriority(); | 3344 client_->RenewTreePriority(); |
3345 } | 3345 } |
3346 | 3346 |
3347 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 3347 ResourceId LayerTreeHostImpl::ResourceIdForUIResource(UIResourceId uid) const { |
3348 UIResourceId uid) const { | |
3349 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 3348 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
3350 if (iter != ui_resource_map_.end()) | 3349 if (iter != ui_resource_map_.end()) |
3351 return iter->second.resource_id; | 3350 return iter->second.resource_id; |
3352 return 0; | 3351 return 0; |
3353 } | 3352 } |
3354 | 3353 |
3355 bool LayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) const { | 3354 bool LayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) const { |
3356 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 3355 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
3357 DCHECK(iter != ui_resource_map_.end()); | 3356 DCHECK(iter != ui_resource_map_.end()); |
3358 return iter->second.opaque; | 3357 return iter->second.opaque; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3434 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3433 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3435 | 3434 |
3436 curve->UpdateTarget( | 3435 curve->UpdateTarget( |
3437 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3436 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3438 .InSecondsF(), | 3437 .InSecondsF(), |
3439 new_target); | 3438 new_target); |
3440 | 3439 |
3441 return true; | 3440 return true; |
3442 } | 3441 } |
3443 } // namespace cc | 3442 } // namespace cc |
OLD | NEW |