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 | 6 |
7 #include "cc/resource_update_controller.h" | 7 #include "cc/resource_update_controller.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/prioritized_texture.h" | 10 #include "cc/prioritized_texture.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Measured in seconds. | 32 // Measured in seconds. |
33 const double uploaderBusyTickRate = 0.001; | 33 const double uploaderBusyTickRate = 0.001; |
34 | 34 |
35 // Flush interval when performing texture uploads. | 35 // Flush interval when performing texture uploads. |
36 const int textureUploadFlushPeriod = 4; | 36 const int textureUploadFlushPeriod = 4; |
37 | 37 |
38 // Number of blocking update intervals to allow. | 38 // Number of blocking update intervals to allow. |
39 const size_t maxBlockingUpdateIntervals = 4; | 39 const size_t maxBlockingUpdateIntervals = 4; |
40 | 40 |
41 scoped_ptr<SkCanvas> createAcceleratedCanvas( | 41 scoped_ptr<SkCanvas> createAcceleratedCanvas( |
42 GrContext* grContext, cc::IntSize canvasSize, unsigned textureId) | 42 GrContext* grContext, gfx::Size canvasSize, unsigned textureId) |
43 { | 43 { |
44 GrPlatformTextureDesc textureDesc; | 44 GrPlatformTextureDesc textureDesc; |
45 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; | 45 textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag; |
46 textureDesc.fWidth = canvasSize.width(); | 46 textureDesc.fWidth = canvasSize.width(); |
47 textureDesc.fHeight = canvasSize.height(); | 47 textureDesc.fHeight = canvasSize.height(); |
48 textureDesc.fConfig = kSkia8888_GrPixelConfig; | 48 textureDesc.fConfig = kSkia8888_GrPixelConfig; |
49 textureDesc.fTextureHandle = textureId; | 49 textureDesc.fTextureHandle = textureId; |
50 SkAutoTUnref<GrTexture> target( | 50 SkAutoTUnref<GrTexture> target( |
51 grContext->createPlatformTexture(textureDesc)); | 51 grContext->createPlatformTexture(textureDesc)); |
52 SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); | 52 SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get())); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 void ResourceUpdateController::discardUploadsToEvictedResources() | 115 void ResourceUpdateController::discardUploadsToEvictedResources() |
116 { | 116 { |
117 m_queue->clearUploadsToEvictedResources(); | 117 m_queue->clearUploadsToEvictedResources(); |
118 } | 118 } |
119 | 119 |
120 void ResourceUpdateController::updateTexture(ResourceUpdate update) | 120 void ResourceUpdateController::updateTexture(ResourceUpdate update) |
121 { | 121 { |
122 if (update.picture) { | 122 if (update.picture) { |
123 PrioritizedTexture* texture = update.texture; | 123 PrioritizedTexture* texture = update.texture; |
124 IntRect pictureRect = update.content_rect; | 124 gfx::Rect pictureRect = update.content_rect; |
125 IntRect sourceRect = update.source_rect; | 125 gfx::Rect sourceRect = update.source_rect; |
126 IntSize destOffset = update.dest_offset; | 126 gfx::Vector2d destOffset = update.dest_offset; |
127 | 127 |
128 texture->acquireBackingTexture(m_resourceProvider); | 128 texture->acquireBackingTexture(m_resourceProvider); |
129 DCHECK(texture->haveBackingTexture()); | 129 DCHECK(texture->haveBackingTexture()); |
130 | 130 |
131 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == | 131 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == |
132 ResourceProvider::GLTexture); | 132 ResourceProvider::GLTexture); |
133 | 133 |
134 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? | 134 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? |
135 WebSharedGraphicsContext3D::compositorThreadContext() : | 135 WebSharedGraphicsContext3D::compositorThreadContext() : |
136 WebSharedGraphicsContext3D::mainThreadContext(); | 136 WebSharedGraphicsContext3D::mainThreadContext(); |
(...skipping 15 matching lines...) Expand all Loading... |
152 // Create an accelerated canvas to draw on. | 152 // Create an accelerated canvas to draw on. |
153 scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( | 153 scoped_ptr<SkCanvas> canvas = createAcceleratedCanvas( |
154 paintGrContext, texture->size(), lock.textureId()); | 154 paintGrContext, texture->size(), lock.textureId()); |
155 | 155 |
156 // The compositor expects the textures to be upside-down so it can flip | 156 // 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 | 157 // the final composited image. Ganesh renders the image upright so we |
158 // need to do a y-flip. | 158 // need to do a y-flip. |
159 canvas->translate(0.0, texture->size().height()); | 159 canvas->translate(0.0, texture->size().height()); |
160 canvas->scale(1.0, -1.0); | 160 canvas->scale(1.0, -1.0); |
161 // Clip to the destination on the texture that must be updated. | 161 // Clip to the destination on the texture that must be updated. |
162 canvas->clipRect(SkRect::MakeXYWH(destOffset.width(), | 162 canvas->clipRect(SkRect::MakeXYWH(destOffset.x(), |
163 destOffset.height(), | 163 destOffset.y(), |
164 sourceRect.width(), | 164 sourceRect.width(), |
165 sourceRect.height())); | 165 sourceRect.height())); |
166 // Translate the origin of pictureRect to destOffset. | 166 // Translate the origin of pictureRect to destOffset. |
167 // Note that destOffset is defined relative to sourceRect. | 167 // Note that destOffset is defined relative to sourceRect. |
168 canvas->translate( | 168 canvas->translate( |
169 pictureRect.x() - sourceRect.x() + destOffset.width(), | 169 pictureRect.x() - sourceRect.x() + destOffset.x(), |
170 pictureRect.y() - sourceRect.y() + destOffset.height()); | 170 pictureRect.y() - sourceRect.y() + destOffset.y()); |
171 canvas->drawPicture(*update.picture); | 171 canvas->drawPicture(*update.picture); |
172 | 172 |
173 // Flush ganesh context so that all the rendered stuff appears on the | 173 // Flush ganesh context so that all the rendered stuff appears on the |
174 // texture. | 174 // texture. |
175 paintGrContext->flush(); | 175 paintGrContext->flush(); |
176 | 176 |
177 // Flush the GL context so rendering results from this context are | 177 // Flush the GL context so rendering results from this context are |
178 // visible in the compositor's context. | 178 // visible in the compositor's context. |
179 paintContext->flush(); | 179 paintContext->flush(); |
180 } | 180 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 while (m_queue->fullUploadSize() && uploadCount < uploads) { | 295 while (m_queue->fullUploadSize() && uploadCount < uploads) { |
296 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) | 296 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) |
297 m_resourceProvider->shallowFlushIfSupported(); | 297 m_resourceProvider->shallowFlushIfSupported(); |
298 updateTexture(m_queue->takeFirstFullUpload()); | 298 updateTexture(m_queue->takeFirstFullUpload()); |
299 uploadCount++; | 299 uploadCount++; |
300 } | 300 } |
301 m_resourceProvider->shallowFlushIfSupported(); | 301 m_resourceProvider->shallowFlushIfSupported(); |
302 } | 302 } |
303 | 303 |
304 } // namespace cc | 304 } // namespace cc |
OLD | NEW |