| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 m_availableQueries.first()->begin(); | 164 m_availableQueries.first()->begin(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ThrottledTextureUploader::endQuery() | 167 void ThrottledTextureUploader::endQuery() |
| 168 { | 168 { |
| 169 m_availableQueries.first()->end(); | 169 m_availableQueries.first()->end(); |
| 170 m_pendingQueries.append(m_availableQueries.takeFirst()); | 170 m_pendingQueries.append(m_availableQueries.takeFirst()); |
| 171 m_numBlockingTextureUploads++; | 171 m_numBlockingTextureUploads++; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvide
r, Parameters upload) | 174 void ThrottledTextureUploader::uploadTexture(ResourceProvider* resourceProvider,
Parameters upload) |
| 175 { | 175 { |
| 176 bool isFullUpload = upload.geometry.destOffset.isZero() && | 176 bool isFullUpload = upload.geometry.destOffset.isZero() && |
| 177 upload.geometry.sourceRect.size() == upload.texture->siz
e(); | 177 upload.geometry.sourceRect.size() == upload.texture->siz
e(); |
| 178 | 178 |
| 179 if (isFullUpload) | 179 if (isFullUpload) |
| 180 beginQuery(); | 180 beginQuery(); |
| 181 | 181 |
| 182 if (upload.bitmap) { | 182 if (upload.bitmap) { |
| 183 upload.bitmap->lockPixels(); | 183 upload.bitmap->lockPixels(); |
| 184 upload.texture->upload( | 184 upload.texture->upload( |
| 185 resourceProvider, | 185 resourceProvider, |
| 186 static_cast<const uint8_t*>(upload.bitmap->getPixels()), | 186 static_cast<const uint8_t*>(upload.bitmap->getPixels()), |
| 187 upload.geometry.contentRect, | 187 upload.geometry.contentRect, |
| 188 upload.geometry.sourceRect, | 188 upload.geometry.sourceRect, |
| 189 upload.geometry.destOffset); | 189 upload.geometry.destOffset); |
| 190 upload.bitmap->unlockPixels(); | 190 upload.bitmap->unlockPixels(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // TODO(reveman): Move this logic to CCTextureUpdateController after | 193 // TODO(reveman): Move this logic to TextureUpdateController after |
| 194 // removing Parameters struct. | 194 // removing Parameters struct. |
| 195 if (upload.picture) { | 195 if (upload.picture) { |
| 196 CCPrioritizedTexture* texture = upload.texture; | 196 PrioritizedTexture* 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 ASSERT(texture->haveBackingTexture()); | 202 ASSERT(texture->haveBackingTexture()); |
| 203 | 203 |
| 204 ASSERT(resourceProvider->resourceType(texture->resourceId()) == | 204 ASSERT(resourceProvider->resourceType(texture->resourceId()) == |
| 205 CCResourceProvider::GLTexture); | 205 ResourceProvider::GLTexture); |
| 206 | 206 |
| 207 WebGraphicsContext3D* paintContext = CCProxy::hasImplThread() ? | 207 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? |
| 208 WebSharedGraphicsContext3D::compositorThreadContext() : | 208 WebSharedGraphicsContext3D::compositorThreadContext() : |
| 209 WebSharedGraphicsContext3D::mainThreadContext(); | 209 WebSharedGraphicsContext3D::mainThreadContext(); |
| 210 GrContext* paintGrContext = CCProxy::hasImplThread() ? | 210 GrContext* paintGrContext = Proxy::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 |
| 216 // because the backing texture is created in one context while it is | 216 // because the backing texture is created in one context while it is |
| 217 // being written to in another. | 217 // being written to in another. |
| 218 resourceProvider->flush(); | 218 resourceProvider->flush(); |
| 219 CCResourceProvider::ScopedWriteLockGL lock( | 219 ResourceProvider::ScopedWriteLockGL lock( |
| 220 resourceProvider, texture->resourceId()); | 220 resourceProvider, texture->resourceId()); |
| 221 | 221 |
| 222 // Make sure ganesh uses the correct GL context. | 222 // Make sure ganesh uses the correct GL context. |
| 223 paintContext->makeContextCurrent(); | 223 paintContext->makeContextCurrent(); |
| 224 | 224 |
| 225 // Create an accelerated canvas to draw on. | 225 // Create an accelerated canvas to draw on. |
| 226 scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( | 226 scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( |
| 227 paintGrContext, texture->size(), lock.textureId()); | 227 paintGrContext, texture->size(), lock.textureId()); |
| 228 | 228 |
| 229 // The compositor expects the textures to be upside-down so it can flip | 229 // The compositor expects the textures to be upside-down so it can flip |
| (...skipping 41 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 |