OLD | NEW |
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 #ifndef CC_SINGLE_THREAD_PROXY_H_ | 5 #ifndef CC_SINGLE_THREAD_PROXY_H_ |
6 #define CC_SINGLE_THREAD_PROXY_H_ | 6 #define CC_SINGLE_THREAD_PROXY_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "cc/animation_events.h" | 11 #include "cc/animation_events.h" |
12 #include "cc/layer_tree_host_impl.h" | 12 #include "cc/layer_tree_host_impl.h" |
13 #include "cc/proxy.h" | 13 #include "cc/proxy.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 class LayerTreeHost; | 17 class LayerTreeHost; |
18 | 18 |
19 class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { | 19 class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { |
20 public: | 20 public: |
21 static scoped_ptr<Proxy> create(LayerTreeHost*); | 21 static scoped_ptr<Proxy> create(LayerTreeHost*); |
22 virtual ~SingleThreadProxy(); | 22 virtual ~SingleThreadProxy(); |
23 | 23 |
24 // Proxy implementation | 24 // Proxy implementation |
25 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; | 25 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; |
26 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta duration) OVERRIDE; | 26 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta duration) OVERRIDE; |
27 virtual void finishAllRendering() OVERRIDE; | 27 virtual void finishAllRendering() OVERRIDE; |
28 virtual bool isStarted() const OVERRIDE; | 28 virtual bool isStarted() const OVERRIDE; |
29 virtual bool initializeOutputSurface() OVERRIDE; | 29 virtual bool initializeContext() OVERRIDE; |
30 virtual void setSurfaceReady() OVERRIDE; | 30 virtual void setSurfaceReady() OVERRIDE; |
31 virtual void setVisible(bool) OVERRIDE; | 31 virtual void setVisible(bool) OVERRIDE; |
32 virtual bool initializeRenderer() OVERRIDE; | 32 virtual bool initializeRenderer() OVERRIDE; |
33 virtual bool recreateOutputSurface() OVERRIDE; | 33 virtual bool recreateContext() OVERRIDE; |
34 virtual void renderingStats(RenderingStats*) OVERRIDE; | 34 virtual void renderingStats(RenderingStats*) OVERRIDE; |
35 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; | 35 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; |
36 virtual void loseOutputSurface() OVERRIDE; | 36 virtual void loseContext() OVERRIDE; |
37 virtual void setNeedsAnimate() OVERRIDE; | 37 virtual void setNeedsAnimate() OVERRIDE; |
38 virtual void setNeedsCommit() OVERRIDE; | 38 virtual void setNeedsCommit() OVERRIDE; |
39 virtual void setNeedsRedraw() OVERRIDE; | 39 virtual void setNeedsRedraw() OVERRIDE; |
40 virtual void setDeferCommits(bool) OVERRIDE; | 40 virtual void setDeferCommits(bool) OVERRIDE; |
41 virtual bool commitRequested() const OVERRIDE; | 41 virtual bool commitRequested() const OVERRIDE; |
42 virtual void didAddAnimation() OVERRIDE; | 42 virtual void didAddAnimation() OVERRIDE; |
43 virtual void start() OVERRIDE; | 43 virtual void start() OVERRIDE; |
44 virtual void stop() OVERRIDE; | 44 virtual void stop() OVERRIDE; |
45 virtual size_t maxPartialTextureUpdates() const OVERRIDE; | 45 virtual size_t maxPartialTextureUpdates() const OVERRIDE; |
46 virtual void acquireLayerTextures() OVERRIDE { } | 46 virtual void acquireLayerTextures() OVERRIDE { } |
47 virtual void forceSerializeOnSwapBuffers() OVERRIDE; | 47 virtual void forceSerializeOnSwapBuffers() OVERRIDE; |
48 | 48 |
49 // LayerTreeHostImplClient implementation | 49 // LayerTreeHostImplClient implementation |
50 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { } | 50 virtual void didLoseContextOnImplThread() OVERRIDE { } |
51 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; | 51 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; |
52 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE { } | 52 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE { } |
53 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { } | 53 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { } |
54 virtual void setNeedsRedrawOnImplThread() OVERRIDE; | 54 virtual void setNeedsRedrawOnImplThread() OVERRIDE; |
55 virtual void setNeedsCommitOnImplThread() OVERRIDE; | 55 virtual void setNeedsCommitOnImplThread() OVERRIDE; |
56 virtual void setNeedsManageTilesOnImplThread() OVERRIDE; | 56 virtual void setNeedsManageTilesOnImplThread() OVERRIDE; |
57 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE; | 57 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE; |
58 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE; | 58 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE; |
59 virtual void sendManagedMemoryStats() OVERRIDE; | 59 virtual void sendManagedMemoryStats() OVERRIDE; |
60 | 60 |
61 // Called by the legacy path where RenderWidget does the scheduling. | 61 // Called by the legacy path where RenderWidget does the scheduling. |
62 void compositeImmediately(); | 62 void compositeImmediately(); |
63 | 63 |
64 private: | 64 private: |
65 explicit SingleThreadProxy(LayerTreeHost*); | 65 explicit SingleThreadProxy(LayerTreeHost*); |
66 | 66 |
67 bool commitAndComposite(); | 67 bool commitAndComposite(); |
68 void doCommit(scoped_ptr<ResourceUpdateQueue>); | 68 void doCommit(scoped_ptr<ResourceUpdateQueue>); |
69 bool doComposite(); | 69 bool doComposite(); |
70 void didSwapFrame(); | 70 void didSwapFrame(); |
71 | 71 |
72 // Accessed on main thread only. | 72 // Accessed on main thread only. |
73 LayerTreeHost* m_layerTreeHost; | 73 LayerTreeHost* m_layerTreeHost; |
74 bool m_outputSurfaceLost; | 74 bool m_contextLost; |
75 | 75 |
76 // Holds on to the context between initializeContext() and initializeRendere
r() calls. Shouldn't | 76 // Holds on to the context between initializeContext() and initializeRendere
r() calls. Shouldn't |
77 // be used for anything else. | 77 // be used for anything else. |
78 scoped_ptr<OutputSurface> m_outputSurfaceBeforeInitialization; | 78 scoped_ptr<GraphicsContext> m_contextBeforeInitialization; |
79 | 79 |
80 // Used on the Thread, but checked on main thread during initialization/shut
down. | 80 // Used on the Thread, but checked on main thread during initialization/shut
down. |
81 scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; | 81 scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; |
82 bool m_rendererInitialized; | 82 bool m_rendererInitialized; |
83 RendererCapabilities m_RendererCapabilitiesForMainThread; | 83 RendererCapabilities m_RendererCapabilitiesForMainThread; |
84 | 84 |
85 bool m_nextFrameIsNewlyCommittedFrame; | 85 bool m_nextFrameIsNewlyCommittedFrame; |
86 | 86 |
87 base::TimeDelta m_totalCommitTime; | 87 base::TimeDelta m_totalCommitTime; |
88 size_t m_totalCommitCount; | 88 size_t m_totalCommitCount; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 { | 145 { |
146 } | 146 } |
147 private: | 147 private: |
148 DebugScopedSetImplThread m_implThread; | 148 DebugScopedSetImplThread m_implThread; |
149 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; | 149 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; |
150 }; | 150 }; |
151 | 151 |
152 } // namespace cc | 152 } // namespace cc |
153 | 153 |
154 #endif // CC_SINGLE_THREAD_PROXY_H_ | 154 #endif // CC_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |