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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/prioritized_resource.h" | 10 #include "cc/prioritized_resource.h" |
11 #include "cc/resource_provider.h" | 11 #include "cc/resource_provider.h" |
12 #include "cc/texture_copier.h" | 12 #include "cc/texture_copier.h" |
13 #include "cc/thread.h" | 13 #include "cc/thread.h" |
14 #include "skia/ext/refptr.h" | 14 #include "skia/ext/refptr.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo
ntext3D.h" | |
17 #include "third_party/khronos/GLES2/gl2.h" | 16 #include "third_party/khronos/GLES2/gl2.h" |
18 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 17 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
19 | 18 |
20 using WebKit::WebGraphicsContext3D; | 19 using WebKit::WebGraphicsContext3D; |
21 using WebKit::WebSharedGraphicsContext3D; | |
22 | 20 |
23 namespace { | 21 namespace { |
24 | 22 |
25 // Number of partial updates we allow. | 23 // Number of partial updates we allow. |
26 const size_t partialTextureUpdatesMax = 12; | 24 const size_t partialTextureUpdatesMax = 12; |
27 | 25 |
28 // Measured in seconds. | 26 // Measured in seconds. |
29 const double textureUpdateTickRate = 0.004; | 27 const double textureUpdateTickRate = 0.004; |
30 | 28 |
31 // Measured in seconds. | 29 // Measured in seconds. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 115 } |
118 | 116 |
119 void ResourceUpdateController::updateTexture(ResourceUpdate update) | 117 void ResourceUpdateController::updateTexture(ResourceUpdate update) |
120 { | 118 { |
121 if (update.picture) { | 119 if (update.picture) { |
122 PrioritizedResource* texture = update.texture; | 120 PrioritizedResource* texture = update.texture; |
123 gfx::Rect pictureRect = update.content_rect; | 121 gfx::Rect pictureRect = update.content_rect; |
124 gfx::Rect sourceRect = update.source_rect; | 122 gfx::Rect sourceRect = update.source_rect; |
125 gfx::Vector2d destOffset = update.dest_offset; | 123 gfx::Vector2d destOffset = update.dest_offset; |
126 | 124 |
| 125 WebGraphicsContext3D* paintContext = m_resourceProvider->offscreenGraphi
csContext3d(); |
| 126 if (!paintContext) |
| 127 return; |
| 128 |
| 129 GrContext* paintGrContext = m_resourceProvider->offscreenGrContext(); |
| 130 if (!paintGrContext) |
| 131 return; |
| 132 |
127 texture->acquireBackingTexture(m_resourceProvider); | 133 texture->acquireBackingTexture(m_resourceProvider); |
128 DCHECK(texture->haveBackingTexture()); | 134 DCHECK(texture->haveBackingTexture()); |
129 | 135 |
130 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == | 136 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == |
131 ResourceProvider::GLTexture); | 137 ResourceProvider::GLTexture); |
132 | 138 |
133 WebGraphicsContext3D* paintContext = m_hasImplThread ? | |
134 WebSharedGraphicsContext3D::compositorThreadContext() : | |
135 WebSharedGraphicsContext3D::mainThreadContext(); | |
136 GrContext* paintGrContext = m_hasImplThread ? | |
137 WebSharedGraphicsContext3D::compositorThreadGrContext() : | |
138 WebSharedGraphicsContext3D::mainThreadGrContext(); | |
139 | |
140 // Flush the context in which the backing texture is created so that it | 139 // Flush the context in which the backing texture is created so that it |
141 // is available in other shared contexts. It is important to do here | 140 // is available in other shared contexts. It is important to do here |
142 // because the backing texture is created in one context while it is | 141 // because the backing texture is created in one context while it is |
143 // being written to in another. | 142 // being written to in another. |
144 ResourceProvider::ScopedWriteLockGL lock( | 143 ResourceProvider::ScopedWriteLockGL lock( |
145 m_resourceProvider, texture->resourceId()); | 144 m_resourceProvider, texture->resourceId()); |
146 m_resourceProvider->flush(); | 145 m_resourceProvider->flush(); |
147 | 146 |
148 // Make sure ganesh uses the correct GL context. | 147 // Make sure ganesh uses the correct GL context. |
149 paintContext->makeContextCurrent(); | 148 paintContext->makeContextCurrent(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (!uploads) | 282 if (!uploads) |
284 return; | 283 return; |
285 | 284 |
286 while (m_queue->fullUploadSize() && uploads--) | 285 while (m_queue->fullUploadSize() && uploads--) |
287 updateTexture(m_queue->takeFirstFullUpload()); | 286 updateTexture(m_queue->takeFirstFullUpload()); |
288 | 287 |
289 m_resourceProvider->flushUploads(); | 288 m_resourceProvider->flushUploads(); |
290 } | 289 } |
291 | 290 |
292 } // namespace cc | 291 } // namespace cc |
OLD | NEW |