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/prioritized_resource.h" | 5 #include "cc/prioritized_resource.h" |
6 | 6 |
7 #include "cc/platform_color.h" | 7 #include "cc/platform_color.h" |
8 #include "cc/prioritized_resource_manager.h" | 8 #include "cc/prioritized_resource_manager.h" |
9 #include "cc/priority_calculator.h" | 9 #include "cc/priority_calculator.h" |
10 #include "cc/proxy.h" | 10 #include "cc/proxy.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // The component order may be bgra if we uploaded bgra pixels to rgba | 101 // The component order may be bgra if we uploaded bgra pixels to rgba |
102 // texture. Mark contents as swizzled if image component order is | 102 // texture. Mark contents as swizzled if image component order is |
103 // different than texture format. | 103 // different than texture format. |
104 m_contentsSwizzled = !PlatformColor::sameComponentOrder(m_format); | 104 m_contentsSwizzled = !PlatformColor::sameComponentOrder(m_format); |
105 } | 105 } |
106 | 106 |
107 void PrioritizedResource::link(Backing* backing) | 107 void PrioritizedResource::link(Backing* backing) |
108 { | 108 { |
109 DCHECK(backing); | 109 DCHECK(backing); |
110 CHECK(!backing->m_owner); | 110 DCHECK(!backing->m_owner); |
111 CHECK(!m_backing); | 111 DCHECK(!m_backing); |
112 | 112 |
113 m_backing = backing; | 113 m_backing = backing; |
114 m_backing->m_owner = this; | 114 m_backing->m_owner = this; |
115 } | 115 } |
116 | 116 |
117 void PrioritizedResource::unlink() | 117 void PrioritizedResource::unlink() |
118 { | 118 { |
119 DCHECK(m_backing); | 119 DCHECK(m_backing); |
120 CHECK(m_backing->m_owner == this); | 120 DCHECK(m_backing->m_owner == this); |
121 | 121 |
122 m_backing->m_owner = 0; | 122 m_backing->m_owner = 0; |
123 m_backing = 0; | 123 m_backing = 0; |
124 } | 124 } |
125 | 125 |
126 void PrioritizedResource::setToSelfManagedMemoryPlaceholder(size_t bytes) | 126 void PrioritizedResource::setToSelfManagedMemoryPlaceholder(size_t bytes) |
127 { | 127 { |
128 setDimensions(gfx::Size(), GL_RGBA); | 128 setDimensions(gfx::Size(), GL_RGBA); |
129 setIsSelfManaged(true); | 129 setIsSelfManaged(true); |
130 m_bytes = bytes; | 130 m_bytes = bytes; |
131 } | 131 } |
132 | 132 |
133 PrioritizedResource::Backing::Backing(unsigned id, ResourceProvider* resourcePro
vider, gfx::Size size, GLenum format) | 133 PrioritizedResource::Backing::Backing(unsigned id, ResourceProvider* resourcePro
vider, gfx::Size size, GLenum format) |
134 : Resource(id, size, format) | 134 : Resource(id, size, format) |
135 , m_owner(0) | 135 , m_owner(0) |
136 , m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority()) | 136 , m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority()) |
137 , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) | 137 , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) |
138 , m_inDrawingImplTree(false) | 138 , m_inDrawingImplTree(false) |
139 , m_resourceHasBeenDeleted(false) | 139 , m_resourceHasBeenDeleted(false) |
140 , m_inMainThreadEvictedList(false) | |
141 #ifndef NDEBUG | 140 #ifndef NDEBUG |
142 , m_resourceProvider(resourceProvider) | 141 , m_resourceProvider(resourceProvider) |
143 #endif | 142 #endif |
144 { | 143 { |
145 } | 144 } |
146 | 145 |
147 PrioritizedResource::Backing::~Backing() | 146 PrioritizedResource::Backing::~Backing() |
148 { | 147 { |
149 DCHECK(!m_owner); | 148 DCHECK(!m_owner); |
150 DCHECK(m_resourceHasBeenDeleted); | 149 DCHECK(m_resourceHasBeenDeleted); |
151 CHECK(!m_inMainThreadEvictedList); | |
152 } | 150 } |
153 | 151 |
154 void PrioritizedResource::Backing::deleteResource(ResourceProvider* resourceProv
ider) | 152 void PrioritizedResource::Backing::deleteResource(ResourceProvider* resourceProv
ider) |
155 { | 153 { |
156 DCHECK(!proxy() || proxy()->isImplThread()); | 154 DCHECK(!proxy() || proxy()->isImplThread()); |
157 DCHECK(!m_resourceHasBeenDeleted); | 155 DCHECK(!m_resourceHasBeenDeleted); |
158 #ifndef NDEBUG | 156 #ifndef NDEBUG |
159 DCHECK(resourceProvider == m_resourceProvider); | 157 DCHECK(resourceProvider == m_resourceProvider); |
160 #endif | 158 #endif |
161 | 159 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 202 } |
205 | 203 |
206 const Proxy* PrioritizedResource::Backing::proxy() const | 204 const Proxy* PrioritizedResource::Backing::proxy() const |
207 { | 205 { |
208 if (!m_owner || !m_owner->resourceManager()) | 206 if (!m_owner || !m_owner->resourceManager()) |
209 return 0; | 207 return 0; |
210 return m_owner->resourceManager()->proxyForDebug(); | 208 return m_owner->resourceManager()->proxyForDebug(); |
211 } | 209 } |
212 | 210 |
213 } // namespace cc | 211 } // namespace cc |
OLD | NEW |