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_THREAD_PROXY_H_ | 5 #ifndef CC_THREAD_PROXY_H_ |
6 #define CC_THREAD_PROXY_H_ | 6 #define CC_THREAD_PROXY_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "cc/animation_events.h" | 10 #include "cc/animation_events.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 static scoped_ptr<Proxy> create(LayerTreeHost*, scoped_ptr<Thread> implThrea
d); | 28 static scoped_ptr<Proxy> create(LayerTreeHost*, scoped_ptr<Thread> implThrea
d); |
29 | 29 |
30 virtual ~ThreadProxy(); | 30 virtual ~ThreadProxy(); |
31 | 31 |
32 // Proxy implementation | 32 // Proxy implementation |
33 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; | 33 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) OVERRIDE; |
34 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta duration) OVERRIDE; | 34 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta 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 initializeOutputSurface() 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 recreateOutputSurface() OVERRIDE; | 41 virtual bool recreateContext() OVERRIDE; |
42 virtual void renderingStats(RenderingStats*) OVERRIDE; | 42 virtual void renderingStats(RenderingStats*) OVERRIDE; |
43 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; | 43 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; |
44 virtual void loseOutputSurface() 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 void setDeferCommits(bool) OVERRIDE; | 48 virtual void setDeferCommits(bool) OVERRIDE; |
49 virtual bool commitRequested() const OVERRIDE; | 49 virtual bool commitRequested() const OVERRIDE; |
50 virtual void didAddAnimation() OVERRIDE { } | 50 virtual void didAddAnimation() OVERRIDE { } |
51 virtual void start() OVERRIDE; | 51 virtual void start() OVERRIDE; |
52 virtual void stop() OVERRIDE; | 52 virtual void stop() OVERRIDE; |
53 virtual size_t maxPartialTextureUpdates() const OVERRIDE; | 53 virtual size_t maxPartialTextureUpdates() const OVERRIDE; |
54 virtual void acquireLayerTextures() OVERRIDE; | 54 virtual void acquireLayerTextures() OVERRIDE; |
55 virtual void forceSerializeOnSwapBuffers() OVERRIDE; | 55 virtual void forceSerializeOnSwapBuffers() OVERRIDE; |
56 | 56 |
57 // LayerTreeHostImplClient implementation | 57 // LayerTreeHostImplClient implementation |
58 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE; | 58 virtual void didLoseContextOnImplThread() OVERRIDE; |
59 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; | 59 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; |
60 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE; | 60 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE; |
61 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; | 61 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; |
62 virtual void setNeedsRedrawOnImplThread() OVERRIDE; | 62 virtual void setNeedsRedrawOnImplThread() OVERRIDE; |
63 virtual void setNeedsCommitOnImplThread() OVERRIDE; | 63 virtual void setNeedsCommitOnImplThread() OVERRIDE; |
64 virtual void setNeedsManageTilesOnImplThread() OVERRIDE; | 64 virtual void setNeedsManageTilesOnImplThread() OVERRIDE; |
65 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE; | 65 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE; |
66 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE; | 66 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE; |
67 virtual void sendManagedMemoryStats() OVERRIDE; | 67 virtual void sendManagedMemoryStats() OVERRIDE; |
68 | 68 |
(...skipping 21 matching lines...) Expand all Loading... |
90 gfx::Transform implTransform; | 90 gfx::Transform implTransform; |
91 size_t memoryAllocationLimitBytes; | 91 size_t memoryAllocationLimitBytes; |
92 }; | 92 }; |
93 | 93 |
94 // Called on main thread | 94 // Called on main thread |
95 void beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameState); | 95 void beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameState); |
96 void didCommitAndDrawFrame(); | 96 void didCommitAndDrawFrame(); |
97 void didCompleteSwapBuffers(); | 97 void didCompleteSwapBuffers(); |
98 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl
ockTime); | 98 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl
ockTime); |
99 void beginContextRecreation(); | 99 void beginContextRecreation(); |
100 void tryToRecreateOutputSurface(); | 100 void tryToRecreateContext(); |
101 | 101 |
102 // Called on impl thread | 102 // Called on impl thread |
103 struct ReadbackRequest { | 103 struct ReadbackRequest { |
104 CompletionEvent completion; | 104 CompletionEvent completion; |
105 bool success; | 105 bool success; |
106 void* pixels; | 106 void* pixels; |
107 gfx::Rect rect; | 107 gfx::Rect rect; |
108 }; | 108 }; |
109 void forceBeginFrameOnImplThread(CompletionEvent*); | 109 void forceBeginFrameOnImplThread(CompletionEvent*); |
110 void beginFrameCompleteOnImplThread(CompletionEvent*, ResourceUpdateQueue*); | 110 void beginFrameCompleteOnImplThread(CompletionEvent*, ResourceUpdateQueue*); |
111 void beginFrameAbortedOnImplThread(); | 111 void beginFrameAbortedOnImplThread(); |
112 void requestReadbackOnImplThread(ReadbackRequest*); | 112 void requestReadbackOnImplThread(ReadbackRequest*); |
113 void requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset,
bool useAnchor, float scale, base::TimeDelta duration); | 113 void requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targetOffset,
bool useAnchor, float scale, base::TimeDelta duration); |
114 void finishAllRenderingOnImplThread(CompletionEvent*); | 114 void finishAllRenderingOnImplThread(CompletionEvent*); |
115 void initializeImplOnImplThread(CompletionEvent*, InputHandler*); | 115 void initializeImplOnImplThread(CompletionEvent*, InputHandler*); |
116 void setSurfaceReadyOnImplThread(); | 116 void setSurfaceReadyOnImplThread(); |
117 void setVisibleOnImplThread(CompletionEvent*, bool); | 117 void setVisibleOnImplThread(CompletionEvent*, bool); |
118 void initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface>); | 118 void initializeContextOnImplThread(scoped_ptr<GraphicsContext>); |
119 void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSuccee
ded, RendererCapabilities*); | 119 void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSuccee
ded, RendererCapabilities*); |
120 void layerTreeHostClosedOnImplThread(CompletionEvent*); | 120 void layerTreeHostClosedOnImplThread(CompletionEvent*); |
121 void manageTilesOnImplThread(); | 121 void manageTilesOnImplThread(); |
122 void setFullRootLayerDamageOnImplThread(); | 122 void setFullRootLayerDamageOnImplThread(); |
123 void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*); | 123 void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*); |
124 void recreateOutputSurfaceOnImplThread(CompletionEvent*, scoped_ptr<OutputSu
rface>, bool* recreateSucceeded, RendererCapabilities*); | 124 void recreateContextOnImplThread(CompletionEvent*, scoped_ptr<GraphicsContex
t>, bool* recreateSucceeded, RendererCapabilities*); |
125 void renderingStatsOnImplThread(CompletionEvent*, RenderingStats*); | 125 void renderingStatsOnImplThread(CompletionEvent*, RenderingStats*); |
126 ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool for
cedDraw); | 126 ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool for
cedDraw); |
127 void forceSerializeOnSwapBuffersOnImplThread(CompletionEvent*); | 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 base::CancelableClosure m_outputSurfaceRecreationCallback; | 134 base::CancelableClosure m_contextRecreationCallback; |
135 LayerTreeHost* m_layerTreeHost; | 135 LayerTreeHost* m_layerTreeHost; |
136 bool m_rendererInitialized; | 136 bool m_rendererInitialized; |
137 RendererCapabilities m_RendererCapabilitiesMainThreadCopy; | 137 RendererCapabilities m_RendererCapabilitiesMainThreadCopy; |
138 bool m_started; | 138 bool m_started; |
139 bool m_texturesAcquired; | 139 bool m_texturesAcquired; |
140 bool m_inCompositeAndReadback; | 140 bool m_inCompositeAndReadback; |
141 bool m_manageTilesPending; | 141 bool m_manageTilesPending; |
142 | 142 |
143 scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; | 143 scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; |
144 | 144 |
145 scoped_ptr<InputHandler> m_inputHandlerOnImplThread; | 145 scoped_ptr<InputHandler> m_inputHandlerOnImplThread; |
146 | 146 |
147 scoped_ptr<Scheduler> m_schedulerOnImplThread; | 147 scoped_ptr<Scheduler> m_schedulerOnImplThread; |
148 | 148 |
149 scoped_refptr<ScopedThreadProxy> m_mainThreadProxy; | 149 scoped_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<OutputSurface> m_outputSurfaceBeforeInitializationOnImplThread; | 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 CompletionEvent* 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 CompletionEvent* m_commitCompletionEventOnImplThread; | 162 CompletionEvent* m_commitCompletionEventOnImplThread; |
163 | 163 |
(...skipping 10 matching lines...) Expand all Loading... |
174 base::TimeDelta m_totalCommitTime; | 174 base::TimeDelta m_totalCommitTime; |
175 size_t m_totalCommitCount; | 175 size_t m_totalCommitCount; |
176 | 176 |
177 bool m_deferCommits; | 177 bool m_deferCommits; |
178 scoped_ptr<BeginFrameAndCommitState> m_pendingDeferredCommit; | 178 scoped_ptr<BeginFrameAndCommitState> m_pendingDeferredCommit; |
179 }; | 179 }; |
180 | 180 |
181 } // namespace cc | 181 } // namespace cc |
182 | 182 |
183 #endif // CC_THREAD_PROXY_H_ | 183 #endif // CC_THREAD_PROXY_H_ |
OLD | NEW |