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

Side by Side Diff: cc/single_thread_proxy.cc

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restart with GrContext owned in cc Created 7 years, 10 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 | 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/single_thread_proxy.h" 5 #include "cc/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/draw_quad.h" 9 #include "cc/draw_quad.h"
10 #include "cc/layer_tree_host.h" 10 #include "cc/layer_tree_host.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 bool SingleThreadProxy::recreateOutputSurface() 133 bool SingleThreadProxy::recreateOutputSurface()
134 { 134 {
135 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); 135 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext");
136 DCHECK(Proxy::isMainThread()); 136 DCHECK(Proxy::isMainThread());
137 DCHECK(m_outputSurfaceLost); 137 DCHECK(m_outputSurfaceLost);
138 138
139 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce(); 139 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce();
140 if (!outputSurface.get()) 140 if (!outputSurface.get())
141 return false; 141 return false;
142 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL;
143 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr eeHost->needsOffscreenContext()) {
144 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai nThread();
145 if (!offscreenContext3d)
146 return false;
147 }
142 148
143 bool initialized; 149 bool initialized;
144 { 150 {
145 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 151 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
146 DebugScopedSetImplThread impl(this); 152 DebugScopedSetImplThread impl(this);
147 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider()); 153 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider());
148 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); 154 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ());
149 if (initialized) { 155 if (initialized) {
150 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); 156 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities();
157 m_layerTreeHostImpl->resourceProvider()->setContext3dForGrContext(of fscreenContext3d);
151 } 158 }
152 } 159 }
153 160
154 if (initialized) 161 if (initialized)
155 m_outputSurfaceLost = false; 162 m_outputSurfaceLost = false;
156 163
157 return initialized; 164 return initialized;
158 } 165 }
159 166
160 void SingleThreadProxy::renderingStats(RenderingStats* stats) 167 void SingleThreadProxy::renderingStats(RenderingStats* stats)
(...skipping 28 matching lines...) Expand all
189 m_layerTreeHostImpl->beginCommit(); 196 m_layerTreeHostImpl->beginCommit();
190 197
191 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin gs(); 198 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin gs();
192 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); 199 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
193 200
194 scoped_ptr<ResourceUpdateController> updateController = 201 scoped_ptr<ResourceUpdateController> updateController =
195 ResourceUpdateController::create( 202 ResourceUpdateController::create(
196 NULL, 203 NULL,
197 Proxy::mainThread(), 204 Proxy::mainThread(),
198 queue.Pass(), 205 queue.Pass(),
199 m_layerTreeHostImpl->resourceProvider(), 206 m_layerTreeHostImpl->resourceProvider());
200 hasImplThread());
201 updateController->finalize(); 207 updateController->finalize();
202 208
203 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); 209 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
204 210
205 m_layerTreeHostImpl->commitComplete(); 211 m_layerTreeHostImpl->commitComplete();
206 212
207 #ifndef NDEBUG 213 #ifndef NDEBUG
208 // In the single-threaded case, the scroll deltas should never be 214 // In the single-threaded case, the scroll deltas should never be
209 // touched on the impl layer tree. 215 // touched on the impl layer tree.
210 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS crollDeltas(); 216 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS crollDeltas();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 NOTREACHED(); 367 NOTREACHED();
362 } 368 }
363 369
364 bool SingleThreadProxy::commitAndComposite() 370 bool SingleThreadProxy::commitAndComposite()
365 { 371 {
366 DCHECK(Proxy::isMainThread()); 372 DCHECK(Proxy::isMainThread());
367 373
368 if (!m_layerTreeHost->initializeRendererIfNeeded()) 374 if (!m_layerTreeHost->initializeRendererIfNeeded())
369 return false; 375 return false;
370 376
377 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL;
378 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr eeHost->needsOffscreenContext()) {
379 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai nThread();
380 }
381
371 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); 382 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings();
372 383
373 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); 384 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue);
374 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes()); 385 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes());
375 386
376 m_layerTreeHost->willCommit(); 387 m_layerTreeHost->willCommit();
377 doCommit(queue.Pass()); 388 doCommit(queue.Pass());
378 bool result = doComposite(); 389 bool result = doComposite(offscreenContext3d);
379 m_layerTreeHost->didBeginFrame(); 390 m_layerTreeHost->didBeginFrame();
380 return result; 391 return result;
381 } 392 }
382 393
383 bool SingleThreadProxy::doComposite() 394 bool SingleThreadProxy::doComposite(WebKit::WebGraphicsContext3D* offscreenC ontext3d)
384 { 395 {
385 DCHECK(!m_outputSurfaceLost); 396 DCHECK(!m_outputSurfaceLost);
386 { 397 {
387 DebugScopedSetImplThread impl(this); 398 DebugScopedSetImplThread impl(this);
388 base::AutoReset<bool> markInside(&m_insideDraw, true); 399 base::AutoReset<bool> markInside(&m_insideDraw, true);
389 400
401 m_layerTreeHostImpl->resourceProvider()->setContext3dForGrContext(offscr eenContext3d);
402
390 if (!m_layerTreeHostImpl->visible()) 403 if (!m_layerTreeHostImpl->visible())
391 return false; 404 return false;
392 405
393 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); 406 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now());
394 407
395 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only 408 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only
396 // be used when such a frame is possible. Since drawLayers() depends on the result of 409 // be used when such a frame is possible. Since drawLayers() depends on the result of
397 // prepareToDraw(), it is guarded on canDraw() as well. 410 // prepareToDraw(), it is guarded on canDraw() as well.
398 if (!m_layerTreeHostImpl->canDraw()) 411 if (!m_layerTreeHostImpl->canDraw())
399 return false; 412 return false;
(...skipping 29 matching lines...) Expand all
429 } 442 }
430 443
431 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() 444 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture()
432 { 445 {
433 // Requires impl-side painting, which is only supported in threaded composit ing. 446 // Requires impl-side painting, which is only supported in threaded composit ing.
434 NOTREACHED(); 447 NOTREACHED();
435 return skia::RefPtr<SkPicture>(); 448 return skia::RefPtr<SkPicture>();
436 } 449 }
437 450
438 } // namespace cc 451 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698