Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: cc/CCSingleThreadProxy.cpp

Issue 11048044: cc: Switch to Chromium DCHECKs and LOGs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost) 26 CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost)
27 : m_layerTreeHost(layerTreeHost) 27 : m_layerTreeHost(layerTreeHost)
28 , m_contextLost(false) 28 , m_contextLost(false)
29 , m_rendererInitialized(false) 29 , m_rendererInitialized(false)
30 , m_nextFrameIsNewlyCommittedFrame(false) 30 , m_nextFrameIsNewlyCommittedFrame(false)
31 , m_totalCommitCount(0) 31 , m_totalCommitCount(0)
32 { 32 {
33 TRACE_EVENT0("cc", "CCSingleThreadProxy::CCSingleThreadProxy"); 33 TRACE_EVENT0("cc", "CCSingleThreadProxy::CCSingleThreadProxy");
34 ASSERT(CCProxy::isMainThread()); 34 DCHECK(CCProxy::isMainThread());
35 } 35 }
36 36
37 void CCSingleThreadProxy::start() 37 void CCSingleThreadProxy::start()
38 { 38 {
39 DebugScopedSetImplThread impl; 39 DebugScopedSetImplThread impl;
40 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); 40 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
41 } 41 }
42 42
43 CCSingleThreadProxy::~CCSingleThreadProxy() 43 CCSingleThreadProxy::~CCSingleThreadProxy()
44 { 44 {
45 TRACE_EVENT0("cc", "CCSingleThreadProxy::~CCSingleThreadProxy"); 45 TRACE_EVENT0("cc", "CCSingleThreadProxy::~CCSingleThreadProxy");
46 ASSERT(CCProxy::isMainThread()); 46 DCHECK(CCProxy::isMainThread());
47 ASSERT(!m_layerTreeHostImpl.get() && !m_layerTreeHost); // make sure stop() got called. 47 DCHECK(!m_layerTreeHostImpl.get() && !m_layerTreeHost); // make sure stop() got called.
48 } 48 }
49 49
50 bool CCSingleThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect ) 50 bool CCSingleThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect )
51 { 51 {
52 TRACE_EVENT0("cc", "CCSingleThreadProxy::compositeAndReadback"); 52 TRACE_EVENT0("cc", "CCSingleThreadProxy::compositeAndReadback");
53 ASSERT(CCProxy::isMainThread()); 53 DCHECK(CCProxy::isMainThread());
54 54
55 if (!commitAndComposite()) 55 if (!commitAndComposite())
56 return false; 56 return false;
57 57
58 m_layerTreeHostImpl->readback(pixels, rect); 58 m_layerTreeHostImpl->readback(pixels, rect);
59 59
60 if (m_layerTreeHostImpl->isContextLost()) 60 if (m_layerTreeHostImpl->isContextLost())
61 return false; 61 return false;
62 62
63 m_layerTreeHostImpl->swapBuffers(); 63 m_layerTreeHostImpl->swapBuffers();
64 didSwapFrame(); 64 didSwapFrame();
65 65
66 return true; 66 return true;
67 } 67 }
68 68
69 void CCSingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) 69 void CCSingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration)
70 { 70 {
71 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scal e, monotonicallyIncreasingTime(), duration); 71 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scal e, monotonicallyIncreasingTime(), duration);
72 } 72 }
73 73
74 void CCSingleThreadProxy::finishAllRendering() 74 void CCSingleThreadProxy::finishAllRendering()
75 { 75 {
76 ASSERT(CCProxy::isMainThread()); 76 DCHECK(CCProxy::isMainThread());
77 { 77 {
78 DebugScopedSetImplThread impl; 78 DebugScopedSetImplThread impl;
79 m_layerTreeHostImpl->finishAllRendering(); 79 m_layerTreeHostImpl->finishAllRendering();
80 } 80 }
81 } 81 }
82 82
83 bool CCSingleThreadProxy::isStarted() const 83 bool CCSingleThreadProxy::isStarted() const
84 { 84 {
85 ASSERT(CCProxy::isMainThread()); 85 DCHECK(CCProxy::isMainThread());
86 return m_layerTreeHostImpl.get(); 86 return m_layerTreeHostImpl.get();
87 } 87 }
88 88
89 bool CCSingleThreadProxy::initializeContext() 89 bool CCSingleThreadProxy::initializeContext()
90 { 90 {
91 ASSERT(CCProxy::isMainThread()); 91 DCHECK(CCProxy::isMainThread());
92 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 92 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
93 if (!context.get()) 93 if (!context.get())
94 return false; 94 return false;
95 m_contextBeforeInitialization = context.Pass(); 95 m_contextBeforeInitialization = context.Pass();
96 return true; 96 return true;
97 } 97 }
98 98
99 void CCSingleThreadProxy::setSurfaceReady() 99 void CCSingleThreadProxy::setSurfaceReady()
100 { 100 {
101 // Scheduling is controlled by the embedder in the single thread case, so no thing to do. 101 // Scheduling is controlled by the embedder in the single thread case, so no thing to do.
102 } 102 }
103 103
104 void CCSingleThreadProxy::setVisible(bool visible) 104 void CCSingleThreadProxy::setVisible(bool visible)
105 { 105 {
106 DebugScopedSetImplThread impl; 106 DebugScopedSetImplThread impl;
107 m_layerTreeHostImpl->setVisible(visible); 107 m_layerTreeHostImpl->setVisible(visible);
108 } 108 }
109 109
110 bool CCSingleThreadProxy::initializeRenderer() 110 bool CCSingleThreadProxy::initializeRenderer()
111 { 111 {
112 ASSERT(CCProxy::isMainThread()); 112 DCHECK(CCProxy::isMainThread());
113 ASSERT(m_contextBeforeInitialization.get()); 113 DCHECK(m_contextBeforeInitialization.get());
114 { 114 {
115 DebugScopedSetImplThread impl; 115 DebugScopedSetImplThread impl;
116 bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitial ization.Pass()); 116 bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitial ization.Pass());
117 if (ok) { 117 if (ok) {
118 m_rendererInitialized = true; 118 m_rendererInitialized = true;
119 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); 119 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities();
120 } 120 }
121 121
122 return ok; 122 return ok;
123 } 123 }
124 } 124 }
125 125
126 bool CCSingleThreadProxy::recreateContext() 126 bool CCSingleThreadProxy::recreateContext()
127 { 127 {
128 TRACE_EVENT0("cc", "CCSingleThreadProxy::recreateContext"); 128 TRACE_EVENT0("cc", "CCSingleThreadProxy::recreateContext");
129 ASSERT(CCProxy::isMainThread()); 129 DCHECK(CCProxy::isMainThread());
130 ASSERT(m_contextLost); 130 DCHECK(m_contextLost);
131 131
132 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); 132 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
133 if (!context.get()) 133 if (!context.get())
134 return false; 134 return false;
135 135
136 bool initialized; 136 bool initialized;
137 { 137 {
138 DebugScopedSetMainThreadBlocked mainThreadBlocked; 138 DebugScopedSetMainThreadBlocked mainThreadBlocked;
139 DebugScopedSetImplThread impl; 139 DebugScopedSetImplThread impl;
140 if (!m_layerTreeHostImpl->contentsTexturesPurged()) 140 if (!m_layerTreeHostImpl->contentsTexturesPurged())
(...skipping 12 matching lines...) Expand all
153 153
154 void CCSingleThreadProxy::renderingStats(CCRenderingStats* stats) 154 void CCSingleThreadProxy::renderingStats(CCRenderingStats* stats)
155 { 155 {
156 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 156 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
157 stats->totalCommitCount = m_totalCommitCount; 157 stats->totalCommitCount = m_totalCommitCount;
158 m_layerTreeHostImpl->renderingStats(stats); 158 m_layerTreeHostImpl->renderingStats(stats);
159 } 159 }
160 160
161 const RendererCapabilities& CCSingleThreadProxy::rendererCapabilities() const 161 const RendererCapabilities& CCSingleThreadProxy::rendererCapabilities() const
162 { 162 {
163 ASSERT(m_rendererInitialized); 163 DCHECK(m_rendererInitialized);
164 // Note: this gets called during the commit by the "impl" thread 164 // Note: this gets called during the commit by the "impl" thread
165 return m_RendererCapabilitiesForMainThread; 165 return m_RendererCapabilitiesForMainThread;
166 } 166 }
167 167
168 void CCSingleThreadProxy::loseContext() 168 void CCSingleThreadProxy::loseContext()
169 { 169 {
170 ASSERT(CCProxy::isMainThread()); 170 DCHECK(CCProxy::isMainThread());
171 m_layerTreeHost->didLoseContext(); 171 m_layerTreeHost->didLoseContext();
172 m_contextLost = true; 172 m_contextLost = true;
173 } 173 }
174 174
175 void CCSingleThreadProxy::setNeedsAnimate() 175 void CCSingleThreadProxy::setNeedsAnimate()
176 { 176 {
177 // CCThread-only feature 177 // CCThread-only feature
178 ASSERT_NOT_REACHED(); 178 NOTREACHED();
179 } 179 }
180 180
181 void CCSingleThreadProxy::doCommit(PassOwnPtr<CCTextureUpdateQueue> queue) 181 void CCSingleThreadProxy::doCommit(PassOwnPtr<CCTextureUpdateQueue> queue)
182 { 182 {
183 ASSERT(CCProxy::isMainThread()); 183 DCHECK(CCProxy::isMainThread());
184 // Commit immediately 184 // Commit immediately
185 { 185 {
186 DebugScopedSetMainThreadBlocked mainThreadBlocked; 186 DebugScopedSetMainThreadBlocked mainThreadBlocked;
187 DebugScopedSetImplThread impl; 187 DebugScopedSetImplThread impl;
188 188
189 base::TimeTicks startTime = base::TimeTicks::HighResNow(); 189 base::TimeTicks startTime = base::TimeTicks::HighResNow();
190 m_layerTreeHostImpl->beginCommit(); 190 m_layerTreeHostImpl->beginCommit();
191 191
192 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); 192 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
193 193
194 OwnPtr<CCTextureUpdateController> updateController = 194 OwnPtr<CCTextureUpdateController> updateController =
195 CCTextureUpdateController::create( 195 CCTextureUpdateController::create(
196 NULL, 196 NULL,
197 CCProxy::mainThread(), 197 CCProxy::mainThread(),
198 queue, 198 queue,
199 m_layerTreeHostImpl->resourceProvider(), 199 m_layerTreeHostImpl->resourceProvider(),
200 m_layerTreeHostImpl->resourceProvider()->textureUploader()); 200 m_layerTreeHostImpl->resourceProvider()->textureUploader());
201 updateController->finalize(); 201 updateController->finalize();
202 202
203 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); 203 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
204 204
205 m_layerTreeHostImpl->commitComplete(); 205 m_layerTreeHostImpl->commitComplete();
206 206
207 #if !ASSERT_DISABLED 207 if (DCHECK_IS_ON()) {
208 // In the single-threaded case, the scroll deltas should never be 208 // In the single-threaded case, the scroll deltas should never be
209 // touched on the impl layer tree. 209 // touched on the impl layer tree.
210 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->proces sScrollDeltas(); 210 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->pr ocessScrollDeltas();
211 ASSERT(!scrollInfo->scrolls.size()); 211 DCHECK(!scrollInfo->scrolls.size());
212 #endif 212 }
213 213
214 base::TimeTicks endTime = base::TimeTicks::HighResNow(); 214 base::TimeTicks endTime = base::TimeTicks::HighResNow();
215 m_totalCommitTime += endTime - startTime; 215 m_totalCommitTime += endTime - startTime;
216 m_totalCommitCount++; 216 m_totalCommitCount++;
217 } 217 }
218 m_layerTreeHost->commitComplete(); 218 m_layerTreeHost->commitComplete();
219 m_nextFrameIsNewlyCommittedFrame = true; 219 m_nextFrameIsNewlyCommittedFrame = true;
220 } 220 }
221 221
222 void CCSingleThreadProxy::setNeedsCommit() 222 void CCSingleThreadProxy::setNeedsCommit()
223 { 223 {
224 ASSERT(CCProxy::isMainThread()); 224 DCHECK(CCProxy::isMainThread());
225 m_layerTreeHost->scheduleComposite(); 225 m_layerTreeHost->scheduleComposite();
226 } 226 }
227 227
228 void CCSingleThreadProxy::setNeedsRedraw() 228 void CCSingleThreadProxy::setNeedsRedraw()
229 { 229 {
230 // FIXME: Once we move render_widget scheduling into this class, we can 230 // FIXME: Once we move render_widget scheduling into this class, we can
231 // treat redraw requests more efficiently than commitAndRedraw requests. 231 // treat redraw requests more efficiently than commitAndRedraw requests.
232 m_layerTreeHostImpl->setFullRootLayerDamage(); 232 m_layerTreeHostImpl->setFullRootLayerDamage();
233 setNeedsCommit(); 233 setNeedsCommit();
234 } 234 }
235 235
236 bool CCSingleThreadProxy::commitRequested() const 236 bool CCSingleThreadProxy::commitRequested() const
237 { 237 {
238 return false; 238 return false;
239 } 239 }
240 240
241 void CCSingleThreadProxy::didAddAnimation() 241 void CCSingleThreadProxy::didAddAnimation()
242 { 242 {
243 } 243 }
244 244
245 size_t CCSingleThreadProxy::maxPartialTextureUpdates() const 245 size_t CCSingleThreadProxy::maxPartialTextureUpdates() const
246 { 246 {
247 return std::numeric_limits<size_t>::max(); 247 return std::numeric_limits<size_t>::max();
248 } 248 }
249 249
250 void CCSingleThreadProxy::stop() 250 void CCSingleThreadProxy::stop()
251 { 251 {
252 TRACE_EVENT0("cc", "CCSingleThreadProxy::stop"); 252 TRACE_EVENT0("cc", "CCSingleThreadProxy::stop");
253 ASSERT(CCProxy::isMainThread()); 253 DCHECK(CCProxy::isMainThread());
254 { 254 {
255 DebugScopedSetMainThreadBlocked mainThreadBlocked; 255 DebugScopedSetMainThreadBlocked mainThreadBlocked;
256 DebugScopedSetImplThread impl; 256 DebugScopedSetImplThread impl;
257 257
258 if (!m_layerTreeHostImpl->contentsTexturesPurged()) 258 if (!m_layerTreeHostImpl->contentsTexturesPurged())
259 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostI mpl->resourceProvider()); 259 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostI mpl->resourceProvider());
260 m_layerTreeHostImpl.reset(); 260 m_layerTreeHostImpl.reset();
261 } 261 }
262 m_layerTreeHost = 0; 262 m_layerTreeHost = 0;
263 } 263 }
264 264
265 void CCSingleThreadProxy::setNeedsRedrawOnImplThread() 265 void CCSingleThreadProxy::setNeedsRedrawOnImplThread()
266 { 266 {
267 m_layerTreeHost->scheduleComposite(); 267 m_layerTreeHost->scheduleComposite();
268 } 268 }
269 269
270 void CCSingleThreadProxy::setNeedsCommitOnImplThread() 270 void CCSingleThreadProxy::setNeedsCommitOnImplThread()
271 { 271 {
272 m_layerTreeHost->scheduleComposite(); 272 m_layerTreeHost->scheduleComposite();
273 } 273 }
274 274
275 void CCSingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr <CCAnimationEventsVector> events, double wallClockTime) 275 void CCSingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr <CCAnimationEventsVector> events, double wallClockTime)
276 { 276 {
277 ASSERT(CCProxy::isImplThread()); 277 DCHECK(CCProxy::isImplThread());
278 DebugScopedSetMainThread main; 278 DebugScopedSetMainThread main;
279 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); 279 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
280 } 280 }
281 281
282 void CCSingleThreadProxy::releaseContentsTexturesOnImplThread() 282 void CCSingleThreadProxy::releaseContentsTexturesOnImplThread()
283 { 283 {
284 ASSERT(isImplThread()); 284 DCHECK(isImplThread());
285 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost Impl->resourceProvider()); 285 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost Impl->resourceProvider());
286 } 286 }
287 287
288 // Called by the legacy scheduling path (e.g. where render_widget does the sched uling) 288 // Called by the legacy scheduling path (e.g. where render_widget does the sched uling)
289 void CCSingleThreadProxy::compositeImmediately() 289 void CCSingleThreadProxy::compositeImmediately()
290 { 290 {
291 if (commitAndComposite()) { 291 if (commitAndComposite()) {
292 m_layerTreeHostImpl->swapBuffers(); 292 m_layerTreeHostImpl->swapBuffers();
293 didSwapFrame(); 293 didSwapFrame();
294 } 294 }
295 } 295 }
296 296
297 void CCSingleThreadProxy::forceSerializeOnSwapBuffers() 297 void CCSingleThreadProxy::forceSerializeOnSwapBuffers()
298 { 298 {
299 { 299 {
300 DebugScopedSetImplThread impl; 300 DebugScopedSetImplThread impl;
301 if (m_rendererInitialized) 301 if (m_rendererInitialized)
302 m_layerTreeHostImpl->renderer()->doNoOp(); 302 m_layerTreeHostImpl->renderer()->doNoOp();
303 } 303 }
304 } 304 }
305 305
306 void CCSingleThreadProxy::onSwapBuffersCompleteOnImplThread() 306 void CCSingleThreadProxy::onSwapBuffersCompleteOnImplThread()
307 { 307 {
308 ASSERT_NOT_REACHED(); 308 NOTREACHED();
309 } 309 }
310 310
311 bool CCSingleThreadProxy::commitAndComposite() 311 bool CCSingleThreadProxy::commitAndComposite()
312 { 312 {
313 ASSERT(CCProxy::isMainThread()); 313 DCHECK(CCProxy::isMainThread());
314 314
315 if (!m_layerTreeHost->initializeRendererIfNeeded()) 315 if (!m_layerTreeHost->initializeRendererIfNeeded())
316 return false; 316 return false;
317 317
318 // Unlink any texture backings that were deleted 318 // Unlink any texture backings that were deleted
319 CCPrioritizedTextureManager::BackingVector evictedContentsTexturesBackings; 319 CCPrioritizedTextureManager::BackingVector evictedContentsTexturesBackings;
320 { 320 {
321 DebugScopedSetImplThread implThread; 321 DebugScopedSetImplThread implThread;
322 m_layerTreeHost->getEvictedContentTexturesBackings(evictedContentsTextur esBackings); 322 m_layerTreeHost->getEvictedContentTexturesBackings(evictedContentsTextur esBackings);
323 } 323 }
(...skipping 11 matching lines...) Expand all
335 335
336 m_layerTreeHost->willCommit(); 336 m_layerTreeHost->willCommit();
337 doCommit(queue.release()); 337 doCommit(queue.release());
338 bool result = doComposite(); 338 bool result = doComposite();
339 m_layerTreeHost->didBeginFrame(); 339 m_layerTreeHost->didBeginFrame();
340 return result; 340 return result;
341 } 341 }
342 342
343 bool CCSingleThreadProxy::doComposite() 343 bool CCSingleThreadProxy::doComposite()
344 { 344 {
345 ASSERT(!m_contextLost); 345 DCHECK(!m_contextLost);
346 { 346 {
347 DebugScopedSetImplThread impl; 347 DebugScopedSetImplThread impl;
348 348
349 if (!m_layerTreeHostImpl->visible()) 349 if (!m_layerTreeHostImpl->visible())
350 return false; 350 return false;
351 351
352 double monotonicTime = monotonicallyIncreasingTime(); 352 double monotonicTime = monotonicallyIncreasingTime();
353 double wallClockTime = currentTime(); 353 double wallClockTime = currentTime();
354 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); 354 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
355 355
(...skipping 20 matching lines...) Expand all
376 376
377 void CCSingleThreadProxy::didSwapFrame() 377 void CCSingleThreadProxy::didSwapFrame()
378 { 378 {
379 if (m_nextFrameIsNewlyCommittedFrame) { 379 if (m_nextFrameIsNewlyCommittedFrame) {
380 m_nextFrameIsNewlyCommittedFrame = false; 380 m_nextFrameIsNewlyCommittedFrame = false;
381 m_layerTreeHost->didCommitAndDrawFrame(); 381 m_layerTreeHost->didCommitAndDrawFrame();
382 } 382 }
383 } 383 }
384 384
385 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698