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

Side by Side Diff: cc/CCThreadedTest.h

Issue 10914268: Change cc files from namespace WebCore to cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCThreadTaskTest.cpp ('k') | cc/CCThreadedTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CCThreadedTest_h 5 #ifndef CCThreadedTest_h
6 #define CCThreadedTest_h 6 #define CCThreadedTest_h
7 7
8 #include "CCLayerTreeHost.h" 8 #include "CCLayerTreeHost.h"
9 #include "CCLayerTreeHostImpl.h" 9 #include "CCLayerTreeHostImpl.h"
10 #include "CCScopedThreadProxy.h" 10 #include "CCScopedThreadProxy.h"
11 #include "CompositorFakeWebGraphicsContext3D.h" 11 #include "CompositorFakeWebGraphicsContext3D.h"
12 #include <gtest/gtest.h> 12 #include <gtest/gtest.h>
13 #include <public/WebAnimationDelegate.h> 13 #include <public/WebAnimationDelegate.h>
14 #include <public/WebThread.h> 14 #include <public/WebThread.h>
15 15
16 namespace WebCore { 16 namespace cc {
17 class CCLayerImpl; 17 class CCLayerImpl;
18 class CCLayerTreeHost; 18 class CCLayerTreeHost;
19 class CCLayerTreeHostClient; 19 class CCLayerTreeHostClient;
20 class CCLayerTreeHostImpl; 20 class CCLayerTreeHostImpl;
21 class GraphicsContext3D; 21 class GraphicsContext3D;
22 } 22 }
23 23
24 namespace WebKitTests { 24 namespace WebKitTests {
25 25
26 // Used by test stubs to notify the test when something interesting happens. 26 // Used by test stubs to notify the test when something interesting happens.
27 class TestHooks : public WebKit::WebAnimationDelegate { 27 class TestHooks : public WebKit::WebAnimationDelegate {
28 public: 28 public:
29 virtual void beginCommitOnCCThread(WebCore::CCLayerTreeHostImpl*) { } 29 virtual void beginCommitOnCCThread(cc::CCLayerTreeHostImpl*) { }
30 virtual void commitCompleteOnCCThread(WebCore::CCLayerTreeHostImpl*) { } 30 virtual void commitCompleteOnCCThread(cc::CCLayerTreeHostImpl*) { }
31 virtual bool prepareToDrawOnCCThread(WebCore::CCLayerTreeHostImpl*) { return true; } 31 virtual bool prepareToDrawOnCCThread(cc::CCLayerTreeHostImpl*) { return true ; }
32 virtual void drawLayersOnCCThread(WebCore::CCLayerTreeHostImpl*) { } 32 virtual void drawLayersOnCCThread(cc::CCLayerTreeHostImpl*) { }
33 virtual void animateLayers(WebCore::CCLayerTreeHostImpl*, double monotonicTi me) { } 33 virtual void animateLayers(cc::CCLayerTreeHostImpl*, double monotonicTime) { }
34 virtual void willAnimateLayers(WebCore::CCLayerTreeHostImpl*, double monoton icTime) { } 34 virtual void willAnimateLayers(cc::CCLayerTreeHostImpl*, double monotonicTim e) { }
35 virtual void applyScrollAndScale(const WebCore::IntSize&, float) { } 35 virtual void applyScrollAndScale(const cc::IntSize&, float) { }
36 virtual void animate(double monotonicTime) { } 36 virtual void animate(double monotonicTime) { }
37 virtual void layout() { } 37 virtual void layout() { }
38 virtual void didRecreateOutputSurface(bool succeeded) { } 38 virtual void didRecreateOutputSurface(bool succeeded) { }
39 virtual void didAddAnimation() { } 39 virtual void didAddAnimation() { }
40 virtual void didCommit() { } 40 virtual void didCommit() { }
41 virtual void didCommitAndDrawFrame() { } 41 virtual void didCommitAndDrawFrame() { }
42 virtual void scheduleComposite() { } 42 virtual void scheduleComposite() { }
43 43
44 // Implementation of WebAnimationDelegate 44 // Implementation of WebAnimationDelegate
45 virtual void notifyAnimationStarted(double time) OVERRIDE { } 45 virtual void notifyAnimationStarted(double time) OVERRIDE { }
46 virtual void notifyAnimationFinished(double time) OVERRIDE { } 46 virtual void notifyAnimationFinished(double time) OVERRIDE { }
47 47
48 virtual PassOwnPtr<WebKit::WebCompositorOutputSurface> createOutputSurface() ; 48 virtual PassOwnPtr<WebKit::WebCompositorOutputSurface> createOutputSurface() ;
49 }; 49 };
50 50
51 class TimeoutTask; 51 class TimeoutTask;
52 class BeginTask; 52 class BeginTask;
53 53
54 class MockCCLayerTreeHostClient : public WebCore::CCLayerTreeHostClient { 54 class MockCCLayerTreeHostClient : public cc::CCLayerTreeHostClient {
55 }; 55 };
56 56
57 // The CCThreadedTests runs with the main loop running. It instantiates a single MockLayerTreeHost and associated 57 // The CCThreadedTests runs with the main loop running. It instantiates a single MockLayerTreeHost and associated
58 // MockLayerTreeHostImpl/MockLayerTreeHostClient. 58 // MockLayerTreeHostImpl/MockLayerTreeHostClient.
59 // 59 //
60 // beginTest() is called once the main message loop is running and the layer tre e host is initialized. 60 // beginTest() is called once the main message loop is running and the layer tre e host is initialized.
61 // 61 //
62 // Key stages of the drawing loop, e.g. drawing or commiting, redirect to CCThre adedTest methods of similar names. 62 // Key stages of the drawing loop, e.g. drawing or commiting, redirect to CCThre adedTest methods of similar names.
63 // To track the commit process, override these functions. 63 // To track the commit process, override these functions.
64 // 64 //
(...skipping 15 matching lines...) Expand all
80 void postSetNeedsRedrawToMainThread(); 80 void postSetNeedsRedrawToMainThread();
81 void postSetNeedsAnimateAndCommitToMainThread(); 81 void postSetNeedsAnimateAndCommitToMainThread();
82 void postSetVisibleToMainThread(bool visible); 82 void postSetVisibleToMainThread(bool visible);
83 void postDidAddAnimationToMainThread(); 83 void postDidAddAnimationToMainThread();
84 84
85 void doBeginTest(); 85 void doBeginTest();
86 void timeout(); 86 void timeout();
87 87
88 void clearTimeout() { m_timeoutTask = 0; } 88 void clearTimeout() { m_timeoutTask = 0; }
89 89
90 WebCore::CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } 90 cc::CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); }
91 91
92 protected: 92 protected:
93 CCThreadedTest(); 93 CCThreadedTest();
94 94
95 virtual void initializeSettings(WebCore::CCLayerTreeSettings&) { } 95 virtual void initializeSettings(cc::CCLayerTreeSettings&) { }
96 96
97 virtual void scheduleComposite(); 97 virtual void scheduleComposite();
98 98
99 void realEndTest(); 99 void realEndTest();
100 100
101 void dispatchSetNeedsAnimate(); 101 void dispatchSetNeedsAnimate();
102 void dispatchAddInstantAnimation(); 102 void dispatchAddInstantAnimation();
103 void dispatchAddAnimation(); 103 void dispatchAddAnimation();
104 void dispatchSetNeedsAnimateAndCommit(); 104 void dispatchSetNeedsAnimateAndCommit();
105 void dispatchSetNeedsCommit(); 105 void dispatchSetNeedsCommit();
106 void dispatchAcquireLayerTextures(); 106 void dispatchAcquireLayerTextures();
107 void dispatchSetNeedsRedraw(); 107 void dispatchSetNeedsRedraw();
108 void dispatchSetVisible(bool); 108 void dispatchSetVisible(bool);
109 void dispatchComposite(); 109 void dispatchComposite();
110 void dispatchDidAddAnimation(); 110 void dispatchDidAddAnimation();
111 111
112 virtual void runTest(bool threaded); 112 virtual void runTest(bool threaded);
113 WebKit::WebThread* webThread() const { return m_webThread.get(); } 113 WebKit::WebThread* webThread() const { return m_webThread.get(); }
114 114
115 WebCore::CCLayerTreeSettings m_settings; 115 cc::CCLayerTreeSettings m_settings;
116 OwnPtr<MockCCLayerTreeHostClient> m_client; 116 OwnPtr<MockCCLayerTreeHostClient> m_client;
117 OwnPtr<WebCore::CCLayerTreeHost> m_layerTreeHost; 117 OwnPtr<cc::CCLayerTreeHost> m_layerTreeHost;
118 118
119 protected: 119 protected:
120 RefPtr<WebCore::CCScopedThreadProxy> m_mainThreadProxy; 120 RefPtr<cc::CCScopedThreadProxy> m_mainThreadProxy;
121 121
122 private: 122 private:
123 bool m_beginning; 123 bool m_beginning;
124 bool m_endWhenBeginReturns; 124 bool m_endWhenBeginReturns;
125 bool m_timedOut; 125 bool m_timedOut;
126 bool m_finished; 126 bool m_finished;
127 bool m_scheduled; 127 bool m_scheduled;
128 bool m_started; 128 bool m_started;
129 129
130 OwnPtr<WebKit::WebThread> m_webThread; 130 OwnPtr<WebKit::WebThread> m_webThread;
131 TimeoutTask* m_timeoutTask; 131 TimeoutTask* m_timeoutTask;
132 BeginTask* m_beginTask; 132 BeginTask* m_beginTask;
133 }; 133 };
134 134
135 class CCThreadedTestThreadOnly : public CCThreadedTest { 135 class CCThreadedTestThreadOnly : public CCThreadedTest {
136 public: 136 public:
137 void runTestThreaded() 137 void runTestThreaded()
138 { 138 {
139 CCThreadedTest::runTest(true); 139 CCThreadedTest::runTest(true);
140 } 140 }
141 }; 141 };
142 142
143 // Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks. 143 // Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks.
144 class MockLayerTreeHostImpl : public WebCore::CCLayerTreeHostImpl { 144 class MockLayerTreeHostImpl : public cc::CCLayerTreeHostImpl {
145 public: 145 public:
146 static PassOwnPtr<MockLayerTreeHostImpl> create(TestHooks*, const WebCore::C CLayerTreeSettings&, WebCore::CCLayerTreeHostImplClient*); 146 static PassOwnPtr<MockLayerTreeHostImpl> create(TestHooks*, const cc::CCLaye rTreeSettings&, cc::CCLayerTreeHostImplClient*);
147 147
148 virtual void beginCommit(); 148 virtual void beginCommit();
149 virtual void commitComplete(); 149 virtual void commitComplete();
150 virtual bool prepareToDraw(FrameData&); 150 virtual bool prepareToDraw(FrameData&);
151 virtual void drawLayers(const FrameData&); 151 virtual void drawLayers(const FrameData&);
152 152
153 // Make these public. 153 // Make these public.
154 typedef Vector<WebCore::CCLayerImpl*> CCLayerList; 154 typedef Vector<cc::CCLayerImpl*> CCLayerList;
155 using CCLayerTreeHostImpl::calculateRenderSurfaceLayerList; 155 using CCLayerTreeHostImpl::calculateRenderSurfaceLayerList;
156 156
157 protected: 157 protected:
158 virtual void animateLayers(double monotonicTime, double wallClockTime); 158 virtual void animateLayers(double monotonicTime, double wallClockTime);
159 virtual double lowFrequencyAnimationInterval() const; 159 virtual double lowFrequencyAnimationInterval() const;
160 160
161 private: 161 private:
162 MockLayerTreeHostImpl(TestHooks*, const WebCore::CCLayerTreeSettings&, WebCo re::CCLayerTreeHostImplClient*); 162 MockLayerTreeHostImpl(TestHooks*, const cc::CCLayerTreeSettings&, cc::CCLaye rTreeHostImplClient*);
163 163
164 TestHooks* m_testHooks; 164 TestHooks* m_testHooks;
165 }; 165 };
166 166
167 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com positorFakeWebGraphicsContext3D { 167 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com positorFakeWebGraphicsContext3D {
168 public: 168 public:
169 static PassOwnPtr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre ate(Attributes); 169 static PassOwnPtr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre ate(Attributes);
170 170
171 virtual WebKit::WebGLId createTexture(); 171 virtual WebKit::WebGLId createTexture();
172 172
(...skipping 22 matching lines...) Expand all
195 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ 195 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \
196 { \ 196 { \
197 runTest(false); \ 197 runTest(false); \
198 } \ 198 } \
199 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ 199 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \
200 { \ 200 { \
201 runTest(true); \ 201 runTest(true); \
202 } 202 }
203 203
204 #endif // CCThreadedTest_h 204 #endif // CCThreadedTest_h
OLDNEW
« no previous file with comments | « cc/CCThreadTaskTest.cpp ('k') | cc/CCThreadedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698