[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "config.h" |
| 6 | |
[email protected] | 4456eee2 | 2012-10-19 18:16:38 | [diff] [blame] | 7 | #include "cc/texture_update_controller.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 8 | |
[email protected] | 6331a117 | 2012-10-18 11:35:13 | [diff] [blame] | 9 | #include "base/debug/trace_event.h" |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 10 | #include "cc/prioritized_texture.h" |
| 11 | #include "cc/proxy.h" |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 12 | #include "cc/resource_provider.h" |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 13 | #include "cc/texture_copier.h" |
[email protected] | 4456eee2 | 2012-10-19 18:16:38 | [diff] [blame] | 14 | #include "third_party/khronos/GLES2/gl2.h" |
| 15 | #include "third_party/skia/include/gpu/SkGpuDevice.h" |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 16 | #include <limits> |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 17 | #include <public/WebGraphicsContext3D.h> |
| 18 | #include <public/WebSharedGraphicsContext3D.h> |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 19 | #include <wtf/CurrentTime.h> |
| 20 | |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 21 | using WebKit::WebGraphicsContext3D; |
| 22 | using WebKit::WebSharedGraphicsContext3D; |
| 23 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 24 | namespace { |
| 25 | |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 26 | // Number of partial updates we allow. |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 27 | const size_t partialTextureUpdatesMax = 12; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 28 | |
| 29 | // Measured in seconds. |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 30 | const double textureUpdateTickRate = 0.004; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 31 | |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 32 | // Measured in seconds. |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 33 | const double uploaderBusyTickRate = 0.001; |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 34 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 35 | // Flush interval when performing texture uploads. |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 36 | const int textureUploadFlushPeriod = 4; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 37 | |
[email protected] | b914e10 | 2012-10-02 08:11:52 | [diff] [blame] | 38 | // Number of blocking update intervals to allow. |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 39 | const size_t maxBlockingUpdateIntervals = 4; |
[email protected] | 549526e9 | 2012-09-29 15:43:08 | [diff] [blame] | 40 | |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 41 | scoped_ptr<SkCanvas> createAcceleratedCanvas( |
| 42 | GrContext* grContext, cc::IntSize canvasSize, unsigned textureId) |
| 43 | { |
| 44 | GrPlatformTextureDesc textureDesc; |
| 45 | textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; |
| 46 | textureDesc.fWidth = canvasSize.width(); |
| 47 | textureDesc.fHeight = canvasSize.height(); |
| 48 | textureDesc.fConfig = kSkia8888_GrPixelConfig; |
| 49 | textureDesc.fTextureHandle = textureId; |
| 50 | SkAutoTUnref<GrTexture> target( |
| 51 | grContext->createPlatformTexture(textureDesc)); |
| 52 | SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); |
| 53 | return make_scoped_ptr(new SkCanvas(device.get())); |
| 54 | } |
| 55 | |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 56 | } // namespace |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 57 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 58 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 59 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 60 | size_t TextureUpdateController::maxPartialTextureUpdates() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 61 | { |
[email protected] | a7c078b | 2012-09-20 17:52:12 | [diff] [blame] | 62 | return partialTextureUpdatesMax; |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 63 | } |
| 64 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 65 | size_t TextureUpdateController::maxFullUpdatesPerTick( |
| 66 | ResourceProvider* resourceProvider) |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 67 | { |
[email protected] | e224959 | 2012-10-19 06:59:09 | [diff] [blame] | 68 | double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond(); |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 69 | size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); |
| 70 | return texturesPerTick ? texturesPerTick : 1; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 71 | } |
| 72 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 73 | TextureUpdateController::TextureUpdateController(TextureUpdateControllerClient* client, Thread* thread, scoped_ptr<TextureUpdateQueue> queue, ResourceProvider* resourceProvider) |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 74 | : m_client(client) |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 75 | , m_timer(new Timer(thread, this)) |
[email protected] | b1b800c | 2012-10-16 05:03:59 | [diff] [blame] | 76 | , m_queue(queue.Pass()) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 77 | , m_resourceProvider(resourceProvider) |
[email protected] | e224959 | 2012-10-19 06:59:09 | [diff] [blame] | 78 | , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider)) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 79 | , m_firstUpdateAttempt(true) |
| 80 | { |
| 81 | } |
| 82 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 83 | TextureUpdateController::~TextureUpdateController() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 84 | { |
| 85 | } |
| 86 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 87 | void TextureUpdateController::performMoreUpdates( |
[email protected] | d918afe | 2012-09-27 19:27:21 | [diff] [blame] | 88 | base::TimeTicks timeLimit) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 89 | { |
[email protected] | d918afe | 2012-09-27 19:27:21 | [diff] [blame] | 90 | m_timeLimit = timeLimit; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 91 | |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 92 | // Update already in progress. |
| 93 | if (m_timer->isActive()) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 94 | return; |
| 95 | |
| 96 | // Call updateMoreTexturesNow() directly unless it's the first update |
| 97 | // attempt. This ensures that we empty the update queue in a finite |
| 98 | // amount of time. |
| 99 | if (m_firstUpdateAttempt) { |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 100 | // Post a 0-delay task when no updates were left. When it runs, |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 101 | // readyToFinalizeTextureUpdates() will be called. |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 102 | if (!updateMoreTexturesIfEnoughTimeRemaining()) |
| 103 | m_timer->startOneShot(0); |
| 104 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 105 | m_firstUpdateAttempt = false; |
| 106 | } else |
| 107 | updateMoreTexturesNow(); |
| 108 | } |
| 109 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 110 | void TextureUpdateController::discardUploadsToEvictedResources() |
[email protected] | 77a60b9b | 2012-09-19 23:59:01 | [diff] [blame] | 111 | { |
| 112 | m_queue->clearUploadsToEvictedResources(); |
| 113 | } |
| 114 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 115 | void TextureUpdateController::updateTexture(ResourceUpdate update) |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 116 | { |
| 117 | if (update.picture) { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 118 | PrioritizedTexture* texture = update.texture; |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 119 | IntRect pictureRect = update.content_rect; |
| 120 | IntRect sourceRect = update.source_rect; |
| 121 | IntSize destOffset = update.dest_offset; |
| 122 | |
| 123 | texture->acquireBackingTexture(m_resourceProvider); |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 124 | DCHECK(texture->haveBackingTexture()); |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 125 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 126 | DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 127 | ResourceProvider::GLTexture); |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 128 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 129 | WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 130 | WebSharedGraphicsContext3D::compositorThreadContext() : |
| 131 | WebSharedGraphicsContext3D::mainThreadContext(); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 132 | GrContext* paintGrContext = Proxy::hasImplThread() ? |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 133 | WebSharedGraphicsContext3D::compositorThreadGrContext() : |
| 134 | WebSharedGraphicsContext3D::mainThreadGrContext(); |
| 135 | |
| 136 | // Flush the context in which the backing texture is created so that it |
| 137 | // is available in other shared contexts. It is important to do here |
| 138 | // because the backing texture is created in one context while it is |
| 139 | // being written to in another. |
| 140 | m_resourceProvider->flush(); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 141 | ResourceProvider::ScopedWriteLockGL lock( |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 142 | m_resourceProvider, texture->resourceId()); |
| 143 | |
| 144 | // Make sure ganesh uses the correct GL context. |
| 145 | paintContext->makeContextCurrent(); |
| 146 | |
| 147 | // Create an accelerated canvas to draw on. |
| 148 | scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( |
| 149 | paintGrContext, texture->size(), lock.textureId()); |
| 150 | |
| 151 | // The compositor expects the textures to be upside-down so it can flip |
| 152 | // the final composited image. Ganesh renders the image upright so we |
| 153 | // need to do a y-flip. |
| 154 | canvas->translate(0.0, texture->size().height()); |
| 155 | canvas->scale(1.0, -1.0); |
| 156 | // Clip to the destination on the texture that must be updated. |
| 157 | canvas->clipRect(SkRect::MakeXYWH(destOffset.width(), |
| 158 | destOffset.height(), |
| 159 | sourceRect.width(), |
| 160 | sourceRect.height())); |
| 161 | // Translate the origin of pictureRect to destOffset. |
| 162 | // Note that destOffset is defined relative to sourceRect. |
| 163 | canvas->translate( |
| 164 | pictureRect.x() - sourceRect.x() + destOffset.width(), |
| 165 | pictureRect.y() - sourceRect.y() + destOffset.height()); |
| 166 | canvas->drawPicture(*update.picture); |
| 167 | |
| 168 | // Flush ganesh context so that all the rendered stuff appears on the |
| 169 | // texture. |
| 170 | paintGrContext->flush(); |
| 171 | |
| 172 | // Flush the GL context so rendering results from this context are |
| 173 | // visible in the compositor's context. |
| 174 | paintContext->flush(); |
| 175 | } |
| 176 | |
| 177 | if (update.bitmap) { |
[email protected] | e224959 | 2012-10-19 06:59:09 | [diff] [blame] | 178 | update.bitmap->lockPixels(); |
| 179 | update.texture->upload( |
| 180 | m_resourceProvider, |
| 181 | static_cast<const uint8_t*>(update.bitmap->getPixels()), |
| 182 | update.content_rect, |
| 183 | update.source_rect, |
| 184 | update.dest_offset); |
| 185 | update.bitmap->unlockPixels(); |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 189 | void TextureUpdateController::finalize() |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 190 | { |
[email protected] | f961b79 | 2012-09-20 07:27:33 | [diff] [blame] | 191 | size_t uploadCount = 0; |
| 192 | while (m_queue->fullUploadSize()) { |
| 193 | if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
| 194 | m_resourceProvider->shallowFlushIfSupported(); |
| 195 | |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 196 | updateTexture(m_queue->takeFirstFullUpload()); |
[email protected] | f961b79 | 2012-09-20 07:27:33 | [diff] [blame] | 197 | uploadCount++; |
| 198 | } |
| 199 | |
| 200 | while (m_queue->partialUploadSize()) { |
| 201 | if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
| 202 | m_resourceProvider->shallowFlushIfSupported(); |
| 203 | |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 204 | updateTexture(m_queue->takeFirstPartialUpload()); |
[email protected] | f961b79 | 2012-09-20 07:27:33 | [diff] [blame] | 205 | uploadCount++; |
| 206 | } |
| 207 | |
| 208 | if (uploadCount) |
| 209 | m_resourceProvider->shallowFlushIfSupported(); |
| 210 | |
| 211 | if (m_queue->copySize()) { |
| 212 | TextureCopier* copier = m_resourceProvider->textureCopier(); |
| 213 | while (m_queue->copySize()) |
| 214 | copier->copyTexture(m_queue->takeFirstCopy()); |
| 215 | |
| 216 | // If we've performed any texture copies, we need to insert a flush |
| 217 | // here into the compositor context before letting the main thread |
| 218 | // proceed as it may make draw calls to the source texture of one of |
| 219 | // our copy operations. |
| 220 | copier->flush(); |
| 221 | } |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 222 | } |
| 223 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 224 | void TextureUpdateController::onTimerFired() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 225 | { |
[email protected] | 1795308 | 2012-10-24 20:13:32 | [diff] [blame^] | 226 | ResourceProvider::debugNotifyEnterZone(0xB000000); |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 227 | if (!updateMoreTexturesIfEnoughTimeRemaining()) |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 228 | m_client->readyToFinalizeTextureUpdates(); |
[email protected] | 1795308 | 2012-10-24 20:13:32 | [diff] [blame^] | 229 | ResourceProvider::debugNotifyLeaveZone(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 230 | } |
| 231 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 232 | base::TimeTicks TextureUpdateController::now() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 233 | { |
[email protected] | d918afe | 2012-09-27 19:27:21 | [diff] [blame] | 234 | return base::TimeTicks::Now(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 235 | } |
| 236 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 237 | base::TimeDelta TextureUpdateController::updateMoreTexturesTime() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 238 | { |
[email protected] | d918afe | 2012-09-27 19:27:21 | [diff] [blame] | 239 | return base::TimeDelta::FromMilliseconds(textureUpdateTickRate * 1000); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 240 | } |
| 241 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 242 | size_t TextureUpdateController::updateMoreTexturesSize() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 243 | { |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 244 | return m_textureUpdatesPerTick; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 245 | } |
| 246 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 247 | size_t TextureUpdateController::maxBlockingUpdates() const |
[email protected] | 549526e9 | 2012-09-29 15:43:08 | [diff] [blame] | 248 | { |
[email protected] | b914e10 | 2012-10-02 08:11:52 | [diff] [blame] | 249 | return updateMoreTexturesSize() * maxBlockingUpdateIntervals; |
[email protected] | 549526e9 | 2012-09-29 15:43:08 | [diff] [blame] | 250 | } |
| 251 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 252 | bool TextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 253 | { |
[email protected] | b914e10 | 2012-10-02 08:11:52 | [diff] [blame] | 254 | // Blocking uploads will increase when we're too aggressive in our upload |
[email protected] | 549526e9 | 2012-09-29 15:43:08 | [diff] [blame] | 255 | // time estimate. We use a different timeout here to prevent unnecessary |
[email protected] | b914e10 | 2012-10-02 08:11:52 | [diff] [blame] | 256 | // amounts of idle time when blocking uploads have reached the max. |
[email protected] | e224959 | 2012-10-19 06:59:09 | [diff] [blame] | 257 | if (m_resourceProvider->numBlockingUploads() >= maxBlockingUpdates()) { |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 258 | m_timer->startOneShot(uploaderBusyTickRate); |
| 259 | return true; |
| 260 | } |
| 261 | |
| 262 | if (!m_queue->fullUploadSize()) |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 263 | return false; |
| 264 | |
[email protected] | e8e410d | 2012-09-28 01:47:01 | [diff] [blame] | 265 | bool hasTimeRemaining = m_timeLimit.is_null() || |
| 266 | this->now() < m_timeLimit - updateMoreTexturesTime(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 267 | if (hasTimeRemaining) |
| 268 | updateMoreTexturesNow(); |
[email protected] | 3c496dc | 2012-09-13 23:14:20 | [diff] [blame] | 269 | |
| 270 | return true; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 271 | } |
| 272 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 273 | void TextureUpdateController::updateMoreTexturesNow() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 274 | { |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 275 | size_t uploads = std::min( |
| 276 | m_queue->fullUploadSize(), updateMoreTexturesSize()); |
| 277 | m_timer->startOneShot( |
[email protected] | d918afe | 2012-09-27 19:27:21 | [diff] [blame] | 278 | updateMoreTexturesTime().InSecondsF() / updateMoreTexturesSize() * |
| 279 | uploads); |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 280 | |
| 281 | if (!uploads) |
| 282 | return; |
| 283 | |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 284 | size_t uploadCount = 0; |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 285 | while (m_queue->fullUploadSize() && uploadCount < uploads) { |
| 286 | if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 287 | m_resourceProvider->shallowFlushIfSupported(); |
[email protected] | 1e5b6bf5 | 2012-10-18 01:44:52 | [diff] [blame] | 288 | updateTexture(m_queue->takeFirstFullUpload()); |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 289 | uploadCount++; |
[email protected] | 1269515 | 2012-09-17 22:28:14 | [diff] [blame] | 290 | } |
[email protected] | 41b8f68 | 2012-09-19 01:51:17 | [diff] [blame] | 291 | m_resourceProvider->shallowFlushIfSupported(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 292 | } |
| 293 | |
[email protected] | 2d86b92 | 2012-10-13 16:57:47 | [diff] [blame] | 294 | } // namespace cc |