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" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 { | 145 { |
146 return m_textureUpdatesPerTick; | 146 return m_textureUpdatesPerTick; |
147 } | 147 } |
148 | 148 |
149 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() | 149 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() |
150 { | 150 { |
151 // Uploader might be busy when we're too aggressive in our upload time | 151 // Uploader might be busy when we're too aggressive in our upload time |
152 // estimate. We use a different timeout here to prevent unnecessary | 152 // estimate. We use a different timeout here to prevent unnecessary |
153 // amounts of idle time. | 153 // amounts of idle time. |
154 if (m_uploader->isBusy()) { | 154 if (m_uploader->isBusy()) { |
155 m_timer->startOneShot(uploaderBusyTickRate); | 155 m_timer->startOneShot(uploaderBusyTickRate); |
reveman
2012/09/22 00:50:26
I think you have to include this logic in the loop
| |
156 return true; | 156 return true; |
157 } | 157 } |
158 | 158 |
159 if (!m_queue->fullUploadSize()) | 159 if (!m_queue->fullUploadSize()) |
160 return false; | 160 return false; |
reveman
2012/09/22 00:50:26
And I think you need to include this in the loop b
| |
161 | 161 |
162 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime(); | 162 double timeRemaining = m_monotonicTimeLimit - monotonicTimeNow(); |
163 if (hasTimeRemaining) | 163 while (timeRemaining > updateMoreTexturesTime() && m_queue->fullUploadSize() && !m_uploader->isBusy()) { |
164 updateMoreTexturesNow(); | 164 updateMoreTexturesNow(); |
165 timeRemaining -= updateMoreTexturesTime(); | |
166 } | |
165 | 167 |
166 return true; | 168 return true; |
167 } | 169 } |
168 | 170 |
169 void CCTextureUpdateController::updateMoreTexturesNow() | 171 void CCTextureUpdateController::updateMoreTexturesNow() |
170 { | 172 { |
171 size_t uploads = std::min( | 173 size_t uploads = std::min( |
172 m_queue->fullUploadSize(), updateMoreTexturesSize()); | 174 m_queue->fullUploadSize(), updateMoreTexturesSize()); |
173 m_timer->startOneShot( | 175 m_timer->startOneShot( |
reveman
2012/09/22 00:50:26
Awkward to call startOneShot() here now that this
| |
174 updateMoreTexturesTime() / updateMoreTexturesSize() * uploads); | 176 updateMoreTexturesTime() / updateMoreTexturesSize() * uploads); |
175 | 177 |
176 if (!uploads) | 178 if (!uploads) |
177 return; | 179 return; |
178 | 180 |
179 size_t uploadCount = 0; | 181 size_t uploadCount = 0; |
180 m_uploader->beginUploads(); | 182 m_uploader->beginUploads(); |
181 while (m_queue->fullUploadSize() && uploadCount < uploads) { | 183 while (m_queue->fullUploadSize() && uploadCount < uploads) { |
182 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) | 184 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
183 m_resourceProvider->shallowFlushIfSupported(); | 185 m_resourceProvider->shallowFlushIfSupported(); |
184 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo ad()); | 186 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo ad()); |
185 uploadCount++; | 187 uploadCount++; |
186 } | 188 } |
187 m_uploader->endUploads(); | 189 m_uploader->endUploads(); |
188 m_resourceProvider->shallowFlushIfSupported(); | 190 m_resourceProvider->shallowFlushIfSupported(); |
189 } | 191 } |
190 | 192 |
191 } | 193 } |
OLD | NEW |