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

Unified Diff: cc/CCSingleThreadProxy.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCSingleThreadProxy.h ('k') | cc/CCSolidColorDrawQuad.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCSingleThreadProxy.cpp
diff --git a/cc/CCSingleThreadProxy.cpp b/cc/CCSingleThreadProxy.cpp
deleted file mode 100644
index 7f89cf5a75827741f568cb6ba1f4ffe7bd7b82b6..0000000000000000000000000000000000000000
--- a/cc/CCSingleThreadProxy.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-#include "CCSingleThreadProxy.h"
-
-#include "CCDrawQuad.h"
-#include "CCGraphicsContext.h"
-#include "CCLayerTreeHost.h"
-#include "CCTextureUpdateController.h"
-#include "CCTimer.h"
-#include "TraceEvent.h"
-#include <wtf/CurrentTime.h>
-
-using namespace WTF;
-
-namespace cc {
-
-scoped_ptr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost)
-{
- return make_scoped_ptr(new CCSingleThreadProxy(layerTreeHost)).PassAs<CCProxy>();
-}
-
-CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost)
- : m_layerTreeHost(layerTreeHost)
- , m_contextLost(false)
- , m_rendererInitialized(false)
- , m_nextFrameIsNewlyCommittedFrame(false)
- , m_totalCommitCount(0)
-{
- TRACE_EVENT0("cc", "CCSingleThreadProxy::CCSingleThreadProxy");
- ASSERT(CCProxy::isMainThread());
-}
-
-void CCSingleThreadProxy::start()
-{
- DebugScopedSetImplThread impl;
- m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
-}
-
-CCSingleThreadProxy::~CCSingleThreadProxy()
-{
- TRACE_EVENT0("cc", "CCSingleThreadProxy::~CCSingleThreadProxy");
- ASSERT(CCProxy::isMainThread());
- ASSERT(!m_layerTreeHostImpl.get() && !m_layerTreeHost); // make sure stop() got called.
-}
-
-bool CCSingleThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect)
-{
- TRACE_EVENT0("cc", "CCSingleThreadProxy::compositeAndReadback");
- ASSERT(CCProxy::isMainThread());
-
- if (!commitAndComposite())
- return false;
-
- m_layerTreeHostImpl->readback(pixels, rect);
-
- if (m_layerTreeHostImpl->isContextLost())
- return false;
-
- m_layerTreeHostImpl->swapBuffers();
- didSwapFrame();
-
- return true;
-}
-
-void CCSingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration)
-{
- m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration);
-}
-
-void CCSingleThreadProxy::finishAllRendering()
-{
- ASSERT(CCProxy::isMainThread());
- {
- DebugScopedSetImplThread impl;
- m_layerTreeHostImpl->finishAllRendering();
- }
-}
-
-bool CCSingleThreadProxy::isStarted() const
-{
- ASSERT(CCProxy::isMainThread());
- return m_layerTreeHostImpl.get();
-}
-
-bool CCSingleThreadProxy::initializeContext()
-{
- ASSERT(CCProxy::isMainThread());
- scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
- if (!context.get())
- return false;
- m_contextBeforeInitialization = context.Pass();
- return true;
-}
-
-void CCSingleThreadProxy::setSurfaceReady()
-{
- // Scheduling is controlled by the embedder in the single thread case, so nothing to do.
-}
-
-void CCSingleThreadProxy::setVisible(bool visible)
-{
- DebugScopedSetImplThread impl;
- m_layerTreeHostImpl->setVisible(visible);
-}
-
-bool CCSingleThreadProxy::initializeRenderer()
-{
- ASSERT(CCProxy::isMainThread());
- ASSERT(m_contextBeforeInitialization.get());
- {
- DebugScopedSetImplThread impl;
- bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitialization.Pass());
- if (ok) {
- m_rendererInitialized = true;
- m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities();
- }
-
- return ok;
- }
-}
-
-bool CCSingleThreadProxy::recreateContext()
-{
- TRACE_EVENT0("cc", "CCSingleThreadProxy::recreateContext");
- ASSERT(CCProxy::isMainThread());
- ASSERT(m_contextLost);
-
- scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext();
- if (!context.get())
- return false;
-
- bool initialized;
- {
- DebugScopedSetMainThreadBlocked mainThreadBlocked;
- DebugScopedSetImplThread impl;
- if (!m_layerTreeHostImpl->contentsTexturesPurged())
- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
- initialized = m_layerTreeHostImpl->initializeRenderer(context.Pass());
- if (initialized) {
- m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities();
- }
- }
-
- if (initialized)
- m_contextLost = false;
-
- return initialized;
-}
-
-void CCSingleThreadProxy::renderingStats(CCRenderingStats* stats)
-{
- stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
- stats->totalCommitCount = m_totalCommitCount;
- m_layerTreeHostImpl->renderingStats(stats);
-}
-
-const RendererCapabilities& CCSingleThreadProxy::rendererCapabilities() const
-{
- ASSERT(m_rendererInitialized);
- // Note: this gets called during the commit by the "impl" thread
- return m_RendererCapabilitiesForMainThread;
-}
-
-void CCSingleThreadProxy::loseContext()
-{
- ASSERT(CCProxy::isMainThread());
- m_layerTreeHost->didLoseContext();
- m_contextLost = true;
-}
-
-void CCSingleThreadProxy::setNeedsAnimate()
-{
- // CCThread-only feature
- ASSERT_NOT_REACHED();
-}
-
-void CCSingleThreadProxy::doCommit(PassOwnPtr<CCTextureUpdateQueue> queue)
-{
- ASSERT(CCProxy::isMainThread());
- // Commit immediately
- {
- DebugScopedSetMainThreadBlocked mainThreadBlocked;
- DebugScopedSetImplThread impl;
-
- base::TimeTicks startTime = base::TimeTicks::HighResNow();
- m_layerTreeHostImpl->beginCommit();
-
- m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
-
- OwnPtr<CCTextureUpdateController> updateController =
- CCTextureUpdateController::create(
- NULL,
- CCProxy::mainThread(),
- queue,
- m_layerTreeHostImpl->resourceProvider(),
- m_layerTreeHostImpl->resourceProvider()->textureUploader());
- updateController->finalize();
-
- m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
-
- m_layerTreeHostImpl->commitComplete();
-
-#if !ASSERT_DISABLED
- // In the single-threaded case, the scroll deltas should never be
- // touched on the impl layer tree.
- scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processScrollDeltas();
- ASSERT(!scrollInfo->scrolls.size());
-#endif
-
- base::TimeTicks endTime = base::TimeTicks::HighResNow();
- m_totalCommitTime += endTime - startTime;
- m_totalCommitCount++;
- }
- m_layerTreeHost->commitComplete();
- m_nextFrameIsNewlyCommittedFrame = true;
-}
-
-void CCSingleThreadProxy::setNeedsCommit()
-{
- ASSERT(CCProxy::isMainThread());
- m_layerTreeHost->scheduleComposite();
-}
-
-void CCSingleThreadProxy::setNeedsRedraw()
-{
- // FIXME: Once we move render_widget scheduling into this class, we can
- // treat redraw requests more efficiently than commitAndRedraw requests.
- m_layerTreeHostImpl->setFullRootLayerDamage();
- setNeedsCommit();
-}
-
-bool CCSingleThreadProxy::commitRequested() const
-{
- return false;
-}
-
-void CCSingleThreadProxy::didAddAnimation()
-{
-}
-
-size_t CCSingleThreadProxy::maxPartialTextureUpdates() const
-{
- return std::numeric_limits<size_t>::max();
-}
-
-void CCSingleThreadProxy::stop()
-{
- TRACE_EVENT0("cc", "CCSingleThreadProxy::stop");
- ASSERT(CCProxy::isMainThread());
- {
- DebugScopedSetMainThreadBlocked mainThreadBlocked;
- DebugScopedSetImplThread impl;
-
- if (!m_layerTreeHostImpl->contentsTexturesPurged())
- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
- m_layerTreeHostImpl.reset();
- }
- m_layerTreeHost = 0;
-}
-
-void CCSingleThreadProxy::setNeedsRedrawOnImplThread()
-{
- m_layerTreeHost->scheduleComposite();
-}
-
-void CCSingleThreadProxy::setNeedsCommitOnImplThread()
-{
- m_layerTreeHost->scheduleComposite();
-}
-
-void CCSingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimationEventsVector> events, double wallClockTime)
-{
- ASSERT(CCProxy::isImplThread());
- DebugScopedSetMainThread main;
- m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime);
-}
-
-void CCSingleThreadProxy::releaseContentsTexturesOnImplThread()
-{
- ASSERT(isImplThread());
- m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHostImpl->resourceProvider());
-}
-
-// Called by the legacy scheduling path (e.g. where render_widget does the scheduling)
-void CCSingleThreadProxy::compositeImmediately()
-{
- if (commitAndComposite()) {
- m_layerTreeHostImpl->swapBuffers();
- didSwapFrame();
- }
-}
-
-void CCSingleThreadProxy::forceSerializeOnSwapBuffers()
-{
- {
- DebugScopedSetImplThread impl;
- if (m_rendererInitialized)
- m_layerTreeHostImpl->renderer()->doNoOp();
- }
-}
-
-void CCSingleThreadProxy::onSwapBuffersCompleteOnImplThread()
-{
- ASSERT_NOT_REACHED();
-}
-
-bool CCSingleThreadProxy::commitAndComposite()
-{
- ASSERT(CCProxy::isMainThread());
-
- if (!m_layerTreeHost->initializeRendererIfNeeded())
- return false;
-
- // Unlink any texture backings that were deleted
- CCPrioritizedTextureManager::BackingVector evictedContentsTexturesBackings;
- {
- DebugScopedSetImplThread implThread;
- m_layerTreeHost->getEvictedContentTexturesBackings(evictedContentsTexturesBackings);
- }
- m_layerTreeHost->unlinkEvictedContentTexturesBackings(evictedContentsTexturesBackings);
- {
- DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
- m_layerTreeHost->deleteEvictedContentTexturesBackings();
- }
-
- OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
- m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAllocationLimitBytes());
-
- if (m_layerTreeHostImpl->contentsTexturesPurged())
- m_layerTreeHostImpl->resetContentsTexturesPurged();
-
- m_layerTreeHost->willCommit();
- doCommit(queue.release());
- bool result = doComposite();
- m_layerTreeHost->didBeginFrame();
- return result;
-}
-
-bool CCSingleThreadProxy::doComposite()
-{
- ASSERT(!m_contextLost);
- {
- DebugScopedSetImplThread impl;
-
- if (!m_layerTreeHostImpl->visible())
- return false;
-
- double monotonicTime = monotonicallyIncreasingTime();
- double wallClockTime = currentTime();
- m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
-
- // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
- // be used when such a frame is possible. Since drawLayers() depends on the result of
- // prepareToDraw(), it is guarded on canDraw() as well.
- if (!m_layerTreeHostImpl->canDraw())
- return false;
-
- CCLayerTreeHostImpl::FrameData frame;
- m_layerTreeHostImpl->prepareToDraw(frame);
- m_layerTreeHostImpl->drawLayers(frame);
- m_layerTreeHostImpl->didDrawAllLayers(frame);
- }
-
- if (m_layerTreeHostImpl->isContextLost()) {
- m_contextLost = true;
- m_layerTreeHost->didLoseContext();
- return false;
- }
-
- return true;
-}
-
-void CCSingleThreadProxy::didSwapFrame()
-{
- if (m_nextFrameIsNewlyCommittedFrame) {
- m_nextFrameIsNewlyCommittedFrame = false;
- m_layerTreeHost->didCommitAndDrawFrame();
- }
-}
-
-}
« no previous file with comments | « cc/CCSingleThreadProxy.h ('k') | cc/CCSolidColorDrawQuad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698