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

Side by Side Diff: cc/thread_proxy.cc

Issue 11450019: Finish the rename from cc::GraphicsContext to cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
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/thread_proxy.h" 5 #include "cc/thread_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/delay_based_time_source.h" 9 #include "cc/delay_based_time_source.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
11 #include "cc/frame_rate_controller.h" 11 #include "cc/frame_rate_controller.h"
12 #include "cc/graphics_context.h"
13 #include "cc/input_handler.h" 12 #include "cc/input_handler.h"
14 #include "cc/layer_tree_host.h" 13 #include "cc/layer_tree_host.h"
14 #include "cc/output_surface.h"
15 #include "cc/scheduler.h" 15 #include "cc/scheduler.h"
16 #include "cc/scoped_thread_proxy.h" 16 #include "cc/scoped_thread_proxy.h"
17 #include "cc/thread.h" 17 #include "cc/thread.h"
18 #include <public/WebSharedGraphicsContext3D.h> 18 #include <public/WebSharedGraphicsContext3D.h>
19 19
20 using WebKit::WebSharedGraphicsContext3D; 20 using WebKit::WebSharedGraphicsContext3D;
21 21
22 namespace { 22 namespace {
23 23
24 // Measured in seconds. 24 // Measured in seconds.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnI mplThread, base::Unretained(this), &completion)); 140 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnI mplThread, base::Unretained(this), &completion));
141 completion.wait(); 141 completion.wait();
142 } 142 }
143 143
144 bool ThreadProxy::isStarted() const 144 bool ThreadProxy::isStarted() const
145 { 145 {
146 DCHECK(Proxy::isMainThread()); 146 DCHECK(Proxy::isMainThread());
147 return m_started; 147 return m_started;
148 } 148 }
149 149
150 bool ThreadProxy::initializeContext() 150 bool ThreadProxy::initializeOutputSurface()
151 { 151 {
152 TRACE_EVENT0("cc", "ThreadProxy::initializeContext"); 152 TRACE_EVENT0("cc", "ThreadProxy::initializeOutputSurface");
153 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); 153 scoped_ptr<OutputSurface> context = m_layerTreeHost->createOutputSurface();
154 if (!context.get()) 154 if (!context.get())
155 return false; 155 return false;
156 156
157 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeContextOnIm plThread, base::Unretained(this), base::Passed(context.Pass()))); 157 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeOutputSurfa ceOnImplThread, base::Unretained(this), base::Passed(context.Pass())));
158 return true; 158 return true;
159 } 159 }
160 160
161 void ThreadProxy::setSurfaceReady() 161 void ThreadProxy::setSurfaceReady()
162 { 162 {
163 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady"); 163 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReady");
164 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setSurfaceReadyOnImpl Thread, base::Unretained(this))); 164 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setSurfaceReadyOnImpl Thread, base::Unretained(this)));
165 } 165 }
166 166
167 void ThreadProxy::setSurfaceReadyOnImplThread() 167 void ThreadProxy::setSurfaceReadyOnImplThread()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 &capabilities)); 203 &capabilities));
204 completion.wait(); 204 completion.wait();
205 205
206 if (initializeSucceeded) { 206 if (initializeSucceeded) {
207 m_rendererInitialized = true; 207 m_rendererInitialized = true;
208 m_RendererCapabilitiesMainThreadCopy = capabilities; 208 m_RendererCapabilitiesMainThreadCopy = capabilities;
209 } 209 }
210 return initializeSucceeded; 210 return initializeSucceeded;
211 } 211 }
212 212
213 bool ThreadProxy::recreateContext() 213 bool ThreadProxy::recreateOutputSurface()
214 { 214 {
215 TRACE_EVENT0("cc", "ThreadProxy::recreateContext"); 215 TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurface");
216 DCHECK(isMainThread()); 216 DCHECK(isMainThread());
217 217
218 // Try to create the context. 218 // Try to create the surface.
219 scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); 219 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce();
220 if (!context.get()) 220 if (!outputSurface.get())
221 return false; 221 return false;
222 if (m_layerTreeHost->needsSharedContext()) 222 if (m_layerTreeHost->needsSharedContext())
223 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) 223 if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
224 return false; 224 return false;
225 225
226 // Make a blocking call to recreateContextOnImplThread. The results of that 226 // Make a blocking call to recreateOutputSurfaceOnImplThread. The results of that
227 // call are pushed into the recreateSucceeded and capabilities local 227 // call are pushed into the recreateSucceeded and capabilities local
228 // variables. 228 // variables.
229 CompletionEvent completion; 229 CompletionEvent completion;
230 bool recreateSucceeded = false; 230 bool recreateSucceeded = false;
231 RendererCapabilities capabilities; 231 RendererCapabilities capabilities;
232 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 232 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
233 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl Thread, 233 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateOutputSurface OnImplThread,
234 base::Unretained(this), 234 base::Unretained(this),
235 &completion, 235 &completion,
236 base::Passed(context.Pass()), 236 base::Passed(outputSurface.Pass()),
237 &recreateSucceeded, 237 &recreateSucceeded,
238 &capabilities)); 238 &capabilities));
239 completion.wait(); 239 completion.wait();
240 240
241 if (recreateSucceeded) 241 if (recreateSucceeded)
242 m_RendererCapabilitiesMainThreadCopy = capabilities; 242 m_RendererCapabilitiesMainThreadCopy = capabilities;
243 return recreateSucceeded; 243 return recreateSucceeded;
244 } 244 }
245 245
246 void ThreadProxy::renderingStats(RenderingStats* stats) 246 void ThreadProxy::renderingStats(RenderingStats* stats)
247 { 247 {
248 DCHECK(isMainThread()); 248 DCHECK(isMainThread());
249 249
250 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 250 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
251 CompletionEvent completion; 251 CompletionEvent completion;
252 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT hread, 252 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT hread,
253 base::Unretained(this), &completio n, stats)); 253 base::Unretained(this), &completio n, stats));
254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
255 stats->totalCommitCount = m_totalCommitCount; 255 stats->totalCommitCount = m_totalCommitCount;
256 256
257 completion.wait(); 257 completion.wait();
258 } 258 }
259 259
260 const RendererCapabilities& ThreadProxy::rendererCapabilities() const 260 const RendererCapabilities& ThreadProxy::rendererCapabilities() const
261 { 261 {
262 DCHECK(m_rendererInitialized); 262 DCHECK(m_rendererInitialized);
263 return m_RendererCapabilitiesMainThreadCopy; 263 return m_RendererCapabilitiesMainThreadCopy;
264 } 264 }
265 265
266 void ThreadProxy::loseContext() 266 void ThreadProxy::loseOutputSurface()
267 { 267 {
268 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseContextOnImplT hread, base::Unretained(this))); 268 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseOutputSurfaceO nImplThread, base::Unretained(this)));
269 } 269 }
270 270
271 void ThreadProxy::setNeedsAnimate() 271 void ThreadProxy::setNeedsAnimate()
272 { 272 {
273 DCHECK(isMainThread()); 273 DCHECK(isMainThread());
274 if (m_animateRequested) 274 if (m_animateRequested)
275 return; 275 return;
276 276
277 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); 277 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate");
278 m_animateRequested = true; 278 m_animateRequested = true;
(...skipping 11 matching lines...) Expand all
290 return; 290 return;
291 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit"); 291 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit");
292 m_commitRequested = true; 292 m_commitRequested = true;
293 293
294 if (m_commitRequestSentToImplThread) 294 if (m_commitRequestSentToImplThread)
295 return; 295 return;
296 m_commitRequestSentToImplThread = true; 296 m_commitRequestSentToImplThread = true;
297 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, base::Unretained(this))); 297 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, base::Unretained(this)));
298 } 298 }
299 299
300 void ThreadProxy::didLoseContextOnImplThread() 300 void ThreadProxy::didLoseOutputSurfaceOnImplThread()
301 { 301 {
302 DCHECK(isImplThread()); 302 DCHECK(isImplThread());
303 TRACE_EVENT0("cc", "ThreadProxy::didLoseContextOnImplThread"); 303 TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread");
304 m_schedulerOnImplThread->didLoseContext(); 304 m_schedulerOnImplThread->didLoseOutputSurface();
305 } 305 }
306 306
307 void ThreadProxy::onSwapBuffersCompleteOnImplThread() 307 void ThreadProxy::onSwapBuffersCompleteOnImplThread()
308 { 308 {
309 DCHECK(isImplThread()); 309 DCHECK(isImplThread());
310 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); 310 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread");
311 m_schedulerOnImplThread->didSwapBuffersComplete(); 311 m_schedulerOnImplThread->didSwapBuffersComplete();
312 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteS wapBuffers, base::Unretained(this))); 312 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::didCompleteS wapBuffers, base::Unretained(this)));
313 } 313 }
314 314
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 DCHECK(isMainThread()); 862 DCHECK(isMainThread());
863 if (!m_layerTreeHost) 863 if (!m_layerTreeHost)
864 return; 864 return;
865 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); 865 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
866 } 866 }
867 867
868 void ThreadProxy::beginContextRecreation() 868 void ThreadProxy::beginContextRecreation()
869 { 869 {
870 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); 870 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation");
871 DCHECK(isMainThread()); 871 DCHECK(isMainThread());
872 m_layerTreeHost->didLoseContext(); 872 m_layerTreeHost->didLoseOutputSurface();
873 m_contextRecreationCallback.Reset(base::Bind(&ThreadProxy::tryToRecreateCont ext, base::Unretained(this))); 873 m_outputSurfaceRecreationCallback.Reset(base::Bind(&ThreadProxy::tryToRecrea teOutputSurface, base::Unretained(this)));
874 Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); 874 Proxy::mainThread()->postTask(m_outputSurfaceRecreationCallback.callback());
875 } 875 }
876 876
877 void ThreadProxy::tryToRecreateContext() 877 void ThreadProxy::tryToRecreateOutputSurface()
878 { 878 {
879 DCHECK(isMainThread()); 879 DCHECK(isMainThread());
880 DCHECK(m_layerTreeHost); 880 DCHECK(m_layerTreeHost);
881 LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); 881 LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateOutputSurfac e();
882 if (result == LayerTreeHost::RecreateFailedButTryAgain) 882 if (result == LayerTreeHost::RecreateFailedButTryAgain)
883 Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); 883 Proxy::mainThread()->postTask(m_outputSurfaceRecreationCallback.callback ());
884 else if (result == LayerTreeHost::RecreateSucceeded) 884 else if (result == LayerTreeHost::RecreateSucceeded)
885 m_contextRecreationCallback.Cancel(); 885 m_outputSurfaceRecreationCallback.Cancel();
886 } 886 }
887 887
888 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH andler* handler) 888 void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH andler* handler)
889 { 889 {
890 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread"); 890 TRACE_EVENT0("cc", "ThreadProxy::initializeImplOnImplThread");
891 DCHECK(isImplThread()); 891 DCHECK(isImplThread());
892 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); 892 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
893 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec onds(base::Time::kMicrosecondsPerSecond / 60); 893 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec onds(base::Time::kMicrosecondsPerSecond / 60);
894 scoped_ptr<FrameRateController> frameRateController; 894 scoped_ptr<FrameRateController> frameRateController;
895 if (m_renderVSyncEnabled) 895 if (m_renderVSyncEnabled)
896 frameRateController.reset(new FrameRateController(DelayBasedTimeSource:: create(displayRefreshInterval, Proxy::implThread()))); 896 frameRateController.reset(new FrameRateController(DelayBasedTimeSource:: create(displayRefreshInterval, Proxy::implThread())));
897 else 897 else
898 frameRateController.reset(new FrameRateController(Proxy::implThread())); 898 frameRateController.reset(new FrameRateController(Proxy::implThread()));
899 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass() ); 899 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass() );
900 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 900 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
901 901
902 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); 902 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler);
903 if (m_inputHandlerOnImplThread.get()) 903 if (m_inputHandlerOnImplThread.get())
904 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); 904 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get());
905 905
906 completion->signal(); 906 completion->signal();
907 } 907 }
908 908
909 void ThreadProxy::initializeContextOnImplThread(scoped_ptr<GraphicsContext> cont ext) 909 void ThreadProxy::initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface> outputSurface)
910 { 910 {
911 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); 911 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread");
912 DCHECK(isImplThread()); 912 DCHECK(isImplThread());
913 m_contextBeforeInitializationOnImplThread = context.Pass(); 913 m_outputSurfaceBeforeInitializationOnImplThread = outputSurface.Pass();
914 } 914 }
915 915
916 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo ol* initializeSucceeded, RendererCapabilities* capabilities) 916 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo ol* initializeSucceeded, RendererCapabilities* capabilities)
917 { 917 {
918 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); 918 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread");
919 DCHECK(isImplThread()); 919 DCHECK(isImplThread());
920 DCHECK(m_contextBeforeInitializationOnImplThread.get()); 920 DCHECK(m_outputSurfaceBeforeInitializationOnImplThread.get());
921 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo reInitializationOnImplThread.Pass()); 921 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_outputSurfa ceBeforeInitializationOnImplThread.Pass());
922 if (*initializeSucceeded) { 922 if (*initializeSucceeded) {
923 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 923 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
924 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( 924 m_schedulerOnImplThread->setSwapBuffersCompleteSupported(
925 capabilities->usingSwapCompleteCallback); 925 capabilities->usingSwapCompleteCallback);
926 } 926 }
927 927
928 completion->signal(); 928 completion->signal();
929 } 929 }
930 930
931 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) 931 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion)
(...skipping 11 matching lines...) Expand all
943 { 943 {
944 DCHECK(isImplThread()); 944 DCHECK(isImplThread());
945 m_layerTreeHostImpl->setFullRootLayerDamage(); 945 m_layerTreeHostImpl->setFullRootLayerDamage();
946 } 946 }
947 947
948 size_t ThreadProxy::maxPartialTextureUpdates() const 948 size_t ThreadProxy::maxPartialTextureUpdates() const
949 { 949 {
950 return ResourceUpdateController::maxPartialTextureUpdates(); 950 return ResourceUpdateController::maxPartialTextureUpdates();
951 } 951 }
952 952
953 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, scope d_ptr<GraphicsContext> context, bool* recreateSucceeded, RendererCapabilities* c apabilities) 953 void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, bool* recreateSucceeded, RendererCapab ilities* capabilities)
954 { 954 {
955 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); 955 TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurfaceOnImplThread");
956 DCHECK(isImplThread()); 956 DCHECK(isImplThread());
957 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider()); 957 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider());
958 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(context.Pass()) ; 958 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(outputSurface.P ass());
959 if (*recreateSucceeded) { 959 if (*recreateSucceeded) {
960 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 960 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
961 m_schedulerOnImplThread->didRecreateContext(); 961 m_schedulerOnImplThread->didRecreateOutputSurface();
962 } 962 }
963 completion->signal(); 963 completion->signal();
964 } 964 }
965 965
966 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats) 966 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats)
967 { 967 {
968 DCHECK(isImplThread()); 968 DCHECK(isImplThread());
969 m_layerTreeHostImpl->renderingStats(stats); 969 m_layerTreeHostImpl->renderingStats(stats);
970 completion->signal(); 970 completion->signal();
971 } 971 }
972 972
973 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 973 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
974 : memoryAllocationLimitBytes(0) 974 : memoryAllocationLimitBytes(0)
975 { 975 {
976 } 976 }
977 977
978 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 978 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
979 { 979 {
980 } 980 }
981 981
982 } // namespace cc 982 } // namespace cc
OLDNEW
« cc/layer_tree_host.cc ('K') | « cc/thread_proxy.h ('k') | cc/tiled_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698