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 const 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) { |
28 bytes_ = Resource::MemorySizeBytes(size, format); | 28 // We can use UncheckedMemorySizeBytes here, since the size is controlled by |
| 29 // the compositor (used for tiles). |
| 30 bytes_ = Resource::UncheckedMemorySizeBytes(size, format); |
29 if (manager) | 31 if (manager) |
30 manager->RegisterTexture(this); | 32 manager->RegisterTexture(this); |
31 } | 33 } |
32 | 34 |
33 PrioritizedResource::~PrioritizedResource() { | 35 PrioritizedResource::~PrioritizedResource() { |
34 if (manager_) | 36 if (manager_) |
35 manager_->UnregisterTexture(this); | 37 manager_->UnregisterTexture(this); |
36 } | 38 } |
37 | 39 |
38 void PrioritizedResource::SetTextureManager( | 40 void PrioritizedResource::SetTextureManager( |
39 PrioritizedResourceManager* manager) { | 41 PrioritizedResourceManager* manager) { |
40 if (manager_ == manager) | 42 if (manager_ == manager) |
41 return; | 43 return; |
42 if (manager_) | 44 if (manager_) |
43 manager_->UnregisterTexture(this); | 45 manager_->UnregisterTexture(this); |
44 if (manager) | 46 if (manager) |
45 manager->RegisterTexture(this); | 47 manager->RegisterTexture(this); |
46 } | 48 } |
47 | 49 |
48 void PrioritizedResource::SetDimensions(const gfx::Size& size, | 50 void PrioritizedResource::SetDimensions(const gfx::Size& size, |
49 ResourceFormat format) { | 51 ResourceFormat format) { |
50 if (format_ != format || size_ != size) { | 52 if (format_ != format || size_ != size) { |
51 is_above_priority_cutoff_ = false; | 53 is_above_priority_cutoff_ = false; |
52 format_ = format; | 54 format_ = format; |
53 size_ = size; | 55 size_ = size; |
54 bytes_ = Resource::MemorySizeBytes(size, format); | 56 // We can use UncheckedMemorySizeBytes here, since the size is controlled by |
| 57 // the compositor (used for tiles). |
| 58 bytes_ = Resource::UncheckedMemorySizeBytes(size, format); |
55 DCHECK(manager_ || !backing_); | 59 DCHECK(manager_ || !backing_); |
56 if (manager_) | 60 if (manager_) |
57 manager_->ReturnBackingTexture(this); | 61 manager_->ReturnBackingTexture(this); |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 bool PrioritizedResource::RequestLate() { | 65 bool PrioritizedResource::RequestLate() { |
62 if (!manager_) | 66 if (!manager_) |
63 return false; | 67 return false; |
64 return manager_->RequestLate(this); | 68 return manager_->RequestLate(this); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 manager_->ReturnBackingTexture(this); | 198 manager_->ReturnBackingTexture(this); |
195 } | 199 } |
196 | 200 |
197 const Proxy* PrioritizedResource::Backing::proxy() const { | 201 const Proxy* PrioritizedResource::Backing::proxy() const { |
198 if (!owner_ || !owner_->resource_manager()) | 202 if (!owner_ || !owner_->resource_manager()) |
199 return NULL; | 203 return NULL; |
200 return owner_->resource_manager()->ProxyForDebug(); | 204 return owner_->resource_manager()->ProxyForDebug(); |
201 } | 205 } |
202 | 206 |
203 } // namespace cc | 207 } // namespace cc |
OLD | NEW |