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 11 matching lines...) Expand all Loading... |
22 namespace { | 22 namespace { |
23 | 23 |
24 // How many previous uploads to use when predicting future throughput. | 24 // How many previous uploads to use when predicting future throughput. |
25 static const size_t uploadHistorySize = 100; | 25 static const size_t uploadHistorySize = 100; |
26 | 26 |
27 // Global estimated number of textures per second to maintain estimates across | 27 // Global estimated number of textures per second to maintain estimates across |
28 // subsequent instances of ThrottledTextureUploader. | 28 // subsequent instances of ThrottledTextureUploader. |
29 // More than one thread will not access this variable, so we do not need to sync
hronize access. | 29 // More than one thread will not access this variable, so we do not need to sync
hronize access. |
30 static double estimatedTexturesPerSecondGlobal = 48.0 * 60.0; | 30 static double estimatedTexturesPerSecondGlobal = 48.0 * 60.0; |
31 | 31 |
32 PassOwnPtr<SkCanvas> createAcceleratedCanvas(GrContext* grContext, | 32 scoped_ptr<SkCanvas> createAcceleratedCanvas(GrContext* grContext, |
33 cc::IntSize canvasSize, | 33 cc::IntSize canvasSize, |
34 unsigned textureId) | 34 unsigned textureId) |
35 { | 35 { |
36 GrPlatformTextureDesc textureDesc; | 36 GrPlatformTextureDesc textureDesc; |
37 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; | 37 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; |
38 textureDesc.fWidth = canvasSize.width(); | 38 textureDesc.fWidth = canvasSize.width(); |
39 textureDesc.fHeight = canvasSize.height(); | 39 textureDesc.fHeight = canvasSize.height(); |
40 textureDesc.fConfig = kSkia8888_GrPixelConfig; | 40 textureDesc.fConfig = kSkia8888_GrPixelConfig; |
41 textureDesc.fTextureHandle = textureId; | 41 textureDesc.fTextureHandle = textureId; |
42 SkAutoTUnref<GrTexture> target( | 42 SkAutoTUnref<GrTexture> target( |
43 grContext->createPlatformTexture(textureDesc)); | 43 grContext->createPlatformTexture(textureDesc)); |
44 SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); | 44 SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); |
45 return adoptPtr(new SkCanvas(device.get())); | 45 return make_scoped_ptr(new SkCanvas(device.get())); |
46 } | 46 } |
47 | 47 |
48 } // anonymous namespace | 48 } // anonymous namespace |
49 | 49 |
50 namespace cc { | 50 namespace cc { |
51 | 51 |
52 ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) | 52 ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) |
53 : m_context(context) | 53 : m_context(context) |
54 , m_queryId(0) | 54 , m_queryId(0) |
55 , m_value(0) | 55 , m_value(0) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CCResourceProvider::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 OwnPtr<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 |
230 // the final composited image. Ganesh renders the image upright so we | 230 // the final composited image. Ganesh renders the image upright so we |
231 // need to do a y-flip. | 231 // need to do a y-flip. |
232 canvas->translate(0.0, texture->size().height()); | 232 canvas->translate(0.0, texture->size().height()); |
233 canvas->scale(1.0, -1.0); | 233 canvas->scale(1.0, -1.0); |
234 // Clip to the destination on the texture that must be updated. | 234 // Clip to the destination on the texture that must be updated. |
235 canvas->clipRect(SkRect::MakeXYWH(destOffset.width(), | 235 canvas->clipRect(SkRect::MakeXYWH(destOffset.width(), |
236 destOffset.height(), | 236 destOffset.height(), |
(...skipping 34 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 |