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

Side by Side Diff: cc/single_thread_proxy.cc

Issue 11439026: Revert 171403 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/software_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/single_thread_proxy.h" 5 #include "cc/single_thread_proxy.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/draw_quad.h" 8 #include "cc/draw_quad.h"
9 #include "cc/graphics_context.h"
9 #include "cc/layer_tree_host.h" 10 #include "cc/layer_tree_host.h"
10 #include "cc/output_surface.h"
11 #include "cc/resource_update_controller.h" 11 #include "cc/resource_update_controller.h"
12 #include "cc/thread.h" 12 #include "cc/thread.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) 16 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost)
17 { 17 {
18 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>() ; 18 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>() ;
19 } 19 }
20 20
21 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) 21 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost)
22 : Proxy(scoped_ptr<Thread>(NULL)) 22 : Proxy(scoped_ptr<Thread>(NULL))
23 , m_layerTreeHost(layerTreeHost) 23 , m_layerTreeHost(layerTreeHost)
24 , m_outputSurfaceLost(false) 24 , m_contextLost(false)
25 , m_rendererInitialized(false) 25 , m_rendererInitialized(false)
26 , m_nextFrameIsNewlyCommittedFrame(false) 26 , m_nextFrameIsNewlyCommittedFrame(false)
27 , m_totalCommitCount(0) 27 , m_totalCommitCount(0)
28 { 28 {
29 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 29 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
30 DCHECK(Proxy::isMainThread()); 30 DCHECK(Proxy::isMainThread());
31 } 31 }
32 32
33 void SingleThreadProxy::start() 33 void SingleThreadProxy::start()
34 { 34 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 m_layerTreeHostImpl->finishAllRendering(); 75 m_layerTreeHostImpl->finishAllRendering();
76 } 76 }
77 } 77 }
78 78
79 bool SingleThreadProxy::isStarted() const 79 bool SingleThreadProxy::isStarted() const
80 { 80 {
81 DCHECK(Proxy::isMainThread()); 81 DCHECK(Proxy::isMainThread());
82 return m_layerTreeHostImpl.get(); 82 return m_layerTreeHostImpl.get();
83 } 83 }
84 84
85 bool SingleThreadProxy::initializeOutputSurface() 85 bool SingleThreadProxy::initializeContext()
86 { 86 {
87 DCHECK(Proxy::isMainThread()); 87 DCHECK(Proxy::isMainThread());
88 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce(); 88 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext();
89 if (!outputSurface.get()) 89 if (!context.get())
90 return false; 90 return false;
91 m_outputSurfaceBeforeInitialization = outputSurface.Pass(); 91 m_contextBeforeInitialization = context.Pass();
92 return true; 92 return true;
93 } 93 }
94 94
95 void SingleThreadProxy::setSurfaceReady() 95 void SingleThreadProxy::setSurfaceReady()
96 { 96 {
97 // Scheduling is controlled by the embedder in the single thread case, so no thing to do. 97 // Scheduling is controlled by the embedder in the single thread case, so no thing to do.
98 } 98 }
99 99
100 void SingleThreadProxy::setVisible(bool visible) 100 void SingleThreadProxy::setVisible(bool visible)
101 { 101 {
102 DebugScopedSetImplThread impl(this); 102 DebugScopedSetImplThread impl(this);
103 m_layerTreeHostImpl->setVisible(visible); 103 m_layerTreeHostImpl->setVisible(visible);
104 } 104 }
105 105
106 bool SingleThreadProxy::initializeRenderer() 106 bool SingleThreadProxy::initializeRenderer()
107 { 107 {
108 DCHECK(Proxy::isMainThread()); 108 DCHECK(Proxy::isMainThread());
109 DCHECK(m_outputSurfaceBeforeInitialization.get()); 109 DCHECK(m_contextBeforeInitialization.get());
110 { 110 {
111 DebugScopedSetImplThread impl(this); 111 DebugScopedSetImplThread impl(this);
112 bool ok = m_layerTreeHostImpl->initializeRenderer(m_outputSurfaceBeforeI nitialization.Pass()); 112 bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitial ization.Pass());
113 if (ok) { 113 if (ok) {
114 m_rendererInitialized = true; 114 m_rendererInitialized = true;
115 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); 115 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities();
116 } 116 }
117 117
118 return ok; 118 return ok;
119 } 119 }
120 } 120 }
121 121
122 bool SingleThreadProxy::recreateOutputSurface() 122 bool SingleThreadProxy::recreateContext()
123 { 123 {
124 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); 124 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext");
125 DCHECK(Proxy::isMainThread()); 125 DCHECK(Proxy::isMainThread());
126 DCHECK(m_outputSurfaceLost); 126 DCHECK(m_contextLost);
127 127
128 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce(); 128 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext();
129 if (!outputSurface.get()) 129 if (!context.get())
130 return false; 130 return false;
131 131
132 bool initialized; 132 bool initialized;
133 { 133 {
134 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 134 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
135 DebugScopedSetImplThread impl(this); 135 DebugScopedSetImplThread impl(this);
136 if (!m_layerTreeHostImpl->contentsTexturesPurged()) 136 if (!m_layerTreeHostImpl->contentsTexturesPurged())
137 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostI mpl->resourceProvider()); 137 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostI mpl->resourceProvider());
138 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); 138 initialized = m_layerTreeHostImpl->initializeRenderer(context.Pass());
139 if (initialized) { 139 if (initialized) {
140 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); 140 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities();
141 } 141 }
142 } 142 }
143 143
144 if (initialized) 144 if (initialized)
145 m_outputSurfaceLost = false; 145 m_contextLost = false;
146 146
147 return initialized; 147 return initialized;
148 } 148 }
149 149
150 void SingleThreadProxy::renderingStats(RenderingStats* stats) 150 void SingleThreadProxy::renderingStats(RenderingStats* stats)
151 { 151 {
152 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 152 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
153 stats->totalCommitCount = m_totalCommitCount; 153 stats->totalCommitCount = m_totalCommitCount;
154 m_layerTreeHostImpl->renderingStats(stats); 154 m_layerTreeHostImpl->renderingStats(stats);
155 } 155 }
156 156
157 const RendererCapabilities& SingleThreadProxy::rendererCapabilities() const 157 const RendererCapabilities& SingleThreadProxy::rendererCapabilities() const
158 { 158 {
159 DCHECK(m_rendererInitialized); 159 DCHECK(m_rendererInitialized);
160 // Note: this gets called during the commit by the "impl" thread 160 // Note: this gets called during the commit by the "impl" thread
161 return m_RendererCapabilitiesForMainThread; 161 return m_RendererCapabilitiesForMainThread;
162 } 162 }
163 163
164 void SingleThreadProxy::loseOutputSurface() 164 void SingleThreadProxy::loseContext()
165 { 165 {
166 DCHECK(Proxy::isMainThread()); 166 DCHECK(Proxy::isMainThread());
167 m_layerTreeHost->didLoseOutputSurface(); 167 m_layerTreeHost->didLoseContext();
168 m_outputSurfaceLost = true; 168 m_contextLost = true;
169 } 169 }
170 170
171 void SingleThreadProxy::setNeedsAnimate() 171 void SingleThreadProxy::setNeedsAnimate()
172 { 172 {
173 // Thread-only feature 173 // Thread-only feature
174 NOTREACHED(); 174 NOTREACHED();
175 } 175 }
176 176
177 void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue) 177 void SingleThreadProxy::doCommit(scoped_ptr<ResourceUpdateQueue> queue)
178 { 178 {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 m_layerTreeHost->willCommit(); 353 m_layerTreeHost->willCommit();
354 doCommit(queue.Pass()); 354 doCommit(queue.Pass());
355 bool result = doComposite(); 355 bool result = doComposite();
356 m_layerTreeHost->didBeginFrame(); 356 m_layerTreeHost->didBeginFrame();
357 return result; 357 return result;
358 } 358 }
359 359
360 bool SingleThreadProxy::doComposite() 360 bool SingleThreadProxy::doComposite()
361 { 361 {
362 DCHECK(!m_outputSurfaceLost); 362 DCHECK(!m_contextLost);
363 { 363 {
364 DebugScopedSetImplThread impl(this); 364 DebugScopedSetImplThread impl(this);
365 365
366 if (!m_layerTreeHostImpl->visible()) 366 if (!m_layerTreeHostImpl->visible())
367 return false; 367 return false;
368 368
369 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); 369 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now());
370 370
371 if (m_layerTreeHostImpl->settings().implSidePainting) 371 if (m_layerTreeHostImpl->settings().implSidePainting)
372 m_layerTreeHostImpl->manageTiles(); 372 m_layerTreeHostImpl->manageTiles();
373 373
374 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only 374 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only
375 // be used when such a frame is possible. Since drawLayers() depends on the result of 375 // be used when such a frame is possible. Since drawLayers() depends on the result of
376 // prepareToDraw(), it is guarded on canDraw() as well. 376 // prepareToDraw(), it is guarded on canDraw() as well.
377 if (!m_layerTreeHostImpl->canDraw()) 377 if (!m_layerTreeHostImpl->canDraw())
378 return false; 378 return false;
379 379
380 LayerTreeHostImpl::FrameData frame; 380 LayerTreeHostImpl::FrameData frame;
381 m_layerTreeHostImpl->prepareToDraw(frame); 381 m_layerTreeHostImpl->prepareToDraw(frame);
382 m_layerTreeHostImpl->drawLayers(frame); 382 m_layerTreeHostImpl->drawLayers(frame);
383 m_layerTreeHostImpl->didDrawAllLayers(frame); 383 m_layerTreeHostImpl->didDrawAllLayers(frame);
384 } 384 }
385 385
386 if (m_layerTreeHostImpl->isContextLost()) { 386 if (m_layerTreeHostImpl->isContextLost()) {
387 m_outputSurfaceLost = true; 387 m_contextLost = true;
388 m_layerTreeHost->didLoseOutputSurface(); 388 m_layerTreeHost->didLoseContext();
389 return false; 389 return false;
390 } 390 }
391 391
392 return true; 392 return true;
393 } 393 }
394 394
395 void SingleThreadProxy::didSwapFrame() 395 void SingleThreadProxy::didSwapFrame()
396 { 396 {
397 if (m_nextFrameIsNewlyCommittedFrame) { 397 if (m_nextFrameIsNewlyCommittedFrame) {
398 m_nextFrameIsNewlyCommittedFrame = false; 398 m_nextFrameIsNewlyCommittedFrame = false;
399 m_layerTreeHost->didCommitAndDrawFrame(); 399 m_layerTreeHost->didCommitAndDrawFrame();
400 } 400 }
401 } 401 }
402 402
403 } // namespace cc 403 } // namespace cc
OLDNEW
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698