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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCPrioritizedTexture.h" | 7 #include "CCPrioritizedTexture.h" |
8 | 8 |
9 #include "CCPrioritizedTextureManager.h" | 9 #include "CCPrioritizedTextureManager.h" |
10 #include "CCPriorityCalculator.h" | 10 #include "CCPriorityCalculator.h" |
11 #include "CCProxy.h" | 11 #include "CCProxy.h" |
12 #include <algorithm> | 12 #include <algorithm> |
13 | 13 |
14 using namespace std; | 14 using namespace std; |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 CCPrioritizedTexture::CCPrioritizedTexture(CCPrioritizedTextureManager* manager,
IntSize size, GC3Denum format) | 18 CCPrioritizedTexture::CCPrioritizedTexture(CCPrioritizedTextureManager* manager,
IntSize size, GLenum format) |
19 : m_size(size) | 19 : m_size(size) |
20 , m_format(format) | 20 , m_format(format) |
21 , m_bytes(0) | 21 , m_bytes(0) |
22 , m_priority(CCPriorityCalculator::lowestPriority()) | 22 , m_priority(CCPriorityCalculator::lowestPriority()) |
23 , m_isAbovePriorityCutoff(false) | 23 , m_isAbovePriorityCutoff(false) |
24 , m_isSelfManaged(false) | 24 , m_isSelfManaged(false) |
25 , m_backing(0) | 25 , m_backing(0) |
26 , m_manager(0) | 26 , m_manager(0) |
27 { | 27 { |
28 // m_manager is set in registerTexture() so validity can be checked. | 28 // m_manager is set in registerTexture() so validity can be checked. |
(...skipping 13 matching lines...) Expand all Loading... |
42 void CCPrioritizedTexture::setTextureManager(CCPrioritizedTextureManager* manage
r) | 42 void CCPrioritizedTexture::setTextureManager(CCPrioritizedTextureManager* manage
r) |
43 { | 43 { |
44 if (m_manager == manager) | 44 if (m_manager == manager) |
45 return; | 45 return; |
46 if (m_manager) | 46 if (m_manager) |
47 m_manager->unregisterTexture(this); | 47 m_manager->unregisterTexture(this); |
48 if (manager) | 48 if (manager) |
49 manager->registerTexture(this); | 49 manager->registerTexture(this); |
50 } | 50 } |
51 | 51 |
52 void CCPrioritizedTexture::setDimensions(IntSize size, GC3Denum format) | 52 void CCPrioritizedTexture::setDimensions(IntSize size, GLenum format) |
53 { | 53 { |
54 if (m_format != format || m_size != size) { | 54 if (m_format != format || m_size != size) { |
55 m_isAbovePriorityCutoff = false; | 55 m_isAbovePriorityCutoff = false; |
56 m_format = format; | 56 m_format = format; |
57 m_size = size; | 57 m_size = size; |
58 m_bytes = CCTexture::memorySizeBytes(size, format); | 58 m_bytes = CCTexture::memorySizeBytes(size, format); |
59 ASSERT(m_manager || !m_backing); | 59 ASSERT(m_manager || !m_backing); |
60 if (m_manager) | 60 if (m_manager) |
61 m_manager->returnBackingTexture(this); | 61 m_manager->returnBackingTexture(this); |
62 } | 62 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 { | 113 { |
114 ASSERT(m_backing); | 114 ASSERT(m_backing); |
115 ASSERT(m_backing->m_owner == this); | 115 ASSERT(m_backing->m_owner == this); |
116 | 116 |
117 m_backing->m_owner = 0; | 117 m_backing->m_owner = 0; |
118 m_backing = 0; | 118 m_backing = 0; |
119 } | 119 } |
120 | 120 |
121 void CCPrioritizedTexture::setToSelfManagedMemoryPlaceholder(size_t bytes) | 121 void CCPrioritizedTexture::setToSelfManagedMemoryPlaceholder(size_t bytes) |
122 { | 122 { |
123 setDimensions(IntSize(), GraphicsContext3D::RGBA); | 123 setDimensions(IntSize(), GL_RGBA); |
124 setIsSelfManaged(true); | 124 setIsSelfManaged(true); |
125 m_bytes = bytes; | 125 m_bytes = bytes; |
126 } | 126 } |
127 | 127 |
128 CCPrioritizedTexture::Backing::Backing(unsigned id, CCResourceProvider* resource
Provider, IntSize size, GC3Denum format) | 128 CCPrioritizedTexture::Backing::Backing(unsigned id, CCResourceProvider* resource
Provider, IntSize size, GLenum format) |
129 : CCTexture(id, size, format) | 129 : CCTexture(id, size, format) |
130 , m_owner(0) | 130 , m_owner(0) |
131 , m_priorityAtLastPriorityUpdate(CCPriorityCalculator::lowestPriority()) | 131 , m_priorityAtLastPriorityUpdate(CCPriorityCalculator::lowestPriority()) |
132 , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) | 132 , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) |
133 , m_inDrawingImplTree(false) | 133 , m_inDrawingImplTree(false) |
134 , m_resourceHasBeenDeleted(false) | 134 , m_resourceHasBeenDeleted(false) |
135 #ifndef NDEBUG | 135 #ifndef NDEBUG |
136 , m_resourceProvider(resourceProvider) | 136 , m_resourceProvider(resourceProvider) |
137 #endif | 137 #endif |
138 { | 138 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 void CCPrioritizedTexture::Backing::updateInDrawingImplTree() | 184 void CCPrioritizedTexture::Backing::updateInDrawingImplTree() |
185 { | 185 { |
186 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); | 186 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); |
187 m_inDrawingImplTree = !!owner(); | 187 m_inDrawingImplTree = !!owner(); |
188 if (!m_inDrawingImplTree) | 188 if (!m_inDrawingImplTree) |
189 ASSERT(m_priorityAtLastPriorityUpdate == CCPriorityCalculator::lowestPri
ority()); | 189 ASSERT(m_priorityAtLastPriorityUpdate == CCPriorityCalculator::lowestPri
ority()); |
190 } | 190 } |
191 | 191 |
192 } // namespace cc | 192 } // namespace cc |
OLD | NEW |