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 "cc/resource_update_controller.h" | 5 #include "cc/resource_update_controller.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/prioritized_resource.h" | 8 #include "cc/prioritized_resource.h" |
9 #include "cc/resource_provider.h" | 9 #include "cc/resource_provider.h" |
10 #include "cc/texture_copier.h" | 10 #include "cc/texture_copier.h" |
11 #include "cc/thread.h" | 11 #include "cc/thread.h" |
| 12 #include "skia/ext/refptr.h" |
12 #include "third_party/khronos/GLES2/gl2.h" | 13 #include "third_party/khronos/GLES2/gl2.h" |
13 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 14 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
14 #include <limits> | 15 #include <limits> |
15 #include <public/WebGraphicsContext3D.h> | 16 #include <public/WebGraphicsContext3D.h> |
16 #include <public/WebSharedGraphicsContext3D.h> | 17 #include <public/WebSharedGraphicsContext3D.h> |
17 | 18 |
18 using WebKit::WebGraphicsContext3D; | 19 using WebKit::WebGraphicsContext3D; |
19 using WebKit::WebSharedGraphicsContext3D; | 20 using WebKit::WebSharedGraphicsContext3D; |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Number of partial updates we allow. | 24 // Number of partial updates we allow. |
24 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
25 const size_t partialTextureUpdatesMax = 0; | 26 const size_t partialTextureUpdatesMax = 0; |
26 #else | 27 #else |
27 const size_t partialTextureUpdatesMax = 12; | 28 const size_t partialTextureUpdatesMax = 12; |
28 #endif | 29 #endif |
29 | 30 |
30 // Measured in seconds. | 31 // Measured in seconds. |
31 const double textureUpdateTickRate = 0.004; | 32 const double textureUpdateTickRate = 0.004; |
32 | 33 |
33 // Measured in seconds. | 34 // Measured in seconds. |
34 const double uploaderBusyTickRate = 0.001; | 35 const double uploaderBusyTickRate = 0.001; |
35 | 36 |
36 // Number of blocking update intervals to allow. | 37 // Number of blocking update intervals to allow. |
37 const size_t maxBlockingUpdateIntervals = 4; | 38 const size_t maxBlockingUpdateIntervals = 4; |
38 | 39 |
39 scoped_ptr<SkCanvas> createAcceleratedCanvas( | 40 skia::RefPtr<SkCanvas> createAcceleratedCanvas( |
40 GrContext* grContext, gfx::Size canvasSize, unsigned textureId) | 41 GrContext* grContext, gfx::Size canvasSize, unsigned textureId) |
41 { | 42 { |
42 GrPlatformTextureDesc textureDesc; | 43 GrPlatformTextureDesc textureDesc; |
43 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; | 44 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; |
44 textureDesc.fWidth = canvasSize.width(); | 45 textureDesc.fWidth = canvasSize.width(); |
45 textureDesc.fHeight = canvasSize.height(); | 46 textureDesc.fHeight = canvasSize.height(); |
46 textureDesc.fConfig = kSkia8888_GrPixelConfig; | 47 textureDesc.fConfig = kSkia8888_GrPixelConfig; |
47 textureDesc.fTextureHandle = textureId; | 48 textureDesc.fTextureHandle = textureId; |
48 SkAutoTUnref<GrTexture> target( | 49 skia::RefPtr<GrTexture> target = |
49 grContext->createPlatformTexture(textureDesc)); | 50 skia::AdoptRef(grContext->createPlatformTexture(textureDesc)); |
50 SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); | 51 skia::RefPtr<SkDevice> device = |
51 return make_scoped_ptr(new SkCanvas(device.get())); | 52 skia::AdoptRef(new SkGpuDevice(grContext, target.get())); |
| 53 return skia::AdoptRef(new SkCanvas(device.get())); |
52 } | 54 } |
53 | 55 |
54 } // namespace | 56 } // namespace |
55 | 57 |
56 namespace cc { | 58 namespace cc { |
57 | 59 |
58 size_t ResourceUpdateController::maxPartialTextureUpdates() | 60 size_t ResourceUpdateController::maxPartialTextureUpdates() |
59 { | 61 { |
60 return partialTextureUpdatesMax; | 62 return partialTextureUpdatesMax; |
61 } | 63 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // because the backing texture is created in one context while it is | 145 // because the backing texture is created in one context while it is |
144 // being written to in another. | 146 // being written to in another. |
145 m_resourceProvider->flush(); | 147 m_resourceProvider->flush(); |
146 ResourceProvider::ScopedWriteLockGL lock( | 148 ResourceProvider::ScopedWriteLockGL lock( |
147 m_resourceProvider, texture->resourceId()); | 149 m_resourceProvider, texture->resourceId()); |
148 | 150 |
149 // Make sure ganesh uses the correct GL context. | 151 // Make sure ganesh uses the correct GL context. |
150 paintContext->makeContextCurrent(); | 152 paintContext->makeContextCurrent(); |
151 | 153 |
152 // Create an accelerated canvas to draw on. | 154 // Create an accelerated canvas to draw on. |
153 scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( | 155 skia::RefPtr<SkCanvas> canvas = createAcceleratedCanvas( |
154 paintGrContext, texture->size(), lock.textureId()); | 156 paintGrContext, texture->size(), lock.textureId()); |
155 | 157 |
156 // The compositor expects the textures to be upside-down so it can flip | 158 // The compositor expects the textures to be upside-down so it can flip |
157 // the final composited image. Ganesh renders the image upright so we | 159 // the final composited image. Ganesh renders the image upright so we |
158 // need to do a y-flip. | 160 // need to do a y-flip. |
159 canvas->translate(0.0, texture->size().height()); | 161 canvas->translate(0.0, texture->size().height()); |
160 canvas->scale(1.0, -1.0); | 162 canvas->scale(1.0, -1.0); |
161 // Clip to the destination on the texture that must be updated. | 163 // Clip to the destination on the texture that must be updated. |
162 canvas->clipRect(SkRect::MakeXYWH(destOffset.x(), | 164 canvas->clipRect(SkRect::MakeXYWH(destOffset.x(), |
163 destOffset.y(), | 165 destOffset.y(), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (!uploads) | 286 if (!uploads) |
285 return; | 287 return; |
286 | 288 |
287 while (m_queue->fullUploadSize() && uploads--) | 289 while (m_queue->fullUploadSize() && uploads--) |
288 updateTexture(m_queue->takeFirstFullUpload()); | 290 updateTexture(m_queue->takeFirstFullUpload()); |
289 | 291 |
290 m_resourceProvider->flushUploads(); | 292 m_resourceProvider->flushUploads(); |
291 } | 293 } |
292 | 294 |
293 } // namespace cc | 295 } // namespace cc |
OLD | NEW |