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 partialTextureUpdatesMax = 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 // Number of pending update intervals to allow. | 30 // Number of blocking update intervals to allow. |
31 static const size_t maxPendingUpdateIntervals = 2; | 31 static const size_t maxBlockingUpdateIntervals = 4; |
32 | 32 |
33 } // anonymous namespace | 33 } // anonymous namespace |
34 | 34 |
35 namespace cc { | 35 namespace cc { |
36 | 36 |
37 size_t CCTextureUpdateController::maxPartialTextureUpdates() | 37 size_t CCTextureUpdateController::maxPartialTextureUpdates() |
38 { | 38 { |
39 return partialTextureUpdatesMax; | 39 return partialTextureUpdatesMax; |
40 } | 40 } |
41 | 41 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 base::TimeDelta CCTextureUpdateController::updateMoreTexturesTime() const | 140 base::TimeDelta CCTextureUpdateController::updateMoreTexturesTime() const |
141 { | 141 { |
142 return base::TimeDelta::FromMilliseconds(textureUpdateTickRate * 1000); | 142 return base::TimeDelta::FromMilliseconds(textureUpdateTickRate * 1000); |
143 } | 143 } |
144 | 144 |
145 size_t CCTextureUpdateController::updateMoreTexturesSize() const | 145 size_t CCTextureUpdateController::updateMoreTexturesSize() const |
146 { | 146 { |
147 return m_textureUpdatesPerTick; | 147 return m_textureUpdatesPerTick; |
148 } | 148 } |
149 | 149 |
150 size_t CCTextureUpdateController::maxPendingUpdates() const | 150 size_t CCTextureUpdateController::maxBlockingUpdates() const |
151 { | 151 { |
152 return updateMoreTexturesSize() * maxPendingUpdateIntervals; | 152 return updateMoreTexturesSize() * maxBlockingUpdateIntervals; |
153 } | 153 } |
154 | 154 |
155 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() | 155 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() |
156 { | 156 { |
157 // Pending uploads will increase when we're too aggressive in our upload | 157 // Blocking uploads will increase when we're too aggressive in our upload |
158 // time estimate. We use a different timeout here to prevent unnecessary | 158 // time estimate. We use a different timeout here to prevent unnecessary |
159 // amounts of idle time when pending uploads have reached the max. | 159 // amounts of idle time when blocking uploads have reached the max. |
160 if (m_uploader->numPendingUploads() >= maxPendingUpdates()) { | 160 if (m_uploader->numBlockingUploads() >= maxBlockingUpdates()) { |
161 m_timer->startOneShot(uploaderBusyTickRate); | 161 m_timer->startOneShot(uploaderBusyTickRate); |
162 return true; | 162 return true; |
163 } | 163 } |
164 | 164 |
165 if (!m_queue->fullUploadSize()) | 165 if (!m_queue->fullUploadSize()) |
166 return false; | 166 return false; |
167 | 167 |
168 bool hasTimeRemaining = m_timeLimit.is_null() || | 168 bool hasTimeRemaining = m_timeLimit.is_null() || |
169 this->now() < m_timeLimit - updateMoreTexturesTime(); | 169 this->now() < m_timeLimit - updateMoreTexturesTime(); |
170 if (hasTimeRemaining) | 170 if (hasTimeRemaining) |
(...skipping 19 matching lines...) Expand all Loading... |
190 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) | 190 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
191 m_resourceProvider->shallowFlushIfSupported(); | 191 m_resourceProvider->shallowFlushIfSupported(); |
192 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo
ad()); | 192 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo
ad()); |
193 uploadCount++; | 193 uploadCount++; |
194 } | 194 } |
195 m_uploader->endUploads(); | 195 m_uploader->endUploads(); |
196 m_resourceProvider->shallowFlushIfSupported(); | 196 m_resourceProvider->shallowFlushIfSupported(); |
197 } | 197 } |
198 | 198 |
199 } | 199 } |
OLD | NEW |