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 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 case UIResourceBitmap::CLAMP_TO_EDGE: | 3241 case UIResourceBitmap::CLAMP_TO_EDGE: |
3242 wrap_mode = GL_CLAMP_TO_EDGE; | 3242 wrap_mode = GL_CLAMP_TO_EDGE; |
3243 break; | 3243 break; |
3244 case UIResourceBitmap::REPEAT: | 3244 case UIResourceBitmap::REPEAT: |
3245 wrap_mode = GL_REPEAT; | 3245 wrap_mode = GL_REPEAT; |
3246 break; | 3246 break; |
3247 } | 3247 } |
3248 | 3248 |
3249 // Allow for multiple creation requests with the same UIResourceId. The | 3249 // Allow for multiple creation requests with the same UIResourceId. The |
3250 // previous resource is simply deleted. | 3250 // previous resource is simply deleted. |
3251 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 3251 ResourceId id = ResourceIdForUIResource(uid); |
3252 if (id) | 3252 if (id) |
3253 DeleteUIResource(uid); | 3253 DeleteUIResource(uid); |
3254 | 3254 |
3255 ResourceFormat format = resource_provider_->best_texture_format(); | 3255 ResourceFormat format = resource_provider_->best_texture_format(); |
3256 switch (bitmap.GetFormat()) { | 3256 switch (bitmap.GetFormat()) { |
3257 case UIResourceBitmap::RGBA8: | 3257 case UIResourceBitmap::RGBA8: |
3258 break; | 3258 break; |
3259 case UIResourceBitmap::ALPHA_8: | 3259 case UIResourceBitmap::ALPHA_8: |
3260 format = ALPHA_8; | 3260 format = ALPHA_8; |
3261 break; | 3261 break; |
(...skipping 12 matching lines...) Expand all Loading... |
3274 | 3274 |
3275 ui_resource_map_[uid] = data; | 3275 ui_resource_map_[uid] = data; |
3276 | 3276 |
3277 AutoLockUIResourceBitmap bitmap_lock(bitmap); | 3277 AutoLockUIResourceBitmap bitmap_lock(bitmap); |
3278 resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), | 3278 resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), |
3279 bitmap.GetSize()); | 3279 bitmap.GetSize()); |
3280 MarkUIResourceNotEvicted(uid); | 3280 MarkUIResourceNotEvicted(uid); |
3281 } | 3281 } |
3282 | 3282 |
3283 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 3283 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
3284 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 3284 ResourceId id = ResourceIdForUIResource(uid); |
3285 if (id) { | 3285 if (id) { |
3286 resource_provider_->DeleteResource(id); | 3286 resource_provider_->DeleteResource(id); |
3287 ui_resource_map_.erase(uid); | 3287 ui_resource_map_.erase(uid); |
3288 } | 3288 } |
3289 MarkUIResourceNotEvicted(uid); | 3289 MarkUIResourceNotEvicted(uid); |
3290 } | 3290 } |
3291 | 3291 |
3292 void LayerTreeHostImpl::EvictAllUIResources() { | 3292 void LayerTreeHostImpl::EvictAllUIResources() { |
3293 if (ui_resource_map_.empty()) | 3293 if (ui_resource_map_.empty()) |
3294 return; | 3294 return; |
3295 | 3295 |
3296 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 3296 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
3297 iter != ui_resource_map_.end(); | 3297 iter != ui_resource_map_.end(); |
3298 ++iter) { | 3298 ++iter) { |
3299 evicted_ui_resources_.insert(iter->first); | 3299 evicted_ui_resources_.insert(iter->first); |
3300 resource_provider_->DeleteResource(iter->second.resource_id); | 3300 resource_provider_->DeleteResource(iter->second.resource_id); |
3301 } | 3301 } |
3302 ui_resource_map_.clear(); | 3302 ui_resource_map_.clear(); |
3303 | 3303 |
3304 client_->SetNeedsCommitOnImplThread(); | 3304 client_->SetNeedsCommitOnImplThread(); |
3305 client_->OnCanDrawStateChanged(CanDraw()); | 3305 client_->OnCanDrawStateChanged(CanDraw()); |
3306 client_->RenewTreePriority(); | 3306 client_->RenewTreePriority(); |
3307 } | 3307 } |
3308 | 3308 |
3309 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 3309 ResourceId LayerTreeHostImpl::ResourceIdForUIResource(UIResourceId uid) const { |
3310 UIResourceId uid) const { | |
3311 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 3310 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
3312 if (iter != ui_resource_map_.end()) | 3311 if (iter != ui_resource_map_.end()) |
3313 return iter->second.resource_id; | 3312 return iter->second.resource_id; |
3314 return 0; | 3313 return 0; |
3315 } | 3314 } |
3316 | 3315 |
3317 bool LayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) const { | 3316 bool LayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) const { |
3318 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 3317 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
3319 DCHECK(iter != ui_resource_map_.end()); | 3318 DCHECK(iter != ui_resource_map_.end()); |
3320 return iter->second.opaque; | 3319 return iter->second.opaque; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3395 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3397 | 3396 |
3398 curve->UpdateTarget( | 3397 curve->UpdateTarget( |
3399 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3398 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3400 .InSecondsF(), | 3399 .InSecondsF(), |
3401 new_target); | 3400 new_target); |
3402 | 3401 |
3403 return true; | 3402 return true; |
3404 } | 3403 } |
3405 } // namespace cc | 3404 } // namespace cc |
OLD | NEW |