| 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 #include "cc/throttled_texture_uploader.h" | 6 #include "cc/throttled_texture_uploader.h" |
| 7 | 7 |
| 8 #include "CCPrioritizedTexture.h" | 8 #include "CCPrioritizedTexture.h" |
| 9 #include "CCProxy.h" | 9 #include "CCProxy.h" |
| 10 #include "Extensions3DChromium.h" | 10 #include "Extensions3DChromium.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 { | 129 { |
| 130 for (Deque<OwnPtr<Query> >::iterator it = m_pendingQueries.begin(); | 130 for (Deque<OwnPtr<Query> >::iterator it = m_pendingQueries.begin(); |
| 131 it != m_pendingQueries.end(); ++it) { | 131 it != m_pendingQueries.end(); ++it) { |
| 132 if (it->get()->isNonBlocking()) | 132 if (it->get()->isNonBlocking()) |
| 133 continue; | 133 continue; |
| 134 | 134 |
| 135 m_numBlockingTextureUploads--; | 135 m_numBlockingTextureUploads--; |
| 136 it->get()->markAsNonBlocking(); | 136 it->get()->markAsNonBlocking(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 DCHECK(!m_numBlockingTextureUploads); | 139 ASSERT(!m_numBlockingTextureUploads); |
| 140 } | 140 } |
| 141 | 141 |
| 142 double ThrottledTextureUploader::estimatedTexturesPerSecond() | 142 double ThrottledTextureUploader::estimatedTexturesPerSecond() |
| 143 { | 143 { |
| 144 processQueries(); | 144 processQueries(); |
| 145 | 145 |
| 146 // The history should never be empty because we initialize all elements with
an estimate. | 146 // The history should never be empty because we initialize all elements with
an estimate. |
| 147 DCHECK(m_texturesPerSecondHistory.size() == uploadHistorySize); | 147 ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize); |
| 148 | 148 |
| 149 // Sort the history and use the median as our estimate. | 149 // Sort the history and use the median as our estimate. |
| 150 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), | 150 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), |
| 151 m_texturesPerSecondHistory.end()); | 151 m_texturesPerSecondHistory.end()); |
| 152 std::sort(sortedHistory.begin(), sortedHistory.end()); | 152 std::sort(sortedHistory.begin(), sortedHistory.end()); |
| 153 | 153 |
| 154 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 /
3]; | 154 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 /
3]; |
| 155 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon
dGlobal); | 155 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon
dGlobal); |
| 156 return estimatedTexturesPerSecondGlobal; | 156 return estimatedTexturesPerSecondGlobal; |
| 157 } | 157 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 // TODO(reveman): Move this logic to CCTextureUpdateController after | 193 // TODO(reveman): Move this logic to CCTextureUpdateController after |
| 194 // removing Parameters struct. | 194 // removing Parameters struct. |
| 195 if (upload.picture) { | 195 if (upload.picture) { |
| 196 CCPrioritizedTexture* texture = upload.texture; | 196 CCPrioritizedTexture* texture = upload.texture; |
| 197 IntRect pictureRect = upload.geometry.contentRect; | 197 IntRect pictureRect = upload.geometry.contentRect; |
| 198 IntRect sourceRect = upload.geometry.sourceRect; | 198 IntRect sourceRect = upload.geometry.sourceRect; |
| 199 IntSize destOffset = upload.geometry.destOffset; | 199 IntSize destOffset = upload.geometry.destOffset; |
| 200 | 200 |
| 201 texture->acquireBackingTexture(resourceProvider); | 201 texture->acquireBackingTexture(resourceProvider); |
| 202 DCHECK(texture->haveBackingTexture()); | 202 ASSERT(texture->haveBackingTexture()); |
| 203 | 203 |
| 204 DCHECK(resourceProvider->resourceType(texture->resourceId()) == | 204 ASSERT(resourceProvider->resourceType(texture->resourceId()) == |
| 205 CCResourceProvider::GLTexture); | 205 CCResourceProvider::GLTexture); |
| 206 | 206 |
| 207 WebGraphicsContext3D* paintContext = CCProxy::hasImplThread() ? | 207 WebGraphicsContext3D* paintContext = CCProxy::hasImplThread() ? |
| 208 WebSharedGraphicsContext3D::compositorThreadContext() : | 208 WebSharedGraphicsContext3D::compositorThreadContext() : |
| 209 WebSharedGraphicsContext3D::mainThreadContext(); | 209 WebSharedGraphicsContext3D::mainThreadContext(); |
| 210 GrContext* paintGrContext = CCProxy::hasImplThread() ? | 210 GrContext* paintGrContext = CCProxy::hasImplThread() ? |
| 211 WebSharedGraphicsContext3D::compositorThreadGrContext() : | 211 WebSharedGraphicsContext3D::compositorThreadGrContext() : |
| 212 WebSharedGraphicsContext3D::mainThreadGrContext(); | 212 WebSharedGraphicsContext3D::mainThreadGrContext(); |
| 213 | 213 |
| 214 // Flush the context in which the backing texture is created so that it | 214 // Flush the context in which the backing texture is created so that it |
| 215 // is available in other shared contexts. It is important to do here | 215 // is available in other shared contexts. It is important to do here |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Remove the oldest values from our history and insert the new one | 271 // Remove the oldest values from our history and insert the new one |
| 272 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); | 272 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); |
| 273 m_texturesPerSecondHistory.pop_back(); | 273 m_texturesPerSecondHistory.pop_back(); |
| 274 m_texturesPerSecondHistory.push_front(texturesPerSecond); | 274 m_texturesPerSecondHistory.push_front(texturesPerSecond); |
| 275 | 275 |
| 276 m_availableQueries.append(m_pendingQueries.takeFirst()); | 276 m_availableQueries.append(m_pendingQueries.takeFirst()); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 } | 280 } |
| OLD | NEW |