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 CCThreadProxy_h | 5 #ifndef CCThreadProxy_h |
6 #define CCThreadProxy_h | 6 #define CCThreadProxy_h |
7 | 7 |
8 #include "CCAnimationEvents.h" | 8 #include "CCAnimationEvents.h" |
9 #include "CCCompletionEvent.h" | 9 #include "CCCompletionEvent.h" |
10 #include "CCLayerTreeHostImpl.h" | 10 #include "CCLayerTreeHostImpl.h" |
11 #include "CCProxy.h" | 11 #include "CCProxy.h" |
12 #include "CCScheduler.h" | 12 #include "CCScheduler.h" |
13 #include "CCTextureUpdateController.h" | 13 #include "CCTextureUpdateController.h" |
14 #include <base/time.h> | 14 #include <base/time.h> |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 class CCInputHandler; | 18 class InputHandler; |
19 class CCLayerTreeHost; | 19 class LayerTreeHost; |
20 class CCScheduler; | 20 class Scheduler; |
21 class CCScopedThreadProxy; | 21 class ScopedThreadProxy; |
22 class CCTextureUpdateQueue; | 22 class TextureUpdateQueue; |
23 class CCThread; | 23 class Thread; |
24 class CCThreadProxyContextRecreationTimer; | 24 class ThreadProxyContextRecreationTimer; |
25 | 25 |
26 class CCThreadProxy : public CCProxy, CCLayerTreeHostImplClient, CCSchedulerClie
nt, CCTextureUpdateControllerClient { | 26 class ThreadProxy : public Proxy, LayerTreeHostImplClient, SchedulerClient, Text
ureUpdateControllerClient { |
27 public: | 27 public: |
28 static scoped_ptr<CCProxy> create(CCLayerTreeHost*); | 28 static scoped_ptr<Proxy> create(LayerTreeHost*); |
29 | 29 |
30 virtual ~CCThreadProxy(); | 30 virtual ~ThreadProxy(); |
31 | 31 |
32 // CCProxy implementation | 32 // Proxy implementation |
33 virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE; | 33 virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE; |
34 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double duration) OVERRIDE; | 34 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double duration) OVERRIDE; |
35 virtual void finishAllRendering() OVERRIDE; | 35 virtual void finishAllRendering() OVERRIDE; |
36 virtual bool isStarted() const OVERRIDE; | 36 virtual bool isStarted() const OVERRIDE; |
37 virtual bool initializeContext() OVERRIDE; | 37 virtual bool initializeContext() OVERRIDE; |
38 virtual void setSurfaceReady() OVERRIDE; | 38 virtual void setSurfaceReady() OVERRIDE; |
39 virtual void setVisible(bool) OVERRIDE; | 39 virtual void setVisible(bool) OVERRIDE; |
40 virtual bool initializeRenderer() OVERRIDE; | 40 virtual bool initializeRenderer() OVERRIDE; |
41 virtual bool recreateContext() OVERRIDE; | 41 virtual bool recreateContext() OVERRIDE; |
42 virtual void renderingStats(CCRenderingStats*) OVERRIDE; | 42 virtual void renderingStats(RenderingStats*) OVERRIDE; |
43 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; | 43 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; |
44 virtual void loseContext() OVERRIDE; | 44 virtual void loseContext() OVERRIDE; |
45 virtual void setNeedsAnimate() OVERRIDE; | 45 virtual void setNeedsAnimate() OVERRIDE; |
46 virtual void setNeedsCommit() OVERRIDE; | 46 virtual void setNeedsCommit() OVERRIDE; |
47 virtual void setNeedsRedraw() OVERRIDE; | 47 virtual void setNeedsRedraw() OVERRIDE; |
48 virtual bool commitRequested() const OVERRIDE; | 48 virtual bool commitRequested() const OVERRIDE; |
49 virtual void didAddAnimation() OVERRIDE { } | 49 virtual void didAddAnimation() OVERRIDE { } |
50 virtual void start() OVERRIDE; | 50 virtual void start() OVERRIDE; |
51 virtual void stop() OVERRIDE; | 51 virtual void stop() OVERRIDE; |
52 virtual size_t maxPartialTextureUpdates() const OVERRIDE; | 52 virtual size_t maxPartialTextureUpdates() const OVERRIDE; |
53 virtual void acquireLayerTextures() OVERRIDE; | 53 virtual void acquireLayerTextures() OVERRIDE; |
54 virtual void forceSerializeOnSwapBuffers() OVERRIDE; | 54 virtual void forceSerializeOnSwapBuffers() OVERRIDE; |
55 | 55 |
56 // CCLayerTreeHostImplClient implementation | 56 // LayerTreeHostImplClient implementation |
57 virtual void didLoseContextOnImplThread() OVERRIDE; | 57 virtual void didLoseContextOnImplThread() OVERRIDE; |
58 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; | 58 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; |
59 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; | 59 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; |
60 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; | 60 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; |
61 virtual void setNeedsRedrawOnImplThread() OVERRIDE; | 61 virtual void setNeedsRedrawOnImplThread() OVERRIDE; |
62 virtual void setNeedsCommitOnImplThread() OVERRIDE; | 62 virtual void setNeedsCommitOnImplThread() OVERRIDE; |
63 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE; | 63 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, double wallClockTime) OVERRIDE; |
64 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes) OVER
RIDE; | 64 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes) OVER
RIDE; |
65 | 65 |
66 // CCSchedulerClient implementation | 66 // SchedulerClient implementation |
67 virtual void scheduledActionBeginFrame() OVERRIDE; | 67 virtual void scheduledActionBeginFrame() OVERRIDE; |
68 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() OVERRIDE; | 68 virtual ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossibl
e() OVERRIDE; |
69 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) OVERRIDE; | 69 virtual ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced()
OVERRIDE; |
70 virtual void scheduledActionCommit() OVERRIDE; | 70 virtual void scheduledActionCommit() OVERRIDE; |
71 virtual void scheduledActionBeginContextRecreation() OVERRIDE; | 71 virtual void scheduledActionBeginContextRecreation() OVERRIDE; |
72 virtual void scheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 72 virtual void scheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
73 virtual void didAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE; | 73 virtual void didAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE; |
74 | 74 |
75 // CCTextureUpdateControllerClient implementation | 75 // TextureUpdateControllerClient implementation |
76 virtual void readyToFinalizeTextureUpdates() OVERRIDE; | 76 virtual void readyToFinalizeTextureUpdates() OVERRIDE; |
77 | 77 |
78 private: | 78 private: |
79 explicit CCThreadProxy(CCLayerTreeHost*); | 79 explicit ThreadProxy(LayerTreeHost*); |
80 friend class CCThreadProxyContextRecreationTimer; | 80 friend class ThreadProxyContextRecreationTimer; |
81 | 81 |
82 // Set on impl thread, read on main thread. | 82 // Set on impl thread, read on main thread. |
83 struct BeginFrameAndCommitState { | 83 struct BeginFrameAndCommitState { |
84 BeginFrameAndCommitState(); | 84 BeginFrameAndCommitState(); |
85 ~BeginFrameAndCommitState(); | 85 ~BeginFrameAndCommitState(); |
86 | 86 |
87 double monotonicFrameBeginTime; | 87 double monotonicFrameBeginTime; |
88 scoped_ptr<CCScrollAndScaleSet> scrollInfo; | 88 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
89 WebKit::WebTransformationMatrix implTransform; | 89 WebKit::WebTransformationMatrix implTransform; |
90 CCPrioritizedTextureManager::BackingList evictedContentsTexturesBackings
; | 90 PrioritizedTextureManager::BackingList evictedContentsTexturesBackings; |
91 size_t memoryAllocationLimitBytes; | 91 size_t memoryAllocationLimitBytes; |
92 }; | 92 }; |
93 scoped_ptr<BeginFrameAndCommitState> m_pendingBeginFrameRequest; | 93 scoped_ptr<BeginFrameAndCommitState> m_pendingBeginFrameRequest; |
94 | 94 |
95 // Called on main thread | 95 // Called on main thread |
96 void beginFrame(); | 96 void beginFrame(); |
97 void didCommitAndDrawFrame(); | 97 void didCommitAndDrawFrame(); |
98 void didCompleteSwapBuffers(); | 98 void didCompleteSwapBuffers(); |
99 void setAnimationEvents(CCAnimationEventsVector*, double wallClockTime); | 99 void setAnimationEvents(AnimationEventsVector*, double wallClockTime); |
100 void beginContextRecreation(); | 100 void beginContextRecreation(); |
101 void tryToRecreateContext(); | 101 void tryToRecreateContext(); |
102 | 102 |
103 // Called on impl thread | 103 // Called on impl thread |
104 struct ReadbackRequest { | 104 struct ReadbackRequest { |
105 CCCompletionEvent completion; | 105 CompletionEvent completion; |
106 bool success; | 106 bool success; |
107 void* pixels; | 107 void* pixels; |
108 IntRect rect; | 108 IntRect rect; |
109 }; | 109 }; |
110 void forceBeginFrameOnImplThread(CCCompletionEvent*); | 110 void forceBeginFrameOnImplThread(CompletionEvent*); |
111 void beginFrameCompleteOnImplThread(CCCompletionEvent*, CCTextureUpdateQueue
*); | 111 void beginFrameCompleteOnImplThread(CompletionEvent*, TextureUpdateQueue*); |
112 void beginFrameAbortedOnImplThread(); | 112 void beginFrameAbortedOnImplThread(); |
113 void requestReadbackOnImplThread(ReadbackRequest*); | 113 void requestReadbackOnImplThread(ReadbackRequest*); |
114 void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool
useAnchor, float scale, double durationSec); | 114 void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool
useAnchor, float scale, double durationSec); |
115 void finishAllRenderingOnImplThread(CCCompletionEvent*); | 115 void finishAllRenderingOnImplThread(CompletionEvent*); |
116 void initializeImplOnImplThread(CCCompletionEvent*, CCInputHandler*); | 116 void initializeImplOnImplThread(CompletionEvent*, InputHandler*); |
117 void setSurfaceReadyOnImplThread(); | 117 void setSurfaceReadyOnImplThread(); |
118 void setVisibleOnImplThread(CCCompletionEvent*, bool); | 118 void setVisibleOnImplThread(CompletionEvent*, bool); |
119 void initializeContextOnImplThread(CCGraphicsContext*); | 119 void initializeContextOnImplThread(GraphicsContext*); |
120 void initializeRendererOnImplThread(CCCompletionEvent*, bool* initializeSucc
eeded, RendererCapabilities*); | 120 void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSuccee
ded, RendererCapabilities*); |
121 void layerTreeHostClosedOnImplThread(CCCompletionEvent*); | 121 void layerTreeHostClosedOnImplThread(CompletionEvent*); |
122 void setFullRootLayerDamageOnImplThread(); | 122 void setFullRootLayerDamageOnImplThread(); |
123 void acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEvent*); | 123 void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*); |
124 void recreateContextOnImplThread(CCCompletionEvent*, CCGraphicsContext*, boo
l* recreateSucceeded, RendererCapabilities*); | 124 void recreateContextOnImplThread(CompletionEvent*, GraphicsContext*, bool* r
ecreateSucceeded, RendererCapabilities*); |
125 void renderingStatsOnImplThread(CCCompletionEvent*, CCRenderingStats*); | 125 void renderingStatsOnImplThread(CompletionEvent*, RenderingStats*); |
126 CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool f
orcedDraw); | 126 ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool for
cedDraw); |
127 void forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent*); | 127 void forceSerializeOnSwapBuffersOnImplThread(CompletionEvent*); |
128 void setNeedsForcedCommitOnImplThread(); | 128 void setNeedsForcedCommitOnImplThread(); |
129 | 129 |
130 // Accessed on main thread only. | 130 // Accessed on main thread only. |
131 bool m_animateRequested; // Set only when setNeedsAnimate is called. | 131 bool m_animateRequested; // Set only when setNeedsAnimate is called. |
132 bool m_commitRequested; // Set only when setNeedsCommit is called. | 132 bool m_commitRequested; // Set only when setNeedsCommit is called. |
133 bool m_commitRequestSentToImplThread; // Set by setNeedsCommit and setNeedsA
nimate. | 133 bool m_commitRequestSentToImplThread; // Set by setNeedsCommit and setNeedsA
nimate. |
134 bool m_forcedCommitRequested; | 134 bool m_forcedCommitRequested; |
135 scoped_ptr<CCThreadProxyContextRecreationTimer> m_contextRecreationTimer; | 135 scoped_ptr<ThreadProxyContextRecreationTimer> m_contextRecreationTimer; |
136 CCLayerTreeHost* m_layerTreeHost; | 136 LayerTreeHost* m_layerTreeHost; |
137 bool m_rendererInitialized; | 137 bool m_rendererInitialized; |
138 RendererCapabilities m_RendererCapabilitiesMainThreadCopy; | 138 RendererCapabilities m_RendererCapabilitiesMainThreadCopy; |
139 bool m_started; | 139 bool m_started; |
140 bool m_texturesAcquired; | 140 bool m_texturesAcquired; |
141 bool m_inCompositeAndReadback; | 141 bool m_inCompositeAndReadback; |
142 | 142 |
143 scoped_ptr<CCLayerTreeHostImpl> m_layerTreeHostImpl; | 143 scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; |
144 | 144 |
145 scoped_ptr<CCInputHandler> m_inputHandlerOnImplThread; | 145 scoped_ptr<InputHandler> m_inputHandlerOnImplThread; |
146 | 146 |
147 scoped_ptr<CCScheduler> m_schedulerOnImplThread; | 147 scoped_ptr<Scheduler> m_schedulerOnImplThread; |
148 | 148 |
149 RefPtr<CCScopedThreadProxy> m_mainThreadProxy; | 149 RefPtr<ScopedThreadProxy> m_mainThreadProxy; |
150 | 150 |
151 // Holds on to the context we might use for compositing in between initializ
eContext() | 151 // Holds on to the context we might use for compositing in between initializ
eContext() |
152 // and initializeRenderer() calls. | 152 // and initializeRenderer() calls. |
153 scoped_ptr<CCGraphicsContext> m_contextBeforeInitializationOnImplThread; | 153 scoped_ptr<GraphicsContext> m_contextBeforeInitializationOnImplThread; |
154 | 154 |
155 // Set when the main thread is waiting on a scheduledActionBeginFrame to be
issued. | 155 // Set when the main thread is waiting on a scheduledActionBeginFrame to be
issued. |
156 CCCompletionEvent* m_beginFrameCompletionEventOnImplThread; | 156 CompletionEvent* m_beginFrameCompletionEventOnImplThread; |
157 | 157 |
158 // Set when the main thread is waiting on a readback. | 158 // Set when the main thread is waiting on a readback. |
159 ReadbackRequest* m_readbackRequestOnImplThread; | 159 ReadbackRequest* m_readbackRequestOnImplThread; |
160 | 160 |
161 // Set when the main thread is waiting on a commit to complete. | 161 // Set when the main thread is waiting on a commit to complete. |
162 CCCompletionEvent* m_commitCompletionEventOnImplThread; | 162 CompletionEvent* m_commitCompletionEventOnImplThread; |
163 | 163 |
164 // Set when the main thread is waiting on layers to be drawn. | 164 // Set when the main thread is waiting on layers to be drawn. |
165 CCCompletionEvent* m_textureAcquisitionCompletionEventOnImplThread; | 165 CompletionEvent* m_textureAcquisitionCompletionEventOnImplThread; |
166 | 166 |
167 scoped_ptr<CCTextureUpdateController> m_currentTextureUpdateControllerOnImpl
Thread; | 167 scoped_ptr<TextureUpdateController> m_currentTextureUpdateControllerOnImplTh
read; |
168 | 168 |
169 // Set when the next draw should post didCommitAndDrawFrame to the main thre
ad. | 169 // Set when the next draw should post didCommitAndDrawFrame to the main thre
ad. |
170 bool m_nextFrameIsNewlyCommittedFrameOnImplThread; | 170 bool m_nextFrameIsNewlyCommittedFrameOnImplThread; |
171 | 171 |
172 bool m_renderVSyncEnabled; | 172 bool m_renderVSyncEnabled; |
173 | 173 |
174 base::TimeDelta m_totalCommitTime; | 174 base::TimeDelta m_totalCommitTime; |
175 size_t m_totalCommitCount; | 175 size_t m_totalCommitCount; |
176 }; | 176 }; |
177 | 177 |
178 } | 178 } |
179 | 179 |
180 #endif | 180 #endif |
OLD | NEW |