| 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 "CCTextureUpdateController.h" | 7 #include "CCTextureUpdateController.h" |
| 8 | 8 |
| 9 #include "GraphicsContext3D.h" | 9 #include "GraphicsContext3D.h" |
| 10 #include "TextureCopier.h" | 10 #include "TextureCopier.h" |
| 11 #include "TextureUploader.h" | 11 #include "TextureUploader.h" |
| 12 #include "TraceEvent.h" | 12 #include "TraceEvent.h" |
| 13 #include <limits> | 13 #include <limits> |
| 14 #include <wtf/CurrentTime.h> | 14 #include <wtf/CurrentTime.h> |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Number of partial updates we allow. | 18 // Number of partial updates we allow. |
| 19 static const size_t maxPartialTextureUpdatesMax = 12; | 19 static const size_t partialTextureUpdatesMax = 12; |
| 20 | 20 |
| 21 // Measured in seconds. | 21 // Measured in seconds. |
| 22 static const double textureUpdateTickRate = 0.004; | 22 static const double textureUpdateTickRate = 0.004; |
| 23 | 23 |
| 24 // Measured in seconds. | 24 // Measured in seconds. |
| 25 static const double uploaderBusyTickRate = 0.001; | 25 static const double uploaderBusyTickRate = 0.001; |
| 26 | 26 |
| 27 // Flush interval when performing texture uploads. | 27 // Flush interval when performing texture uploads. |
| 28 static const int textureUploadFlushPeriod = 4; | 28 static const int textureUploadFlushPeriod = 4; |
| 29 | 29 |
| 30 } // anonymous namespace | 30 } // anonymous namespace |
| 31 | 31 |
| 32 namespace cc { | 32 namespace cc { |
| 33 | 33 |
| 34 size_t CCTextureUpdateController::maxPartialTextureUpdates() | 34 size_t CCTextureUpdateController::maxPartialTextureUpdates() |
| 35 { | 35 { |
| 36 return maxPartialTextureUpdatesMax; | 36 return partialTextureUpdatesMax; |
| 37 } | 37 } |
| 38 | 38 |
| 39 size_t CCTextureUpdateController::maxFullUpdatesPerTick(TextureUploader* uploade
r) | 39 size_t CCTextureUpdateController::maxFullUpdatesPerTick(TextureUploader* uploade
r) |
| 40 { | 40 { |
| 41 double texturesPerSecond = uploader->estimatedTexturesPerSecond(); | 41 double texturesPerSecond = uploader->estimatedTexturesPerSecond(); |
| 42 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); | 42 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); |
| 43 return texturesPerTick ? texturesPerTick : 1; | 43 return texturesPerTick ? texturesPerTick : 1; |
| 44 } | 44 } |
| 45 | 45 |
| 46 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl
ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour
ceProvider* resourceProvider, TextureUploader* uploader) | 46 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl
ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour
ceProvider* resourceProvider, TextureUploader* uploader) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) | 182 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
| 183 m_resourceProvider->shallowFlushIfSupported(); | 183 m_resourceProvider->shallowFlushIfSupported(); |
| 184 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo
ad()); | 184 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo
ad()); |
| 185 uploadCount++; | 185 uploadCount++; |
| 186 } | 186 } |
| 187 m_uploader->endUploads(); | 187 m_uploader->endUploads(); |
| 188 m_resourceProvider->shallowFlushIfSupported(); | 188 m_resourceProvider->shallowFlushIfSupported(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } | 191 } |
| OLD | NEW |