OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "CCSingleThreadProxy.h" | 7 #include "CCSingleThreadProxy.h" |
8 | 8 |
9 #include "CCDrawQuad.h" | 9 #include "CCDrawQuad.h" |
10 #include "CCGraphicsContext.h" | 10 #include "CCGraphicsContext.h" |
11 #include "CCLayerTreeHost.h" | 11 #include "CCLayerTreeHost.h" |
12 #include "CCTextureUpdateController.h" | 12 #include "CCTextureUpdateController.h" |
13 #include "CCTimer.h" | 13 #include "CCTimer.h" |
14 #include "TraceEvent.h" | 14 #include "TraceEvent.h" |
15 #include <wtf/CurrentTime.h> | 15 #include <wtf/CurrentTime.h> |
16 | 16 |
17 using namespace WTF; | 17 using namespace WTF; |
18 | 18 |
| 19 namespace { |
| 20 |
| 21 // We don't need to split texture uploads into multiple batches if we are single
threaded. |
| 22 const size_t maxTextureUpdates = std::numeric_limits<size_t>::max(); |
| 23 |
| 24 } |
| 25 |
19 namespace WebCore { | 26 namespace WebCore { |
20 | 27 |
21 PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost) | 28 PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost) |
22 { | 29 { |
23 return adoptPtr(new CCSingleThreadProxy(layerTreeHost)); | 30 return adoptPtr(new CCSingleThreadProxy(layerTreeHost)); |
24 } | 31 } |
25 | 32 |
26 CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost) | 33 CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost) |
27 : m_layerTreeHost(layerTreeHost) | 34 : m_layerTreeHost(layerTreeHost) |
28 , m_contextLost(false) | 35 , m_contextLost(false) |
29 , m_rendererInitialized(false) | 36 , m_rendererInitialized(false) |
30 , m_nextFrameIsNewlyCommittedFrame(false) | 37 , m_nextFrameIsNewlyCommittedFrame(false) |
| 38 , m_totalCommitTime(0) |
| 39 , m_totalCommitCount(0) |
31 { | 40 { |
32 TRACE_EVENT0("cc", "CCSingleThreadProxy::CCSingleThreadProxy"); | 41 TRACE_EVENT0("cc", "CCSingleThreadProxy::CCSingleThreadProxy"); |
33 ASSERT(CCProxy::isMainThread()); | 42 ASSERT(CCProxy::isMainThread()); |
34 } | 43 } |
35 | 44 |
36 void CCSingleThreadProxy::start() | 45 void CCSingleThreadProxy::start() |
37 { | 46 { |
38 DebugScopedSetImplThread impl; | 47 DebugScopedSetImplThread impl; |
39 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); | 48 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); |
40 } | 49 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC
apabilities(); | 152 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC
apabilities(); |
144 } | 153 } |
145 } | 154 } |
146 | 155 |
147 if (initialized) | 156 if (initialized) |
148 m_contextLost = false; | 157 m_contextLost = false; |
149 | 158 |
150 return initialized; | 159 return initialized; |
151 } | 160 } |
152 | 161 |
153 void CCSingleThreadProxy::implSideRenderingStats(CCRenderingStats& stats) | 162 void CCSingleThreadProxy::renderingStats(CCRenderingStats& stats) |
154 { | 163 { |
| 164 stats.totalCommitTimeInSeconds = m_totalCommitTime; |
| 165 stats.totalCommitCount = m_totalCommitCount; |
155 m_layerTreeHostImpl->renderingStats(stats); | 166 m_layerTreeHostImpl->renderingStats(stats); |
156 } | 167 } |
157 | 168 |
158 const RendererCapabilities& CCSingleThreadProxy::rendererCapabilities() const | 169 const RendererCapabilities& CCSingleThreadProxy::rendererCapabilities() const |
159 { | 170 { |
160 ASSERT(m_rendererInitialized); | 171 ASSERT(m_rendererInitialized); |
161 // Note: this gets called during the commit by the "impl" thread | 172 // Note: this gets called during the commit by the "impl" thread |
162 return m_RendererCapabilitiesForMainThread; | 173 return m_RendererCapabilitiesForMainThread; |
163 } | 174 } |
164 | 175 |
(...skipping 11 matching lines...) Expand all Loading... |
176 } | 187 } |
177 | 188 |
178 void CCSingleThreadProxy::doCommit(CCTextureUpdateQueue& queue) | 189 void CCSingleThreadProxy::doCommit(CCTextureUpdateQueue& queue) |
179 { | 190 { |
180 ASSERT(CCProxy::isMainThread()); | 191 ASSERT(CCProxy::isMainThread()); |
181 // Commit immediately | 192 // Commit immediately |
182 { | 193 { |
183 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 194 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
184 DebugScopedSetImplThread impl; | 195 DebugScopedSetImplThread impl; |
185 | 196 |
| 197 double startTime = WTF::monotonicallyIncreasingTime(); |
186 m_layerTreeHostImpl->beginCommit(); | 198 m_layerTreeHostImpl->beginCommit(); |
187 | 199 |
188 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 200 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
189 | 201 |
190 // CCTextureUpdateController::updateTextures is non-blocking and will | 202 // CCTextureUpdateController::updateTextures is non-blocking and will |
191 // return without updating any textures if the uploader is busy. This | 203 // return without updating any textures if the uploader is busy. This |
192 // shouldn't be a problem here as the throttled uploader isn't used in | 204 // shouldn't be a problem here as the throttled uploader isn't used in |
193 // single thread mode. For correctness, loop until no more updates are | 205 // single thread mode. For correctness, loop until no more updates are |
194 // pending. | 206 // pending. |
195 while (queue.hasMoreUpdates()) | 207 while (queue.hasMoreUpdates()) |
196 CCTextureUpdateController::updateTextures(m_layerTreeHostImpl->resou
rceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHost
Impl->renderer()->textureUploader(), &queue, maxPartialTextureUpdates()); | 208 CCTextureUpdateController::updateTextures(m_layerTreeHostImpl->resou
rceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHost
Impl->renderer()->textureUploader(), &queue, maxTextureUpdates); |
197 | 209 |
198 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 210 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
199 | 211 |
200 m_layerTreeHostImpl->commitComplete(); | 212 m_layerTreeHostImpl->commitComplete(); |
201 | 213 |
202 #if !ASSERT_DISABLED | 214 #if !ASSERT_DISABLED |
203 // In the single-threaded case, the scroll deltas should never be | 215 // In the single-threaded case, the scroll deltas should never be |
204 // touched on the impl layer tree. | 216 // touched on the impl layer tree. |
205 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processScr
ollDeltas(); | 217 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processScr
ollDeltas(); |
206 ASSERT(!scrollInfo->scrolls.size()); | 218 ASSERT(!scrollInfo->scrolls.size()); |
207 #endif | 219 #endif |
| 220 |
| 221 double endTime = WTF::monotonicallyIncreasingTime(); |
| 222 double commitTime = endTime - startTime; |
| 223 m_totalCommitTime += commitTime; |
| 224 m_totalCommitCount++; |
208 } | 225 } |
209 m_layerTreeHost->commitComplete(); | 226 m_layerTreeHost->commitComplete(); |
210 m_nextFrameIsNewlyCommittedFrame = true; | 227 m_nextFrameIsNewlyCommittedFrame = true; |
211 } | 228 } |
212 | 229 |
213 void CCSingleThreadProxy::setNeedsCommit() | 230 void CCSingleThreadProxy::setNeedsCommit() |
214 { | 231 { |
215 ASSERT(CCProxy::isMainThread()); | 232 ASSERT(CCProxy::isMainThread()); |
216 m_layerTreeHost->scheduleComposite(); | 233 m_layerTreeHost->scheduleComposite(); |
217 } | 234 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (!m_layerTreeHost->initializeRendererIfNeeded()) | 297 if (!m_layerTreeHost->initializeRendererIfNeeded()) |
281 return false; | 298 return false; |
282 | 299 |
283 if (m_layerTreeHostImpl->contentsTexturesPurged()) { | 300 if (m_layerTreeHostImpl->contentsTexturesPurged()) { |
284 m_layerTreeHost->unlinkAllContentTextures(); | 301 m_layerTreeHost->unlinkAllContentTextures(); |
285 DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked; | 302 DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked; |
286 m_layerTreeHost->deleteUnlinkedTextures(); | 303 m_layerTreeHost->deleteUnlinkedTextures(); |
287 } | 304 } |
288 | 305 |
289 CCTextureUpdateQueue queue; | 306 CCTextureUpdateQueue queue; |
290 m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLi
mitBytes()); | 307 m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLi
mitBytes(), maxTextureUpdates); |
291 m_layerTreeHostImpl->resetContentsTexturesPurged(); | 308 m_layerTreeHostImpl->resetContentsTexturesPurged(); |
292 | 309 |
293 m_layerTreeHost->willCommit(); | 310 m_layerTreeHost->willCommit(); |
294 doCommit(queue); | 311 doCommit(queue); |
295 bool result = doComposite(); | 312 bool result = doComposite(); |
296 m_layerTreeHost->didBeginFrame(); | 313 m_layerTreeHost->didBeginFrame(); |
297 return result; | 314 return result; |
298 } | 315 } |
299 | 316 |
300 bool CCSingleThreadProxy::doComposite() | 317 bool CCSingleThreadProxy::doComposite() |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 350 |
334 void CCSingleThreadProxy::didSwapFrame() | 351 void CCSingleThreadProxy::didSwapFrame() |
335 { | 352 { |
336 if (m_nextFrameIsNewlyCommittedFrame) { | 353 if (m_nextFrameIsNewlyCommittedFrame) { |
337 m_nextFrameIsNewlyCommittedFrame = false; | 354 m_nextFrameIsNewlyCommittedFrame = false; |
338 m_layerTreeHost->didCommitAndDrawFrame(); | 355 m_layerTreeHost->didCommitAndDrawFrame(); |
339 } | 356 } |
340 } | 357 } |
341 | 358 |
342 } | 359 } |
OLD | NEW |