Chromium Code Reviews| 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 gfx::Size size, | 17 gfx::Size size, |
| 18 GLenum format) | 18 GLenum 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) { |
| 28 // manager_ is set in RegisterTexture() so validity can be checked. | 28 // manager_ is set in RegisterTexture() so validity can be checked. |
| 29 DCHECK(format || size.IsEmpty()); | 29 DCHECK(format || size.IsEmpty()); |
| 30 if (format) | 30 if (format) { |
| 31 bytes_ = Resource::MemorySizeBytes(size, format); | 31 // TODO(kaanb): check this codepath |
|
enne (OOO)
2013/09/05 02:01:19
Hopefully this codepath is not hit on Android once
kaanb
2013/09/06 02:05:54
We'll probably disable the glow, however with the
| |
| 32 bytes_ = Resource::MemorySizeBytes(size, format, false); | |
| 33 } | |
| 32 if (manager) | 34 if (manager) |
| 33 manager->RegisterTexture(this); | 35 manager->RegisterTexture(this); |
| 34 } | 36 } |
| 35 | 37 |
| 36 PrioritizedResource::~PrioritizedResource() { | 38 PrioritizedResource::~PrioritizedResource() { |
| 37 if (manager_) | 39 if (manager_) |
| 38 manager_->UnregisterTexture(this); | 40 manager_->UnregisterTexture(this); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void PrioritizedResource::SetTextureManager( | 43 void PrioritizedResource::SetTextureManager( |
| 42 PrioritizedResourceManager* manager) { | 44 PrioritizedResourceManager* manager) { |
| 43 if (manager_ == manager) | 45 if (manager_ == manager) |
| 44 return; | 46 return; |
| 45 if (manager_) | 47 if (manager_) |
| 46 manager_->UnregisterTexture(this); | 48 manager_->UnregisterTexture(this); |
| 47 if (manager) | 49 if (manager) |
| 48 manager->RegisterTexture(this); | 50 manager->RegisterTexture(this); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void PrioritizedResource::SetDimensions(gfx::Size size, GLenum format) { | 53 void PrioritizedResource::SetDimensions(gfx::Size size, GLenum format) { |
| 52 if (format_ != format || size_ != size) { | 54 if (format_ != format || size_ != size) { |
| 53 is_above_priority_cutoff_ = false; | 55 is_above_priority_cutoff_ = false; |
| 54 format_ = format; | 56 format_ = format; |
| 55 size_ = size; | 57 size_ = size; |
| 56 bytes_ = Resource::MemorySizeBytes(size, format); | 58 bytes_ = Resource::MemorySizeBytes(size, format, false); |
| 57 DCHECK(manager_ || !backing_); | 59 DCHECK(manager_ || !backing_); |
| 58 if (manager_) | 60 if (manager_) |
| 59 manager_->ReturnBackingTexture(this); | 61 manager_->ReturnBackingTexture(this); |
| 60 } | 62 } |
| 61 } | 63 } |
| 62 | 64 |
| 63 bool PrioritizedResource::RequestLate() { | 65 bool PrioritizedResource::RequestLate() { |
| 64 if (!manager_) | 66 if (!manager_) |
| 65 return false; | 67 return false; |
| 66 return manager_->RequestLate(this); | 68 return manager_->RequestLate(this); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { | 117 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { |
| 116 SetDimensions(gfx::Size(), GL_RGBA); | 118 SetDimensions(gfx::Size(), GL_RGBA); |
| 117 set_is_self_managed(true); | 119 set_is_self_managed(true); |
| 118 bytes_ = bytes; | 120 bytes_ = bytes; |
| 119 } | 121 } |
| 120 | 122 |
| 121 PrioritizedResource::Backing::Backing(unsigned id, | 123 PrioritizedResource::Backing::Backing(unsigned id, |
| 122 ResourceProvider* resource_provider, | 124 ResourceProvider* resource_provider, |
| 123 gfx::Size size, | 125 gfx::Size size, |
| 124 GLenum format) | 126 GLenum format) |
| 125 : Resource(id, size, format), | 127 : Resource(id, size, format, false), |
| 126 owner_(NULL), | 128 owner_(NULL), |
| 127 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), | 129 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), |
| 128 was_above_priority_cutoff_at_last_priority_update_(false), | 130 was_above_priority_cutoff_at_last_priority_update_(false), |
| 129 in_drawing_impl_tree_(false), | 131 in_drawing_impl_tree_(false), |
| 130 #ifdef NDEBUG | 132 #ifdef NDEBUG |
| 131 resource_has_been_deleted_(false) {} | 133 resource_has_been_deleted_(false) {} |
| 132 #else | 134 #else |
| 133 resource_has_been_deleted_(false), | 135 resource_has_been_deleted_(false), |
| 134 resource_provider_(resource_provider) {} | 136 resource_provider_(resource_provider) {} |
| 135 #endif | 137 #endif |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 manager_->ReturnBackingTexture(this); | 194 manager_->ReturnBackingTexture(this); |
| 193 } | 195 } |
| 194 | 196 |
| 195 const Proxy* PrioritizedResource::Backing::proxy() const { | 197 const Proxy* PrioritizedResource::Backing::proxy() const { |
| 196 if (!owner_ || !owner_->resource_manager()) | 198 if (!owner_ || !owner_->resource_manager()) |
| 197 return NULL; | 199 return NULL; |
| 198 return owner_->resource_manager()->ProxyForDebug(); | 200 return owner_->resource_manager()->ProxyForDebug(); |
| 199 } | 201 } |
| 200 | 202 |
| 201 } // namespace cc | 203 } // namespace cc |
| OLD | NEW |