| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/prioritized_resource.h" | 5 #include "cc/resources/prioritized_resource.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/resources/platform_color.h" | 9 #include "cc/resources/platform_color.h" |
| 10 #include "cc/resources/prioritized_resource_manager.h" | 10 #include "cc/resources/prioritized_resource_manager.h" |
| 11 #include "cc/resources/priority_calculator.h" | 11 #include "cc/resources/priority_calculator.h" |
| 12 #include "cc/trees/proxy.h" | 12 #include "cc/trees/proxy.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, | 16 PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, |
| 17 const gfx::Size& size, | 17 gfx::Size size, |
| 18 ResourceFormat format) | 18 ResourceFormat format) |
| 19 : size_(size), | 19 : size_(size), |
| 20 format_(format), | 20 format_(format), |
| 21 bytes_(0), | 21 bytes_(0), |
| 22 contents_swizzled_(false), | 22 contents_swizzled_(false), |
| 23 priority_(PriorityCalculator::LowestPriority()), | 23 priority_(PriorityCalculator::LowestPriority()), |
| 24 is_above_priority_cutoff_(false), | 24 is_above_priority_cutoff_(false), |
| 25 is_self_managed_(false), | 25 is_self_managed_(false), |
| 26 backing_(NULL), | 26 backing_(NULL), |
| 27 manager_(NULL) { | 27 manager_(NULL) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 void PrioritizedResource::SetTextureManager( | 38 void PrioritizedResource::SetTextureManager( |
| 39 PrioritizedResourceManager* manager) { | 39 PrioritizedResourceManager* manager) { |
| 40 if (manager_ == manager) | 40 if (manager_ == manager) |
| 41 return; | 41 return; |
| 42 if (manager_) | 42 if (manager_) |
| 43 manager_->UnregisterTexture(this); | 43 manager_->UnregisterTexture(this); |
| 44 if (manager) | 44 if (manager) |
| 45 manager->RegisterTexture(this); | 45 manager->RegisterTexture(this); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void PrioritizedResource::SetDimensions(const gfx::Size& size, | 48 void PrioritizedResource::SetDimensions(gfx::Size size, ResourceFormat format) { |
| 49 ResourceFormat format) { | |
| 50 if (format_ != format || size_ != size) { | 49 if (format_ != format || size_ != size) { |
| 51 is_above_priority_cutoff_ = false; | 50 is_above_priority_cutoff_ = false; |
| 52 format_ = format; | 51 format_ = format; |
| 53 size_ = size; | 52 size_ = size; |
| 54 bytes_ = Resource::MemorySizeBytes(size, format); | 53 bytes_ = Resource::MemorySizeBytes(size, format); |
| 55 DCHECK(manager_ || !backing_); | 54 DCHECK(manager_ || !backing_); |
| 56 if (manager_) | 55 if (manager_) |
| 57 manager_->ReturnBackingTexture(this); | 56 manager_->ReturnBackingTexture(this); |
| 58 } | 57 } |
| 59 } | 58 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 110 } |
| 112 | 111 |
| 113 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { | 112 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { |
| 114 SetDimensions(gfx::Size(), RGBA_8888); | 113 SetDimensions(gfx::Size(), RGBA_8888); |
| 115 set_is_self_managed(true); | 114 set_is_self_managed(true); |
| 116 bytes_ = bytes; | 115 bytes_ = bytes; |
| 117 } | 116 } |
| 118 | 117 |
| 119 PrioritizedResource::Backing::Backing(unsigned id, | 118 PrioritizedResource::Backing::Backing(unsigned id, |
| 120 ResourceProvider* resource_provider, | 119 ResourceProvider* resource_provider, |
| 121 const gfx::Size& size, | 120 gfx::Size size, |
| 122 ResourceFormat format) | 121 ResourceFormat format) |
| 123 : Resource(id, size, format), | 122 : Resource(id, size, format), |
| 124 owner_(NULL), | 123 owner_(NULL), |
| 125 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), | 124 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), |
| 126 was_above_priority_cutoff_at_last_priority_update_(false), | 125 was_above_priority_cutoff_at_last_priority_update_(false), |
| 127 in_drawing_impl_tree_(false), | 126 in_drawing_impl_tree_(false), |
| 128 in_parent_compositor_(false), | 127 in_parent_compositor_(false), |
| 129 #ifdef NDEBUG | 128 #ifdef NDEBUG |
| 130 resource_has_been_deleted_(false) {} | 129 resource_has_been_deleted_(false) {} |
| 131 #else | 130 #else |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 manager_->ReturnBackingTexture(this); | 192 manager_->ReturnBackingTexture(this); |
| 194 } | 193 } |
| 195 | 194 |
| 196 const Proxy* PrioritizedResource::Backing::proxy() const { | 195 const Proxy* PrioritizedResource::Backing::proxy() const { |
| 197 if (!owner_ || !owner_->resource_manager()) | 196 if (!owner_ || !owner_->resource_manager()) |
| 198 return NULL; | 197 return NULL; |
| 199 return owner_->resource_manager()->ProxyForDebug(); | 198 return owner_->resource_manager()->ProxyForDebug(); |
| 200 } | 199 } |
| 201 | 200 |
| 202 } // namespace cc | 201 } // namespace cc |
| OLD | NEW |