cc: Chromify SingleThreadProxy and FakeProxies
[email protected]
Review URL: https://chromiumcodereview.appspot.com/12516007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187405 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h
index e954b852..6b948f4 100644
--- a/cc/single_thread_proxy.h
+++ b/cc/single_thread_proxy.h
@@ -18,148 +18,160 @@
class LayerTreeHost;
class SingleThreadProxy : public Proxy, LayerTreeHostImplClient {
-public:
- static scoped_ptr<Proxy> create(LayerTreeHost*);
- virtual ~SingleThreadProxy();
+ public:
+ static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host);
+ virtual ~SingleThreadProxy();
- // Proxy implementation
- virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE;
- virtual void StartPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
- virtual void FinishAllRendering() OVERRIDE;
- virtual bool IsStarted() const OVERRIDE;
- virtual bool InitializeOutputSurface() OVERRIDE;
- virtual void SetSurfaceReady() OVERRIDE;
- virtual void SetVisible(bool) OVERRIDE;
- virtual bool InitializeRenderer() OVERRIDE;
- virtual bool RecreateOutputSurface() OVERRIDE;
- virtual void GetRenderingStats(RenderingStats*) OVERRIDE;
- virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
- virtual void SetNeedsAnimate() OVERRIDE;
- virtual void SetNeedsCommit() OVERRIDE;
- virtual void SetNeedsRedraw() OVERRIDE;
- virtual void SetDeferCommits(bool) OVERRIDE;
- virtual bool CommitRequested() const OVERRIDE;
- virtual void MainThreadHasStoppedFlinging() OVERRIDE { }
- virtual void Start() OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
- virtual void AcquireLayerTextures() OVERRIDE { }
- virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
- virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE;
- virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
- virtual bool CommitPendingForTesting() OVERRIDE;
+ // Proxy implementation
+ virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE;
+ virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
+ bool use_anchor,
+ float scale,
+ base::TimeDelta duration) OVERRIDE;
+ virtual void FinishAllRendering() OVERRIDE;
+ virtual bool IsStarted() const OVERRIDE;
+ virtual bool InitializeOutputSurface() OVERRIDE;
+ virtual void SetSurfaceReady() OVERRIDE;
+ virtual void SetVisible(bool visible) OVERRIDE;
+ virtual bool InitializeRenderer() OVERRIDE;
+ virtual bool RecreateOutputSurface() OVERRIDE;
+ virtual void GetRenderingStats(RenderingStats* stats) OVERRIDE;
+ virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
+ virtual void SetNeedsAnimate() OVERRIDE;
+ virtual void SetNeedsCommit() OVERRIDE;
+ virtual void SetNeedsRedraw() OVERRIDE;
+ virtual void SetDeferCommits(bool defer_commits) OVERRIDE;
+ virtual bool CommitRequested() const OVERRIDE;
+ virtual void MainThreadHasStoppedFlinging() OVERRIDE {}
+ virtual void Start() OVERRIDE;
+ virtual void Stop() OVERRIDE;
+ virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
+ virtual void AcquireLayerTextures() OVERRIDE {}
+ virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
+ virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE;
+ virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
+ virtual bool CommitPendingForTesting() OVERRIDE;
- // LayerTreeHostImplClient implementation
- virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE;
- virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE;
- virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE { }
- virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { }
- virtual void onHasPendingTreeStateChanged(bool havePendingTree) OVERRIDE;
- virtual void setNeedsRedrawOnImplThread() OVERRIDE;
- virtual void didUploadVisibleHighResolutionTileOnImplThread() OVERRIDE;
- virtual void setNeedsCommitOnImplThread() OVERRIDE;
- virtual void setNeedsManageTilesOnImplThread() OVERRIDE;
- virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) OVERRIDE;
- virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE;
- virtual void reduceWastedContentsTextureMemoryOnImplThread() OVERRIDE;
- virtual void sendManagedMemoryStats() OVERRIDE;
- virtual bool isInsideDraw() OVERRIDE;
- virtual void renewTreePriority() OVERRIDE { }
+ // LayerTreeHostImplClient implementation
+ virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE;
+ virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE;
+ virtual void onVSyncParametersChanged(base::TimeTicks timebase,
+ base::TimeDelta interval) OVERRIDE {}
+ virtual void onCanDrawStateChanged(bool can_draw) OVERRIDE {}
+ virtual void onHasPendingTreeStateChanged(bool have_pending_tree) OVERRIDE;
+ virtual void setNeedsRedrawOnImplThread() OVERRIDE;
+ virtual void didUploadVisibleHighResolutionTileOnImplThread() OVERRIDE;
+ virtual void setNeedsCommitOnImplThread() OVERRIDE;
+ virtual void setNeedsManageTilesOnImplThread() OVERRIDE;
+ virtual void postAnimationEventsToMainThreadOnImplThread(
+ scoped_ptr<AnimationEventsVector> events,
+ base::Time wall_clock_time) OVERRIDE;
+ virtual bool reduceContentsTextureMemoryOnImplThread(
+ size_t limit_bytes,
+ int priority_cutoff) OVERRIDE;
+ virtual void reduceWastedContentsTextureMemoryOnImplThread() OVERRIDE;
+ virtual void sendManagedMemoryStats() OVERRIDE;
+ virtual bool isInsideDraw() OVERRIDE;
+ virtual void renewTreePriority() OVERRIDE {}
- // Called by the legacy path where RenderWidget does the scheduling.
- void compositeImmediately();
+ // Called by the legacy path where RenderWidget does the scheduling.
+ void CompositeImmediately();
-private:
- explicit SingleThreadProxy(LayerTreeHost*);
+ private:
+ explicit SingleThreadProxy(LayerTreeHost* layer_tree_host);
- bool commitAndComposite();
- void doCommit(scoped_ptr<ResourceUpdateQueue>);
- bool doComposite(scoped_refptr<cc::ContextProvider> offscreenContextProvider);
- void didSwapFrame();
+ bool CommitAndComposite();
+ void DoCommit(scoped_ptr<ResourceUpdateQueue> queue);
+ bool DoComposite(
+ scoped_refptr<cc::ContextProvider> offscreen_context_provider);
+ void DidSwapFrame();
- // Accessed on main thread only.
- LayerTreeHost* m_layerTreeHost;
- bool m_outputSurfaceLost;
- bool m_createdOffscreenContextProvider;
+ // Accessed on main thread only.
+ LayerTreeHost* layer_tree_host_;
+ bool output_surface_lost_;
+ bool created_offscreen_context_provider;
- // Holds on to the context between initializeContext() and InitializeRenderer() calls. Shouldn't
- // be used for anything else.
- scoped_ptr<OutputSurface> m_outputSurfaceBeforeInitialization;
+ // Holds on to the context between initializeContext() and
+ // InitializeRenderer() calls. Shouldn't be used for anything else.
+ scoped_ptr<OutputSurface> output_surface_before_initialization_;
- // Used on the Thread, but checked on main thread during initialization/shutdown.
- scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl;
- bool m_rendererInitialized;
- RendererCapabilities m_RendererCapabilitiesForMainThread;
+ // Used on the Thread, but checked on main thread during
+ // initialization/shutdown.
+ scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
+ bool renderer_initialized_;
+ RendererCapabilities renderer_capabilities_for_main_thread_;
- bool m_nextFrameIsNewlyCommittedFrame;
+ bool next_frame_is_newly_committed_frame_;
- bool m_insideDraw;
+ bool inside_draw_;
- base::TimeDelta m_totalCommitTime;
- size_t m_totalCommitCount;
+ base::TimeDelta total_commit_time_;
+ size_t total_commit_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
};
// For use in the single-threaded case. In debug builds, it pretends that the
// code is running on the impl thread to satisfy assertion checks.
class DebugScopedSetImplThread {
-public:
- explicit DebugScopedSetImplThread(Proxy* proxy)
- : proxy_(proxy)
- {
+ public:
+ explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) {
#ifndef NDEBUG
- m_previousValue = proxy_->impl_thread_is_overridden_;
- proxy_->SetCurrentThreadIsImplThread(true);
+ previous_value_ = proxy_->impl_thread_is_overridden_;
+ proxy_->SetCurrentThreadIsImplThread(true);
#endif
- }
- ~DebugScopedSetImplThread()
- {
+ }
+ ~DebugScopedSetImplThread() {
#ifndef NDEBUG
- proxy_->SetCurrentThreadIsImplThread(m_previousValue);
+ proxy_->SetCurrentThreadIsImplThread(previous_value_);
#endif
- }
-private:
- bool m_previousValue;
- Proxy* proxy_;
+ }
+
+ private:
+ bool previous_value_;
+ Proxy* proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThread);
};
// For use in the single-threaded case. In debug builds, it pretends that the
// code is running on the main thread to satisfy assertion checks.
class DebugScopedSetMainThread {
-public:
- explicit DebugScopedSetMainThread(Proxy* proxy)
- : proxy_(proxy)
- {
+ public:
+ explicit DebugScopedSetMainThread(Proxy* proxy) : proxy_(proxy) {
#ifndef NDEBUG
- m_previousValue = proxy_->impl_thread_is_overridden_;
- proxy_->SetCurrentThreadIsImplThread(false);
+ previous_value_ = proxy_->impl_thread_is_overridden_;
+ proxy_->SetCurrentThreadIsImplThread(false);
#endif
- }
- ~DebugScopedSetMainThread()
- {
+ }
+ ~DebugScopedSetMainThread() {
#ifndef NDEBUG
- proxy_->SetCurrentThreadIsImplThread(m_previousValue);
+ proxy_->SetCurrentThreadIsImplThread(previous_value_);
#endif
- }
-private:
- bool m_previousValue;
- Proxy* proxy_;
+ }
+
+ private:
+ bool previous_value_;
+ Proxy* proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThread);
};
// For use in the single-threaded case. In debug builds, it pretends that the
// code is running on the impl thread and that the main thread is blocked to
// satisfy assertion checks
class DebugScopedSetImplThreadAndMainThreadBlocked {
-public:
- explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy)
- : impl_thread_(proxy)
- , m_mainThreadBlocked(proxy)
- {
- }
-private:
- DebugScopedSetImplThread impl_thread_;
- DebugScopedSetMainThreadBlocked m_mainThreadBlocked;
+ public:
+ explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy)
+ : impl_thread_(proxy), main_thread_blocked_(proxy) {}
+
+ private:
+ DebugScopedSetImplThread impl_thread_;
+ DebugScopedSetMainThreadBlocked main_thread_blocked_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked);
};
-} // namespace cc
+} // namespace cc
#endif // CC_SINGLE_THREAD_PROXY_H_