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" |
| 11 #include "cc/proxy.h" |
11 #include "cc/resource_provider.h" | 12 #include "cc/resource_provider.h" |
12 #include "cc/texture_copier.h" | 13 #include "cc/texture_copier.h" |
13 #include "cc/thread.h" | 14 #include "cc/thread.h" |
14 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
15 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 16 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
16 #include <limits> | 17 #include <limits> |
17 #include <public/WebGraphicsContext3D.h> | 18 #include <public/WebGraphicsContext3D.h> |
18 #include <public/WebSharedGraphicsContext3D.h> | 19 #include <public/WebSharedGraphicsContext3D.h> |
19 | 20 |
20 using WebKit::WebGraphicsContext3D; | 21 using WebKit::WebGraphicsContext3D; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 60 } |
60 | 61 |
61 size_t ResourceUpdateController::maxFullUpdatesPerTick( | 62 size_t ResourceUpdateController::maxFullUpdatesPerTick( |
62 ResourceProvider* resourceProvider) | 63 ResourceProvider* resourceProvider) |
63 { | 64 { |
64 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond(); | 65 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond(); |
65 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); | 66 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); |
66 return texturesPerTick ? texturesPerTick : 1; | 67 return texturesPerTick ? texturesPerTick : 1; |
67 } | 68 } |
68 | 69 |
69 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien
t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid
er* resourceProvider, bool hasImplThread) | 70 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien
t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid
er* resourceProvider) |
70 : m_client(client) | 71 : m_client(client) |
71 , m_hasImplThread(hasImplThread) | |
72 , m_queue(queue.Pass()) | 72 , m_queue(queue.Pass()) |
73 , m_resourceProvider(resourceProvider) | 73 , m_resourceProvider(resourceProvider) |
74 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider)) | 74 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider)) |
75 , m_firstUpdateAttempt(true) | 75 , m_firstUpdateAttempt(true) |
76 , m_thread(thread) | 76 , m_thread(thread) |
77 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 77 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
78 , m_taskPosted(false) | 78 , m_taskPosted(false) |
79 { | 79 { |
80 } | 80 } |
81 | 81 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 gfx::Rect pictureRect = update.content_rect; | 121 gfx::Rect pictureRect = update.content_rect; |
122 gfx::Rect sourceRect = update.source_rect; | 122 gfx::Rect sourceRect = update.source_rect; |
123 gfx::Vector2d destOffset = update.dest_offset; | 123 gfx::Vector2d destOffset = update.dest_offset; |
124 | 124 |
125 texture->acquireBackingTexture(m_resourceProvider); | 125 texture->acquireBackingTexture(m_resourceProvider); |
126 DCHECK(texture->haveBackingTexture()); | 126 DCHECK(texture->haveBackingTexture()); |
127 | 127 |
128 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == | 128 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == |
129 ResourceProvider::GLTexture); | 129 ResourceProvider::GLTexture); |
130 | 130 |
131 WebGraphicsContext3D* paintContext = m_hasImplThread ? | 131 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? |
132 WebSharedGraphicsContext3D::compositorThreadContext() : | 132 WebSharedGraphicsContext3D::compositorThreadContext() : |
133 WebSharedGraphicsContext3D::mainThreadContext(); | 133 WebSharedGraphicsContext3D::mainThreadContext(); |
134 GrContext* paintGrContext = m_hasImplThread ? | 134 GrContext* paintGrContext = Proxy::hasImplThread() ? |
135 WebSharedGraphicsContext3D::compositorThreadGrContext() : | 135 WebSharedGraphicsContext3D::compositorThreadGrContext() : |
136 WebSharedGraphicsContext3D::mainThreadGrContext(); | 136 WebSharedGraphicsContext3D::mainThreadGrContext(); |
137 | 137 |
138 // Flush the context in which the backing texture is created so that it | 138 // Flush the context in which the backing texture is created so that it |
139 // is available in other shared contexts. It is important to do here | 139 // is available in other shared contexts. It is important to do here |
140 // because the backing texture is created in one context while it is | 140 // because the backing texture is created in one context while it is |
141 // being written to in another. | 141 // being written to in another. |
142 m_resourceProvider->flush(); | 142 m_resourceProvider->flush(); |
143 ResourceProvider::ScopedWriteLockGL lock( | 143 ResourceProvider::ScopedWriteLockGL lock( |
144 m_resourceProvider, texture->resourceId()); | 144 m_resourceProvider, texture->resourceId()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 if (!uploads) | 276 if (!uploads) |
277 return; | 277 return; |
278 | 278 |
279 while (m_queue->fullUploadSize() && uploads--) | 279 while (m_queue->fullUploadSize() && uploads--) |
280 updateTexture(m_queue->takeFirstFullUpload()); | 280 updateTexture(m_queue->takeFirstFullUpload()); |
281 | 281 |
282 m_resourceProvider->flushUploads(); | 282 m_resourceProvider->flushUploads(); |
283 } | 283 } |
284 | 284 |
285 } // namespace cc | 285 } // namespace cc |
OLD | NEW |