| 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 "ThrottledTextureUploader.h" | 6 #include "ThrottledTextureUploader.h" |
| 7 | 7 |
| 8 #include "CCPrioritizedTexture.h" |
| 8 #include "Extensions3DChromium.h" | 9 #include "Extensions3DChromium.h" |
| 9 #include "TraceEvent.h" | 10 #include "TraceEvent.h" |
| 10 #include <algorithm> | 11 #include <algorithm> |
| 11 #include <public/Platform.h> | 12 #include <public/Platform.h> |
| 12 #include <public/WebGraphicsContext3D.h> | 13 #include <public/WebGraphicsContext3D.h> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // How many previous uploads to use when predicting future throughput. | 18 // How many previous uploads to use when predicting future throughput. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 146 |
| 146 void ThrottledTextureUploader::endQuery() | 147 void ThrottledTextureUploader::endQuery() |
| 147 { | 148 { |
| 148 m_availableQueries.first()->end(); | 149 m_availableQueries.first()->end(); |
| 149 m_pendingQueries.append(m_availableQueries.takeFirst()); | 150 m_pendingQueries.append(m_availableQueries.takeFirst()); |
| 150 m_numBlockingTextureUploads++; | 151 m_numBlockingTextureUploads++; |
| 151 } | 152 } |
| 152 | 153 |
| 153 void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvide
r, Parameters upload) | 154 void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvide
r, Parameters upload) |
| 154 { | 155 { |
| 155 bool isFullUpload = upload.destOffset.isZero() && | 156 bool isFullUpload = upload.geometry.destOffset.isZero() && |
| 156 upload.sourceRect.size() == upload.texture->texture()->s
ize(); | 157 upload.geometry.sourceRect.size() == upload.texture->siz
e(); |
| 157 | 158 |
| 158 if (isFullUpload) | 159 if (isFullUpload) |
| 159 beginQuery(); | 160 beginQuery(); |
| 160 | 161 |
| 161 upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destO
ffset); | 162 if (upload.bitmap) { |
| 163 upload.bitmap->lockPixels(); |
| 164 upload.texture->upload( |
| 165 resourceProvider, |
| 166 static_cast<const uint8_t*>(upload.bitmap->getPixels()), |
| 167 upload.geometry.contentRect, |
| 168 upload.geometry.sourceRect, |
| 169 upload.geometry.destOffset); |
| 170 upload.bitmap->unlockPixels(); |
| 171 } |
| 172 |
| 173 // TODO(reveman): Move this logic to CCTextureUpdateController. |
| 174 if (upload.picture) { |
| 175 upload.texture->acceleratedUpdate( |
| 176 resourceProvider, |
| 177 upload.picture, |
| 178 upload.geometry.contentRect, |
| 179 upload.geometry.sourceRect, |
| 180 upload.geometry.destOffset); |
| 181 } |
| 162 | 182 |
| 163 if (isFullUpload) | 183 if (isFullUpload) |
| 164 endQuery(); | 184 endQuery(); |
| 165 } | 185 } |
| 166 | 186 |
| 167 void ThrottledTextureUploader::processQueries() | 187 void ThrottledTextureUploader::processQueries() |
| 168 { | 188 { |
| 169 while (!m_pendingQueries.isEmpty()) { | 189 while (!m_pendingQueries.isEmpty()) { |
| 170 if (m_pendingQueries.first()->isPending()) | 190 if (m_pendingQueries.first()->isPending()) |
| 171 break; | 191 break; |
| 172 | 192 |
| 173 unsigned usElapsed = m_pendingQueries.first()->value(); | 193 unsigned usElapsed = m_pendingQueries.first()->value(); |
| 174 WebKit::Platform::current()->histogramCustomCounts("Renderer4.TextureGpu
UploadTimeUS", usElapsed, 0, 100000, 50); | 194 WebKit::Platform::current()->histogramCustomCounts("Renderer4.TextureGpu
UploadTimeUS", usElapsed, 0, 100000, 50); |
| 175 | 195 |
| 176 if (!m_pendingQueries.first()->isNonBlocking()) | 196 if (!m_pendingQueries.first()->isNonBlocking()) |
| 177 m_numBlockingTextureUploads--; | 197 m_numBlockingTextureUploads--; |
| 178 | 198 |
| 179 // Remove the oldest values from our history and insert the new one | 199 // Remove the oldest values from our history and insert the new one |
| 180 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); | 200 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); |
| 181 m_texturesPerSecondHistory.pop_back(); | 201 m_texturesPerSecondHistory.pop_back(); |
| 182 m_texturesPerSecondHistory.push_front(texturesPerSecond); | 202 m_texturesPerSecondHistory.push_front(texturesPerSecond); |
| 183 | 203 |
| 184 m_availableQueries.append(m_pendingQueries.takeFirst()); | 204 m_availableQueries.append(m_pendingQueries.takeFirst()); |
| 185 } | 205 } |
| 186 } | 206 } |
| 187 | 207 |
| 188 } | 208 } |
| OLD | NEW |