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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
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 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHost.h" 7 #include "CCLayerTreeHost.h"
8 8
9 #include "CCGraphicsContext.h" 9 #include "CCGraphicsContext.h"
10 #include "CCLayerTreeHostImpl.h" 10 #include "CCLayerTreeHostImpl.h"
(...skipping 13 matching lines...) Expand all
24 #include <public/Platform.h> 24 #include <public/Platform.h>
25 #include <public/WebLayerScrollClient.h> 25 #include <public/WebLayerScrollClient.h>
26 #include <public/WebSize.h> 26 #include <public/WebSize.h>
27 27
28 using namespace cc; 28 using namespace cc;
29 using namespace WebKit; 29 using namespace WebKit;
30 using namespace WebKitTests; 30 using namespace WebKitTests;
31 31
32 namespace { 32 namespace {
33 33
34 class CCLayerTreeHostTest : public CCThreadedTest { }; 34 class LayerTreeHostTest : public ThreadedTest { };
35 35
36 // Shortlived layerTreeHosts shouldn't die. 36 // Shortlived layerTreeHosts shouldn't die.
37 class CCLayerTreeHostTestShortlived1 : public CCLayerTreeHostTest { 37 class LayerTreeHostTestShortlived1 : public LayerTreeHostTest {
38 public: 38 public:
39 CCLayerTreeHostTestShortlived1() { } 39 LayerTreeHostTestShortlived1() { }
40 40
41 virtual void beginTest() OVERRIDE 41 virtual void beginTest() OVERRIDE
42 { 42 {
43 // Kill the layerTreeHost immediately. 43 // Kill the layerTreeHost immediately.
44 m_layerTreeHost->setRootLayer(0); 44 m_layerTreeHost->setRootLayer(0);
45 m_layerTreeHost.reset(); 45 m_layerTreeHost.reset();
46 46
47 endTest(); 47 endTest();
48 } 48 }
49 49
50 virtual void afterTest() OVERRIDE 50 virtual void afterTest() OVERRIDE
51 { 51 {
52 } 52 }
53 }; 53 };
54 54
55 // Shortlived layerTreeHosts shouldn't die with a commit in flight. 55 // Shortlived layerTreeHosts shouldn't die with a commit in flight.
56 class CCLayerTreeHostTestShortlived2 : public CCLayerTreeHostTest { 56 class LayerTreeHostTestShortlived2 : public LayerTreeHostTest {
57 public: 57 public:
58 CCLayerTreeHostTestShortlived2() { } 58 LayerTreeHostTestShortlived2() { }
59 59
60 virtual void beginTest() OVERRIDE 60 virtual void beginTest() OVERRIDE
61 { 61 {
62 postSetNeedsCommitToMainThread(); 62 postSetNeedsCommitToMainThread();
63 63
64 // Kill the layerTreeHost immediately. 64 // Kill the layerTreeHost immediately.
65 m_layerTreeHost->setRootLayer(0); 65 m_layerTreeHost->setRootLayer(0);
66 m_layerTreeHost.reset(); 66 m_layerTreeHost.reset();
67 67
68 endTest(); 68 endTest();
69 } 69 }
70 70
71 virtual void afterTest() OVERRIDE 71 virtual void afterTest() OVERRIDE
72 { 72 {
73 } 73 }
74 }; 74 };
75 75
76 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestShortlived2) 76 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShortlived2)
77 77
78 // Shortlived layerTreeHosts shouldn't die with a redraw in flight. 78 // Shortlived layerTreeHosts shouldn't die with a redraw in flight.
79 class CCLayerTreeHostTestShortlived3 : public CCLayerTreeHostTest { 79 class LayerTreeHostTestShortlived3 : public LayerTreeHostTest {
80 public: 80 public:
81 CCLayerTreeHostTestShortlived3() { } 81 LayerTreeHostTestShortlived3() { }
82 82
83 virtual void beginTest() OVERRIDE 83 virtual void beginTest() OVERRIDE
84 { 84 {
85 postSetNeedsRedrawToMainThread(); 85 postSetNeedsRedrawToMainThread();
86 86
87 // Kill the layerTreeHost immediately. 87 // Kill the layerTreeHost immediately.
88 m_layerTreeHost->setRootLayer(0); 88 m_layerTreeHost->setRootLayer(0);
89 m_layerTreeHost.reset(); 89 m_layerTreeHost.reset();
90 90
91 endTest(); 91 endTest();
92 } 92 }
93 93
94 virtual void afterTest() OVERRIDE 94 virtual void afterTest() OVERRIDE
95 { 95 {
96 } 96 }
97 }; 97 };
98 98
99 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestShortlived3) 99 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShortlived3)
100 100
101 // Test interleaving of redraws and commits 101 // Test interleaving of redraws and commits
102 class CCLayerTreeHostTestCommitingWithContinuousRedraw : public CCLayerTreeHostT est { 102 class LayerTreeHostTestCommitingWithContinuousRedraw : public LayerTreeHostTest {
103 public: 103 public:
104 CCLayerTreeHostTestCommitingWithContinuousRedraw() 104 LayerTreeHostTestCommitingWithContinuousRedraw()
105 : m_numCompleteCommits(0) 105 : m_numCompleteCommits(0)
106 , m_numDraws(0) 106 , m_numDraws(0)
107 { 107 {
108 } 108 }
109 109
110 virtual void beginTest() OVERRIDE 110 virtual void beginTest() OVERRIDE
111 { 111 {
112 postSetNeedsCommitToMainThread(); 112 postSetNeedsCommitToMainThread();
113 } 113 }
114 114
115 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 115 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
116 { 116 {
117 m_numCompleteCommits++; 117 m_numCompleteCommits++;
118 if (m_numCompleteCommits == 2) 118 if (m_numCompleteCommits == 2)
119 endTest(); 119 endTest();
120 } 120 }
121 121
122 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 122 virtual void drawLayersOnThread(LayerTreeHostImpl*) OVERRIDE
123 { 123 {
124 if (m_numDraws == 1) 124 if (m_numDraws == 1)
125 postSetNeedsCommitToMainThread(); 125 postSetNeedsCommitToMainThread();
126 m_numDraws++; 126 m_numDraws++;
127 postSetNeedsRedrawToMainThread(); 127 postSetNeedsRedrawToMainThread();
128 } 128 }
129 129
130 virtual void afterTest() OVERRIDE 130 virtual void afterTest() OVERRIDE
131 { 131 {
132 } 132 }
133 133
134 private: 134 private:
135 int m_numCompleteCommits; 135 int m_numCompleteCommits;
136 int m_numDraws; 136 int m_numDraws;
137 }; 137 };
138 138
139 TEST_F(CCLayerTreeHostTestCommitingWithContinuousRedraw, runMultiThread) 139 TEST_F(LayerTreeHostTestCommitingWithContinuousRedraw, runMultiThread)
140 { 140 {
141 runTest(true); 141 runTest(true);
142 } 142 }
143 143
144 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 144 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1
145 // draw with frame 0. 145 // draw with frame 0.
146 class CCLayerTreeHostTestSetNeedsCommit1 : public CCLayerTreeHostTest { 146 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
147 public: 147 public:
148 CCLayerTreeHostTestSetNeedsCommit1() 148 LayerTreeHostTestSetNeedsCommit1()
149 : m_numCommits(0) 149 : m_numCommits(0)
150 , m_numDraws(0) 150 , m_numDraws(0)
151 { 151 {
152 } 152 }
153 153
154 virtual void beginTest() OVERRIDE 154 virtual void beginTest() OVERRIDE
155 { 155 {
156 postSetNeedsCommitToMainThread(); 156 postSetNeedsCommitToMainThread();
157 postSetNeedsCommitToMainThread(); 157 postSetNeedsCommitToMainThread();
158 } 158 }
159 159
160 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 160 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
161 { 161 {
162 m_numDraws++; 162 m_numDraws++;
163 if (!impl->sourceFrameNumber()) 163 if (!impl->sourceFrameNumber())
164 endTest(); 164 endTest();
165 } 165 }
166 166
167 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 167 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
168 { 168 {
169 m_numCommits++; 169 m_numCommits++;
170 } 170 }
171 171
172 virtual void afterTest() OVERRIDE 172 virtual void afterTest() OVERRIDE
173 { 173 {
174 EXPECT_GE(1, m_numCommits); 174 EXPECT_GE(1, m_numCommits);
175 EXPECT_GE(1, m_numDraws); 175 EXPECT_GE(1, m_numDraws);
176 } 176 }
177 177
178 private: 178 private:
179 int m_numCommits; 179 int m_numCommits;
180 int m_numDraws; 180 int m_numDraws;
181 }; 181 };
182 182
183 TEST_F(CCLayerTreeHostTestSetNeedsCommit1, DISABLED_runMultiThread) 183 TEST_F(LayerTreeHostTestSetNeedsCommit1, DISABLED_runMultiThread)
184 { 184 {
185 runTest(true); 185 runTest(true);
186 } 186 }
187 187
188 // A setNeedsCommit should lead to 1 commit. Issuing a second commit after that 188 // A setNeedsCommit should lead to 1 commit. Issuing a second commit after that
189 // first committed frame draws should lead to another commit. 189 // first committed frame draws should lead to another commit.
190 class CCLayerTreeHostTestSetNeedsCommit2 : public CCLayerTreeHostTest { 190 class LayerTreeHostTestSetNeedsCommit2 : public LayerTreeHostTest {
191 public: 191 public:
192 CCLayerTreeHostTestSetNeedsCommit2() 192 LayerTreeHostTestSetNeedsCommit2()
193 : m_numCommits(0) 193 : m_numCommits(0)
194 , m_numDraws(0) 194 , m_numDraws(0)
195 { 195 {
196 } 196 }
197 197
198 virtual void beginTest() OVERRIDE 198 virtual void beginTest() OVERRIDE
199 { 199 {
200 postSetNeedsCommitToMainThread(); 200 postSetNeedsCommitToMainThread();
201 } 201 }
202 202
203 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 203 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
204 { 204 {
205 if (!impl->sourceFrameNumber()) 205 if (!impl->sourceFrameNumber())
206 postSetNeedsCommitToMainThread(); 206 postSetNeedsCommitToMainThread();
207 else if (impl->sourceFrameNumber() == 1) 207 else if (impl->sourceFrameNumber() == 1)
208 endTest(); 208 endTest();
209 } 209 }
210 210
211 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 211 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
212 { 212 {
213 m_numCommits++; 213 m_numCommits++;
214 } 214 }
215 215
216 virtual void afterTest() OVERRIDE 216 virtual void afterTest() OVERRIDE
217 { 217 {
218 EXPECT_EQ(2, m_numCommits); 218 EXPECT_EQ(2, m_numCommits);
219 EXPECT_GE(2, m_numDraws); 219 EXPECT_GE(2, m_numDraws);
220 } 220 }
221 221
222 private: 222 private:
223 int m_numCommits; 223 int m_numCommits;
224 int m_numDraws; 224 int m_numDraws;
225 }; 225 };
226 226
227 #if OS(WINDOWS) 227 #if OS(WINDOWS)
228 // http://webkit.org/b/74623 228 // http://webkit.org/b/74623
229 TEST_F(CCLayerTreeHostTestSetNeedsCommit2, FLAKY_runMultiThread) 229 TEST_F(LayerTreeHostTestSetNeedsCommit2, FLAKY_runMultiThread)
230 #else 230 #else
231 TEST_F(CCLayerTreeHostTestSetNeedsCommit2, runMultiThread) 231 TEST_F(LayerTreeHostTestSetNeedsCommit2, runMultiThread)
232 #endif 232 #endif
233 { 233 {
234 runTest(true); 234 runTest(true);
235 } 235 }
236 236
237 // 1 setNeedsRedraw after the first commit has completed should lead to 1 237 // 1 setNeedsRedraw after the first commit has completed should lead to 1
238 // additional draw. 238 // additional draw.
239 class CCLayerTreeHostTestSetNeedsRedraw : public CCLayerTreeHostTest { 239 class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest {
240 public: 240 public:
241 CCLayerTreeHostTestSetNeedsRedraw() 241 LayerTreeHostTestSetNeedsRedraw()
242 : m_numCommits(0) 242 : m_numCommits(0)
243 , m_numDraws(0) 243 , m_numDraws(0)
244 { 244 {
245 } 245 }
246 246
247 virtual void beginTest() OVERRIDE 247 virtual void beginTest() OVERRIDE
248 { 248 {
249 postSetNeedsCommitToMainThread(); 249 postSetNeedsCommitToMainThread();
250 } 250 }
251 251
252 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 252 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
253 { 253 {
254 EXPECT_EQ(0, impl->sourceFrameNumber()); 254 EXPECT_EQ(0, impl->sourceFrameNumber());
255 if (!m_numDraws) 255 if (!m_numDraws)
256 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the second redraw doesn't commit. 256 postSetNeedsRedrawToMainThread(); // Redraw again to verify that the second redraw doesn't commit.
257 else 257 else
258 endTest(); 258 endTest();
259 m_numDraws++; 259 m_numDraws++;
260 } 260 }
261 261
262 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 262 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
263 { 263 {
264 EXPECT_EQ(0, m_numDraws); 264 EXPECT_EQ(0, m_numDraws);
265 m_numCommits++; 265 m_numCommits++;
266 } 266 }
267 267
268 virtual void afterTest() OVERRIDE 268 virtual void afterTest() OVERRIDE
269 { 269 {
270 EXPECT_GE(2, m_numDraws); 270 EXPECT_GE(2, m_numDraws);
271 EXPECT_EQ(1, m_numCommits); 271 EXPECT_EQ(1, m_numCommits);
272 } 272 }
273 273
274 private: 274 private:
275 int m_numCommits; 275 int m_numCommits;
276 int m_numDraws; 276 int m_numDraws;
277 }; 277 };
278 278
279 TEST_F(CCLayerTreeHostTestSetNeedsRedraw, runMultiThread) 279 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread)
280 { 280 {
281 runTest(true); 281 runTest(true);
282 } 282 }
283 283
284 // If the layerTreeHost says it can't draw, then we should not try to draw. 284 // If the layerTreeHost says it can't draw, then we should not try to draw.
285 class CCLayerTreeHostTestCanDrawBlocksDrawing : public CCLayerTreeHostTest { 285 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest {
286 public: 286 public:
287 CCLayerTreeHostTestCanDrawBlocksDrawing() 287 LayerTreeHostTestCanDrawBlocksDrawing()
288 : m_numCommits(0) 288 : m_numCommits(0)
289 { 289 {
290 } 290 }
291 291
292 virtual void beginTest() OVERRIDE 292 virtual void beginTest() OVERRIDE
293 { 293 {
294 postSetNeedsCommitToMainThread(); 294 postSetNeedsCommitToMainThread();
295 } 295 }
296 296
297 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 297 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
298 { 298 {
299 // Only the initial draw should bring us here. 299 // Only the initial draw should bring us here.
300 EXPECT_TRUE(impl->canDraw()); 300 EXPECT_TRUE(impl->canDraw());
301 EXPECT_EQ(0, impl->sourceFrameNumber()); 301 EXPECT_EQ(0, impl->sourceFrameNumber());
302 } 302 }
303 303
304 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 304 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
305 { 305 {
306 if (m_numCommits >= 1) { 306 if (m_numCommits >= 1) {
307 // After the first commit, we should not be able to draw. 307 // After the first commit, we should not be able to draw.
308 EXPECT_FALSE(impl->canDraw()); 308 EXPECT_FALSE(impl->canDraw());
309 } 309 }
310 } 310 }
311 311
312 virtual void didCommit() OVERRIDE 312 virtual void didCommit() OVERRIDE
313 { 313 {
314 m_numCommits++; 314 m_numCommits++;
(...skipping 11 matching lines...) Expand all
326 } 326 }
327 327
328 virtual void afterTest() OVERRIDE 328 virtual void afterTest() OVERRIDE
329 { 329 {
330 } 330 }
331 331
332 private: 332 private:
333 int m_numCommits; 333 int m_numCommits;
334 }; 334 };
335 335
336 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestCanDrawBlocksDrawing) 336 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing)
337 337
338 // beginLayerWrite should prevent draws from executing until a commit occurs 338 // beginLayerWrite should prevent draws from executing until a commit occurs
339 class CCLayerTreeHostTestWriteLayersRedraw : public CCLayerTreeHostTest { 339 class LayerTreeHostTestWriteLayersRedraw : public LayerTreeHostTest {
340 public: 340 public:
341 CCLayerTreeHostTestWriteLayersRedraw() 341 LayerTreeHostTestWriteLayersRedraw()
342 : m_numCommits(0) 342 : m_numCommits(0)
343 , m_numDraws(0) 343 , m_numDraws(0)
344 { 344 {
345 } 345 }
346 346
347 virtual void beginTest() OVERRIDE 347 virtual void beginTest() OVERRIDE
348 { 348 {
349 postAcquireLayerTextures(); 349 postAcquireLayerTextures();
350 postSetNeedsRedrawToMainThread(); // should be inhibited without blockin g 350 postSetNeedsRedrawToMainThread(); // should be inhibited without blockin g
351 postSetNeedsCommitToMainThread(); 351 postSetNeedsCommitToMainThread();
352 } 352 }
353 353
354 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 354 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
355 { 355 {
356 m_numDraws++; 356 m_numDraws++;
357 EXPECT_EQ(m_numDraws, m_numCommits); 357 EXPECT_EQ(m_numDraws, m_numCommits);
358 } 358 }
359 359
360 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 360 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
361 { 361 {
362 m_numCommits++; 362 m_numCommits++;
363 endTest(); 363 endTest();
364 } 364 }
365 365
366 virtual void afterTest() OVERRIDE 366 virtual void afterTest() OVERRIDE
367 { 367 {
368 EXPECT_EQ(1, m_numCommits); 368 EXPECT_EQ(1, m_numCommits);
369 } 369 }
370 370
371 private: 371 private:
372 int m_numCommits; 372 int m_numCommits;
373 int m_numDraws; 373 int m_numDraws;
374 }; 374 };
375 375
376 TEST_F(CCLayerTreeHostTestWriteLayersRedraw, runMultiThread) 376 TEST_F(LayerTreeHostTestWriteLayersRedraw, runMultiThread)
377 { 377 {
378 runTest(true); 378 runTest(true);
379 } 379 }
380 380
381 // Verify that when resuming visibility, requesting layer write permission 381 // Verify that when resuming visibility, requesting layer write permission
382 // will not deadlock the main thread even though there are not yet any 382 // will not deadlock the main thread even though there are not yet any
383 // scheduled redraws. This behavior is critical for reliably surviving tab 383 // scheduled redraws. This behavior is critical for reliably surviving tab
384 // switching. There are no failure conditions to this test, it just passes 384 // switching. There are no failure conditions to this test, it just passes
385 // by not timing out. 385 // by not timing out.
386 class CCLayerTreeHostTestWriteLayersAfterVisible : public CCLayerTreeHostTest { 386 class LayerTreeHostTestWriteLayersAfterVisible : public LayerTreeHostTest {
387 public: 387 public:
388 CCLayerTreeHostTestWriteLayersAfterVisible() 388 LayerTreeHostTestWriteLayersAfterVisible()
389 : m_numCommits(0) 389 : m_numCommits(0)
390 { 390 {
391 } 391 }
392 392
393 virtual void beginTest() OVERRIDE 393 virtual void beginTest() OVERRIDE
394 { 394 {
395 postSetNeedsCommitToMainThread(); 395 postSetNeedsCommitToMainThread();
396 } 396 }
397 397
398 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 398 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
399 { 399 {
400 m_numCommits++; 400 m_numCommits++;
401 if (m_numCommits == 2) 401 if (m_numCommits == 2)
402 endTest(); 402 endTest();
403 else { 403 else {
404 postSetVisibleToMainThread(false); 404 postSetVisibleToMainThread(false);
405 postSetVisibleToMainThread(true); 405 postSetVisibleToMainThread(true);
406 postAcquireLayerTextures(); 406 postAcquireLayerTextures();
407 postSetNeedsCommitToMainThread(); 407 postSetNeedsCommitToMainThread();
408 } 408 }
409 } 409 }
410 410
411 virtual void afterTest() OVERRIDE 411 virtual void afterTest() OVERRIDE
412 { 412 {
413 } 413 }
414 414
415 private: 415 private:
416 int m_numCommits; 416 int m_numCommits;
417 }; 417 };
418 418
419 TEST_F(CCLayerTreeHostTestWriteLayersAfterVisible, runMultiThread) 419 TEST_F(LayerTreeHostTestWriteLayersAfterVisible, runMultiThread)
420 { 420 {
421 runTest(true); 421 runTest(true);
422 } 422 }
423 423
424 // A compositeAndReadback while invisible should force a normal commit without a ssertion. 424 // A compositeAndReadback while invisible should force a normal commit without a ssertion.
425 class CCLayerTreeHostTestCompositeAndReadbackWhileInvisible : public CCLayerTree HostTest { 425 class LayerTreeHostTestCompositeAndReadbackWhileInvisible : public LayerTreeHost Test {
426 public: 426 public:
427 CCLayerTreeHostTestCompositeAndReadbackWhileInvisible() 427 LayerTreeHostTestCompositeAndReadbackWhileInvisible()
428 : m_numCommits(0) 428 : m_numCommits(0)
429 { 429 {
430 } 430 }
431 431
432 virtual void beginTest() OVERRIDE 432 virtual void beginTest() OVERRIDE
433 { 433 {
434 } 434 }
435 435
436 virtual void didCommitAndDrawFrame() OVERRIDE 436 virtual void didCommitAndDrawFrame() OVERRIDE
437 { 437 {
(...skipping 10 matching lines...) Expand all
448 } 448 }
449 449
450 virtual void afterTest() OVERRIDE 450 virtual void afterTest() OVERRIDE
451 { 451 {
452 } 452 }
453 453
454 private: 454 private:
455 int m_numCommits; 455 int m_numCommits;
456 }; 456 };
457 457
458 TEST_F(CCLayerTreeHostTestCompositeAndReadbackWhileInvisible, runMultiThread) 458 TEST_F(LayerTreeHostTestCompositeAndReadbackWhileInvisible, runMultiThread)
459 { 459 {
460 runTest(true); 460 runTest(true);
461 } 461 }
462 462
463 class CCLayerTreeHostTestAbortFrameWhenInvisible : public CCLayerTreeHostTest { 463 class LayerTreeHostTestAbortFrameWhenInvisible : public LayerTreeHostTest {
464 public: 464 public:
465 CCLayerTreeHostTestAbortFrameWhenInvisible() 465 LayerTreeHostTestAbortFrameWhenInvisible()
466 { 466 {
467 } 467 }
468 468
469 virtual void beginTest() OVERRIDE 469 virtual void beginTest() OVERRIDE
470 { 470 {
471 // Request a commit (from the main thread), which will trigger the commi t flow from the impl side. 471 // Request a commit (from the main thread), which will trigger the commi t flow from the impl side.
472 m_layerTreeHost->setNeedsCommit(); 472 m_layerTreeHost->setNeedsCommit();
473 // Then mark ourselves as not visible before processing any more message s on the main thread. 473 // Then mark ourselves as not visible before processing any more message s on the main thread.
474 m_layerTreeHost->setVisible(false); 474 m_layerTreeHost->setVisible(false);
475 // If we make it without kicking a frame, we pass! 475 // If we make it without kicking a frame, we pass!
476 endTestAfterDelay(1); 476 endTestAfterDelay(1);
477 } 477 }
478 478
479 virtual void layout() OVERRIDE 479 virtual void layout() OVERRIDE
480 { 480 {
481 ASSERT_FALSE(true); 481 ASSERT_FALSE(true);
482 endTest(); 482 endTest();
483 } 483 }
484 484
485 virtual void afterTest() OVERRIDE 485 virtual void afterTest() OVERRIDE
486 { 486 {
487 } 487 }
488 488
489 private: 489 private:
490 }; 490 };
491 491
492 TEST_F(CCLayerTreeHostTestAbortFrameWhenInvisible, runMultiThread) 492 TEST_F(LayerTreeHostTestAbortFrameWhenInvisible, runMultiThread)
493 { 493 {
494 runTest(true); 494 runTest(true);
495 } 495 }
496 496
497 // Makes sure that setNedsAnimate does not cause the commitRequested() state to be set. 497 // Makes sure that setNedsAnimate does not cause the commitRequested() state to be set.
498 class CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested : public CCL ayerTreeHostTest { 498 class LayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested : public Layer TreeHostTest {
499 public: 499 public:
500 CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested() 500 LayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested()
501 : m_numCommits(0) 501 : m_numCommits(0)
502 { 502 {
503 } 503 }
504 504
505 virtual void beginTest() OVERRIDE 505 virtual void beginTest() OVERRIDE
506 { 506 {
507 // The tests start up with a commit pending because we give them a root layer. 507 // The tests start up with a commit pending because we give them a root layer.
508 // We need to wait for the commit to happen before doing anything. 508 // We need to wait for the commit to happen before doing anything.
509 EXPECT_TRUE(m_layerTreeHost->commitRequested()); 509 EXPECT_TRUE(m_layerTreeHost->commitRequested());
510 } 510 }
(...skipping 27 matching lines...) Expand all
538 } 538 }
539 539
540 virtual void afterTest() OVERRIDE 540 virtual void afterTest() OVERRIDE
541 { 541 {
542 } 542 }
543 543
544 private: 544 private:
545 int m_numCommits; 545 int m_numCommits;
546 }; 546 };
547 547
548 TEST_F(CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested, runMultiTh read) 548 TEST_F(LayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested, runMultiThre ad)
549 { 549 {
550 runTest(true); 550 runTest(true);
551 } 551 }
552 552
553 553
554 554
555 // Trigger a frame with setNeedsCommit. Then, inside the resulting animate 555 // Trigger a frame with setNeedsCommit. Then, inside the resulting animate
556 // callback, requet another frame using setNeedsAnimate. End the test when 556 // callback, requet another frame using setNeedsAnimate. End the test when
557 // animate gets called yet-again, indicating that the proxy is correctly 557 // animate gets called yet-again, indicating that the proxy is correctly
558 // handling the case where setNeedsAnimate() is called inside the begin frame 558 // handling the case where setNeedsAnimate() is called inside the begin frame
559 // flow. 559 // flow.
560 class CCLayerTreeHostTestSetNeedsAnimateInsideAnimationCallback : public CCLayer TreeHostTest { 560 class LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback : public LayerTree HostTest {
561 public: 561 public:
562 CCLayerTreeHostTestSetNeedsAnimateInsideAnimationCallback() 562 LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback()
563 : m_numAnimates(0) 563 : m_numAnimates(0)
564 { 564 {
565 } 565 }
566 566
567 virtual void beginTest() OVERRIDE 567 virtual void beginTest() OVERRIDE
568 { 568 {
569 postSetNeedsAnimateToMainThread(); 569 postSetNeedsAnimateToMainThread();
570 } 570 }
571 571
572 virtual void animate(double) OVERRIDE 572 virtual void animate(double) OVERRIDE
573 { 573 {
574 if (!m_numAnimates) { 574 if (!m_numAnimates) {
575 m_layerTreeHost->setNeedsAnimate(); 575 m_layerTreeHost->setNeedsAnimate();
576 m_numAnimates++; 576 m_numAnimates++;
577 return; 577 return;
578 } 578 }
579 endTest(); 579 endTest();
580 } 580 }
581 581
582 virtual void afterTest() OVERRIDE 582 virtual void afterTest() OVERRIDE
583 { 583 {
584 } 584 }
585 585
586 private: 586 private:
587 int m_numAnimates; 587 int m_numAnimates;
588 }; 588 };
589 589
590 TEST_F(CCLayerTreeHostTestSetNeedsAnimateInsideAnimationCallback, runMultiThread ) 590 TEST_F(LayerTreeHostTestSetNeedsAnimateInsideAnimationCallback, runMultiThread)
591 { 591 {
592 runTest(true); 592 runTest(true);
593 } 593 }
594 594
595 // Add a layer animation and confirm that CCLayerTreeHostImpl::animateLayers doe s get 595 // Add a layer animation and confirm that LayerTreeHostImpl::animateLayers does get
596 // called and continues to get called. 596 // called and continues to get called.
597 class CCLayerTreeHostTestAddAnimation : public CCLayerTreeHostTest { 597 class LayerTreeHostTestAddAnimation : public LayerTreeHostTest {
598 public: 598 public:
599 CCLayerTreeHostTestAddAnimation() 599 LayerTreeHostTestAddAnimation()
600 : m_numAnimates(0) 600 : m_numAnimates(0)
601 , m_receivedAnimationStartedNotification(false) 601 , m_receivedAnimationStartedNotification(false)
602 , m_startTime(0) 602 , m_startTime(0)
603 , m_firstMonotonicTime(0) 603 , m_firstMonotonicTime(0)
604 { 604 {
605 } 605 }
606 606
607 virtual void beginTest() OVERRIDE 607 virtual void beginTest() OVERRIDE
608 { 608 {
609 postAddInstantAnimationToMainThread(); 609 postAddInstantAnimationToMainThread();
610 } 610 }
611 611
612 virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double mo notonicTime) OVERRIDE 612 virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, double mono tonicTime) OVERRIDE
613 { 613 {
614 if (!m_numAnimates) { 614 if (!m_numAnimates) {
615 // The animation had zero duration so layerTreeHostImpl should no 615 // The animation had zero duration so layerTreeHostImpl should no
616 // longer need to animate its layers. 616 // longer need to animate its layers.
617 EXPECT_FALSE(layerTreeHostImpl->needsAnimateLayers()); 617 EXPECT_FALSE(layerTreeHostImpl->needsAnimateLayers());
618 m_numAnimates++; 618 m_numAnimates++;
619 m_firstMonotonicTime = monotonicTime; 619 m_firstMonotonicTime = monotonicTime;
620 return; 620 return;
621 } 621 }
622 EXPECT_LT(0, m_startTime); 622 EXPECT_LT(0, m_startTime);
(...skipping 13 matching lines...) Expand all
636 { 636 {
637 } 637 }
638 638
639 private: 639 private:
640 int m_numAnimates; 640 int m_numAnimates;
641 bool m_receivedAnimationStartedNotification; 641 bool m_receivedAnimationStartedNotification;
642 double m_startTime; 642 double m_startTime;
643 double m_firstMonotonicTime; 643 double m_firstMonotonicTime;
644 }; 644 };
645 645
646 TEST_F(CCLayerTreeHostTestAddAnimation, runMultiThread) 646 TEST_F(LayerTreeHostTestAddAnimation, runMultiThread)
647 { 647 {
648 runTest(true); 648 runTest(true);
649 } 649 }
650 650
651 // Add a layer animation to a layer, but continually fail to draw. Confirm that after 651 // Add a layer animation to a layer, but continually fail to draw. Confirm that after
652 // a while, we do eventually force a draw. 652 // a while, we do eventually force a draw.
653 class CCLayerTreeHostTestCheckerboardDoesNotStarveDraws : public CCLayerTreeHost Test { 653 class LayerTreeHostTestCheckerboardDoesNotStarveDraws : public LayerTreeHostTest {
654 public: 654 public:
655 CCLayerTreeHostTestCheckerboardDoesNotStarveDraws() 655 LayerTreeHostTestCheckerboardDoesNotStarveDraws()
656 : m_startedAnimating(false) 656 : m_startedAnimating(false)
657 { 657 {
658 } 658 }
659 659
660 virtual void beginTest() OVERRIDE 660 virtual void beginTest() OVERRIDE
661 { 661 {
662 postAddAnimationToMainThread(); 662 postAddAnimationToMainThread();
663 } 663 }
664 664
665 virtual void afterTest() OVERRIDE 665 virtual void afterTest() OVERRIDE
666 { 666 {
667 } 667 }
668 668
669 virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double mo notonicTime) OVERRIDE 669 virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, double mono tonicTime) OVERRIDE
670 { 670 {
671 m_startedAnimating = true; 671 m_startedAnimating = true;
672 } 672 }
673 673
674 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 674 virtual void drawLayersOnThread(LayerTreeHostImpl*) OVERRIDE
675 { 675 {
676 if (m_startedAnimating) 676 if (m_startedAnimating)
677 endTest(); 677 endTest();
678 } 678 }
679 679
680 virtual bool prepareToDrawOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 680 virtual bool prepareToDrawOnThread(LayerTreeHostImpl*) OVERRIDE
681 { 681 {
682 return false; 682 return false;
683 } 683 }
684 684
685 private: 685 private:
686 bool m_startedAnimating; 686 bool m_startedAnimating;
687 }; 687 };
688 688
689 // Starvation can only be an issue with the MT compositor. 689 // Starvation can only be an issue with the MT compositor.
690 TEST_F(CCLayerTreeHostTestCheckerboardDoesNotStarveDraws, runMultiThread) 690 TEST_F(LayerTreeHostTestCheckerboardDoesNotStarveDraws, runMultiThread)
691 { 691 {
692 runTest(true); 692 runTest(true);
693 } 693 }
694 694
695 // Ensures that animations continue to be ticked when we are backgrounded. 695 // Ensures that animations continue to be ticked when we are backgrounded.
696 class CCLayerTreeHostTestTickAnimationWhileBackgrounded : public CCLayerTreeHost Test { 696 class LayerTreeHostTestTickAnimationWhileBackgrounded : public LayerTreeHostTest {
697 public: 697 public:
698 CCLayerTreeHostTestTickAnimationWhileBackgrounded() 698 LayerTreeHostTestTickAnimationWhileBackgrounded()
699 : m_numAnimates(0) 699 : m_numAnimates(0)
700 { 700 {
701 } 701 }
702 702
703 virtual void beginTest() OVERRIDE 703 virtual void beginTest() OVERRIDE
704 { 704 {
705 postAddAnimationToMainThread(); 705 postAddAnimationToMainThread();
706 } 706 }
707 707
708 // Use willAnimateLayers to set visible false before the animation runs and 708 // Use willAnimateLayers to set visible false before the animation runs and
709 // causes a commit, so we block the second visible animate in single-thread 709 // causes a commit, so we block the second visible animate in single-thread
710 // mode. 710 // mode.
711 virtual void willAnimateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, doubl e monotonicTime) OVERRIDE 711 virtual void willAnimateLayers(LayerTreeHostImpl* layerTreeHostImpl, double monotonicTime) OVERRIDE
712 { 712 {
713 if (m_numAnimates < 2) { 713 if (m_numAnimates < 2) {
714 if (!m_numAnimates) { 714 if (!m_numAnimates) {
715 // We have a long animation running. It should continue to tick even if we are not visible. 715 // We have a long animation running. It should continue to tick even if we are not visible.
716 postSetVisibleToMainThread(false); 716 postSetVisibleToMainThread(false);
717 } 717 }
718 m_numAnimates++; 718 m_numAnimates++;
719 return; 719 return;
720 } 720 }
721 endTest(); 721 endTest();
722 } 722 }
723 723
724 virtual void afterTest() OVERRIDE 724 virtual void afterTest() OVERRIDE
725 { 725 {
726 } 726 }
727 727
728 private: 728 private:
729 int m_numAnimates; 729 int m_numAnimates;
730 }; 730 };
731 731
732 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded ) 732 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestTickAnimationWhileBackgrounded)
733 733
734 // Ensures that animations continue to be ticked when we are backgrounded. 734 // Ensures that animations continue to be ticked when we are backgrounded.
735 class CCLayerTreeHostTestAddAnimationWithTimingFunction : public CCLayerTreeHost Test { 735 class LayerTreeHostTestAddAnimationWithTimingFunction : public LayerTreeHostTest {
736 public: 736 public:
737 CCLayerTreeHostTestAddAnimationWithTimingFunction() 737 LayerTreeHostTestAddAnimationWithTimingFunction()
738 { 738 {
739 } 739 }
740 740
741 virtual void beginTest() OVERRIDE 741 virtual void beginTest() OVERRIDE
742 { 742 {
743 postAddAnimationToMainThread(); 743 postAddAnimationToMainThread();
744 } 744 }
745 745
746 virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double mo notonicTime) OVERRIDE 746 virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, double mono tonicTime) OVERRIDE
747 { 747 {
748 const CCActiveAnimation* animation = m_layerTreeHost->rootLayer()->layer AnimationController()->getActiveAnimation(0, CCActiveAnimation::Opacity); 748 const ActiveAnimation* animation = m_layerTreeHost->rootLayer()->layerAn imationController()->getActiveAnimation(0, ActiveAnimation::Opacity);
749 if (!animation) 749 if (!animation)
750 return; 750 return;
751 const CCFloatAnimationCurve* curve = animation->curve()->toFloatAnimatio nCurve(); 751 const FloatAnimationCurve* curve = animation->curve()->toFloatAnimationC urve();
752 float startOpacity = curve->getValue(0); 752 float startOpacity = curve->getValue(0);
753 float endOpacity = curve->getValue(curve->duration()); 753 float endOpacity = curve->getValue(curve->duration());
754 float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpac ity; 754 float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpac ity;
755 double time = curve->duration() * 0.25; 755 double time = curve->duration() * 0.25;
756 // If the linear timing function associated with this animation was not picked up, 756 // If the linear timing function associated with this animation was not picked up,
757 // then the linearly interpolated opacity would be different because of the 757 // then the linearly interpolated opacity would be different because of the
758 // default ease timing function. 758 // default ease timing function.
759 EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time)); 759 EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time));
760 endTest(); 760 endTest();
761 } 761 }
762 762
763 virtual void afterTest() OVERRIDE 763 virtual void afterTest() OVERRIDE
764 { 764 {
765 } 765 }
766 766
767 private: 767 private:
768 }; 768 };
769 769
770 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction ) 770 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction)
771 771
772 // Ensures that when opacity is being animated, this value does not cause the su btree to be skipped. 772 // Ensures that when opacity is being animated, this value does not cause the su btree to be skipped.
773 class CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public CCLayerTree HostTest { 773 class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHost Test {
774 public: 774 public:
775 CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity() 775 LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity()
776 { 776 {
777 } 777 }
778 778
779 virtual void beginTest() OVERRIDE 779 virtual void beginTest() OVERRIDE
780 { 780 {
781 m_layerTreeHost->rootLayer()->setDrawOpacity(1); 781 m_layerTreeHost->rootLayer()->setDrawOpacity(1);
782 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 782 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
783 m_layerTreeHost->rootLayer()->setOpacity(0); 783 m_layerTreeHost->rootLayer()->setOpacity(0);
784 postAddAnimationToMainThread(); 784 postAddAnimationToMainThread();
785 } 785 }
786 786
787 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 787 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
788 { 788 {
789 // If the subtree was skipped when preparing to draw, the layer's draw o pacity 789 // If the subtree was skipped when preparing to draw, the layer's draw o pacity
790 // will not have been updated. It should be set to 0 due to the animatio n. 790 // will not have been updated. It should be set to 0 due to the animatio n.
791 // Without the animation, the layer will be skipped since it has zero op acity. 791 // Without the animation, the layer will be skipped since it has zero op acity.
792 EXPECT_EQ(0, m_layerTreeHost->rootLayer()->drawOpacity()); 792 EXPECT_EQ(0, m_layerTreeHost->rootLayer()->drawOpacity());
793 endTest(); 793 endTest();
794 } 794 }
795 795
796 virtual void afterTest() OVERRIDE 796 virtual void afterTest() OVERRIDE
797 { 797 {
798 } 798 }
799 }; 799 };
800 800
801 #if OS(WINDOWS) 801 #if OS(WINDOWS)
802 // http://webkit.org/b/74623 802 // http://webkit.org/b/74623
803 TEST_F(CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, FLAKY_runMultiThre ad) 803 TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, FLAKY_runMultiThread )
804 #else 804 #else
805 TEST_F(CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread) 805 TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread)
806 #endif 806 #endif
807 { 807 {
808 runTest(true); 808 runTest(true);
809 } 809 }
810 810
811 // Ensures that main thread animations have their start times synchronized with impl thread animations. 811 // Ensures that main thread animations have their start times synchronized with impl thread animations.
812 class CCLayerTreeHostTestSynchronizeAnimationStartTimes : public CCLayerTreeHost Test { 812 class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest {
813 public: 813 public:
814 CCLayerTreeHostTestSynchronizeAnimationStartTimes() 814 LayerTreeHostTestSynchronizeAnimationStartTimes()
815 : m_layerTreeHostImpl(0) 815 : m_layerTreeHostImpl(0)
816 { 816 {
817 } 817 }
818 818
819 virtual void beginTest() OVERRIDE 819 virtual void beginTest() OVERRIDE
820 { 820 {
821 postAddAnimationToMainThread(); 821 postAddAnimationToMainThread();
822 } 822 }
823 823
824 // This is guaranteed to be called before CCLayerTreeHostImpl::animateLayers . 824 // This is guaranteed to be called before LayerTreeHostImpl::animateLayers.
825 virtual void willAnimateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, doubl e monotonicTime) OVERRIDE 825 virtual void willAnimateLayers(LayerTreeHostImpl* layerTreeHostImpl, double monotonicTime) OVERRIDE
826 { 826 {
827 m_layerTreeHostImpl = layerTreeHostImpl; 827 m_layerTreeHostImpl = layerTreeHostImpl;
828 } 828 }
829 829
830 virtual void notifyAnimationStarted(double time) OVERRIDE 830 virtual void notifyAnimationStarted(double time) OVERRIDE
831 { 831 {
832 EXPECT_TRUE(m_layerTreeHostImpl); 832 EXPECT_TRUE(m_layerTreeHostImpl);
833 833
834 CCLayerAnimationController* controllerImpl = m_layerTreeHostImpl->rootLa yer()->layerAnimationController(); 834 LayerAnimationController* controllerImpl = m_layerTreeHostImpl->rootLaye r()->layerAnimationController();
835 CCLayerAnimationController* controller = m_layerTreeHost->rootLayer()->l ayerAnimationController(); 835 LayerAnimationController* controller = m_layerTreeHost->rootLayer()->lay erAnimationController();
836 CCActiveAnimation* animationImpl = controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity); 836 ActiveAnimation* animationImpl = controllerImpl->getActiveAnimation(0, A ctiveAnimation::Opacity);
837 CCActiveAnimation* animation = controller->getActiveAnimation(0, CCActiv eAnimation::Opacity); 837 ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAni mation::Opacity);
838 838
839 EXPECT_EQ(animationImpl->startTime(), animation->startTime()); 839 EXPECT_EQ(animationImpl->startTime(), animation->startTime());
840 840
841 endTest(); 841 endTest();
842 } 842 }
843 843
844 virtual void afterTest() OVERRIDE 844 virtual void afterTest() OVERRIDE
845 { 845 {
846 } 846 }
847 847
848 private: 848 private:
849 CCLayerTreeHostImpl* m_layerTreeHostImpl; 849 LayerTreeHostImpl* m_layerTreeHostImpl;
850 }; 850 };
851 851
852 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes ) 852 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSynchronizeAnimationStartTimes)
853 853
854 // Ensures that main thread animations have their start times synchronized with impl thread animations. 854 // Ensures that main thread animations have their start times synchronized with impl thread animations.
855 class CCLayerTreeHostTestAnimationFinishedEvents : public CCLayerTreeHostTest { 855 class LayerTreeHostTestAnimationFinishedEvents : public LayerTreeHostTest {
856 public: 856 public:
857 CCLayerTreeHostTestAnimationFinishedEvents() 857 LayerTreeHostTestAnimationFinishedEvents()
858 { 858 {
859 } 859 }
860 860
861 virtual void beginTest() OVERRIDE 861 virtual void beginTest() OVERRIDE
862 { 862 {
863 postAddInstantAnimationToMainThread(); 863 postAddInstantAnimationToMainThread();
864 } 864 }
865 865
866 virtual void notifyAnimationFinished(double time) OVERRIDE 866 virtual void notifyAnimationFinished(double time) OVERRIDE
867 { 867 {
868 endTest(); 868 endTest();
869 } 869 }
870 870
871 virtual void afterTest() OVERRIDE 871 virtual void afterTest() OVERRIDE
872 { 872 {
873 } 873 }
874 874
875 private: 875 private:
876 }; 876 };
877 877
878 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAnimationFinishedEvents) 878 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAnimationFinishedEvents)
879 879
880 class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTest { 880 class LayerTreeHostTestScrollSimple : public LayerTreeHostTest {
881 public: 881 public:
882 CCLayerTreeHostTestScrollSimple() 882 LayerTreeHostTestScrollSimple()
883 : m_initialScroll(IntPoint(10, 20)) 883 : m_initialScroll(IntPoint(10, 20))
884 , m_secondScroll(IntPoint(40, 5)) 884 , m_secondScroll(IntPoint(40, 5))
885 , m_scrollAmount(2, -1) 885 , m_scrollAmount(2, -1)
886 , m_scrolls(0) 886 , m_scrolls(0)
887 { 887 {
888 } 888 }
889 889
890 virtual void beginTest() OVERRIDE 890 virtual void beginTest() OVERRIDE
891 { 891 {
892 m_layerTreeHost->rootLayer()->setScrollable(true); 892 m_layerTreeHost->rootLayer()->setScrollable(true);
893 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); 893 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
894 postSetNeedsCommitToMainThread(); 894 postSetNeedsCommitToMainThread();
895 } 895 }
896 896
897 virtual void layout() OVERRIDE 897 virtual void layout() OVERRIDE
898 { 898 {
899 LayerChromium* root = m_layerTreeHost->rootLayer(); 899 Layer* root = m_layerTreeHost->rootLayer();
900 if (!m_layerTreeHost->commitNumber()) 900 if (!m_layerTreeHost->commitNumber())
901 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 901 EXPECT_EQ(root->scrollPosition(), m_initialScroll);
902 else { 902 else {
903 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount); 903 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount);
904 904
905 // Pretend like Javascript updated the scroll position itself. 905 // Pretend like Javascript updated the scroll position itself.
906 root->setScrollPosition(m_secondScroll); 906 root->setScrollPosition(m_secondScroll);
907 } 907 }
908 } 908 }
909 909
910 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 910 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
911 { 911 {
912 CCLayerImpl* root = impl->rootLayer(); 912 LayerImpl* root = impl->rootLayer();
913 EXPECT_EQ(root->scrollDelta(), IntSize()); 913 EXPECT_EQ(root->scrollDelta(), IntSize());
914 914
915 root->setScrollable(true); 915 root->setScrollable(true);
916 root->setMaxScrollPosition(IntSize(100, 100)); 916 root->setMaxScrollPosition(IntSize(100, 100));
917 root->scrollBy(m_scrollAmount); 917 root->scrollBy(m_scrollAmount);
918 918
919 if (!impl->sourceFrameNumber()) { 919 if (!impl->sourceFrameNumber()) {
920 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 920 EXPECT_EQ(root->scrollPosition(), m_initialScroll);
921 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 921 EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
922 postSetNeedsCommitToMainThread(); 922 postSetNeedsCommitToMainThread();
(...skipping 15 matching lines...) Expand all
938 { 938 {
939 EXPECT_EQ(1, m_scrolls); 939 EXPECT_EQ(1, m_scrolls);
940 } 940 }
941 private: 941 private:
942 IntPoint m_initialScroll; 942 IntPoint m_initialScroll;
943 IntPoint m_secondScroll; 943 IntPoint m_secondScroll;
944 IntSize m_scrollAmount; 944 IntSize m_scrollAmount;
945 int m_scrolls; 945 int m_scrolls;
946 }; 946 };
947 947
948 TEST_F(CCLayerTreeHostTestScrollSimple, runMultiThread) 948 TEST_F(LayerTreeHostTestScrollSimple, runMultiThread)
949 { 949 {
950 runTest(true); 950 runTest(true);
951 } 951 }
952 952
953 class CCLayerTreeHostTestScrollMultipleRedraw : public CCLayerTreeHostTest { 953 class LayerTreeHostTestScrollMultipleRedraw : public LayerTreeHostTest {
954 public: 954 public:
955 CCLayerTreeHostTestScrollMultipleRedraw() 955 LayerTreeHostTestScrollMultipleRedraw()
956 : m_initialScroll(IntPoint(40, 10)) 956 : m_initialScroll(IntPoint(40, 10))
957 , m_scrollAmount(-3, 17) 957 , m_scrollAmount(-3, 17)
958 , m_scrolls(0) 958 , m_scrolls(0)
959 { 959 {
960 } 960 }
961 961
962 virtual void beginTest() OVERRIDE 962 virtual void beginTest() OVERRIDE
963 { 963 {
964 m_layerTreeHost->rootLayer()->setScrollable(true); 964 m_layerTreeHost->rootLayer()->setScrollable(true);
965 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); 965 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll);
966 postSetNeedsCommitToMainThread(); 966 postSetNeedsCommitToMainThread();
967 } 967 }
968 968
969 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 969 virtual void beginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE
970 { 970 {
971 LayerChromium* root = m_layerTreeHost->rootLayer(); 971 Layer* root = m_layerTreeHost->rootLayer();
972 if (!m_layerTreeHost->commitNumber()) 972 if (!m_layerTreeHost->commitNumber())
973 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 973 EXPECT_EQ(root->scrollPosition(), m_initialScroll);
974 else if (m_layerTreeHost->commitNumber() == 1) 974 else if (m_layerTreeHost->commitNumber() == 1)
975 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); 975 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
976 else if (m_layerTreeHost->commitNumber() == 2) 976 else if (m_layerTreeHost->commitNumber() == 2)
977 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); 977 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
978 } 978 }
979 979
980 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 980 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
981 { 981 {
982 CCLayerImpl* root = impl->rootLayer(); 982 LayerImpl* root = impl->rootLayer();
983 root->setScrollable(true); 983 root->setScrollable(true);
984 root->setMaxScrollPosition(IntSize(100, 100)); 984 root->setMaxScrollPosition(IntSize(100, 100));
985 985
986 if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) { 986 if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) {
987 // First draw after first commit. 987 // First draw after first commit.
988 EXPECT_EQ(root->scrollDelta(), IntSize()); 988 EXPECT_EQ(root->scrollDelta(), IntSize());
989 root->scrollBy(m_scrollAmount); 989 root->scrollBy(m_scrollAmount);
990 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 990 EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
991 991
992 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 992 EXPECT_EQ(root->scrollPosition(), m_initialScroll);
(...skipping 25 matching lines...) Expand all
1018 virtual void afterTest() OVERRIDE 1018 virtual void afterTest() OVERRIDE
1019 { 1019 {
1020 EXPECT_EQ(1, m_scrolls); 1020 EXPECT_EQ(1, m_scrolls);
1021 } 1021 }
1022 private: 1022 private:
1023 IntPoint m_initialScroll; 1023 IntPoint m_initialScroll;
1024 IntSize m_scrollAmount; 1024 IntSize m_scrollAmount;
1025 int m_scrolls; 1025 int m_scrolls;
1026 }; 1026 };
1027 1027
1028 TEST_F(CCLayerTreeHostTestScrollMultipleRedraw, runMultiThread) 1028 TEST_F(LayerTreeHostTestScrollMultipleRedraw, runMultiThread)
1029 { 1029 {
1030 runTest(true); 1030 runTest(true);
1031 } 1031 }
1032 1032
1033 // This test verifies that properties on the layer tree host are commited to the impl side. 1033 // This test verifies that properties on the layer tree host are commited to the impl side.
1034 class CCLayerTreeHostTestCommit : public CCLayerTreeHostTest { 1034 class LayerTreeHostTestCommit : public LayerTreeHostTest {
1035 public: 1035 public:
1036 1036
1037 CCLayerTreeHostTestCommit() { } 1037 LayerTreeHostTestCommit() { }
1038 1038
1039 virtual void beginTest() OVERRIDE 1039 virtual void beginTest() OVERRIDE
1040 { 1040 {
1041 m_layerTreeHost->setViewportSize(IntSize(20, 20), IntSize(20, 20)); 1041 m_layerTreeHost->setViewportSize(IntSize(20, 20), IntSize(20, 20));
1042 m_layerTreeHost->setBackgroundColor(SK_ColorGRAY); 1042 m_layerTreeHost->setBackgroundColor(SK_ColorGRAY);
1043 m_layerTreeHost->setPageScaleFactorAndLimits(5, 5, 5); 1043 m_layerTreeHost->setPageScaleFactorAndLimits(5, 5, 5);
1044 1044
1045 postSetNeedsCommitToMainThread(); 1045 postSetNeedsCommitToMainThread();
1046 } 1046 }
1047 1047
1048 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1048 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1049 { 1049 {
1050 EXPECT_EQ(IntSize(20, 20), impl->layoutViewportSize()); 1050 EXPECT_EQ(IntSize(20, 20), impl->layoutViewportSize());
1051 EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor()); 1051 EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor());
1052 EXPECT_EQ(5, impl->pageScaleFactor()); 1052 EXPECT_EQ(5, impl->pageScaleFactor());
1053 1053
1054 endTest(); 1054 endTest();
1055 } 1055 }
1056 1056
1057 virtual void afterTest() OVERRIDE { } 1057 virtual void afterTest() OVERRIDE { }
1058 }; 1058 };
1059 1059
1060 TEST_F(CCLayerTreeHostTestCommit, runTest) 1060 TEST_F(LayerTreeHostTestCommit, runTest)
1061 { 1061 {
1062 runTest(true); 1062 runTest(true);
1063 } 1063 }
1064 1064
1065 // Verifies that startPageScaleAnimation events propagate correctly from CCLayer TreeHost to 1065 // Verifies that startPageScaleAnimation events propagate correctly from LayerTr eeHost to
1066 // CCLayerTreeHostImpl in the MT compositor. 1066 // LayerTreeHostImpl in the MT compositor.
1067 class CCLayerTreeHostTestStartPageScaleAnimation : public CCLayerTreeHostTest { 1067 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
1068 public: 1068 public:
1069 1069
1070 CCLayerTreeHostTestStartPageScaleAnimation() 1070 LayerTreeHostTestStartPageScaleAnimation()
1071 : m_animationRequested(false) 1071 : m_animationRequested(false)
1072 { 1072 {
1073 } 1073 }
1074 1074
1075 virtual void beginTest() OVERRIDE 1075 virtual void beginTest() OVERRIDE
1076 { 1076 {
1077 m_layerTreeHost->rootLayer()->setScrollable(true); 1077 m_layerTreeHost->rootLayer()->setScrollable(true);
1078 m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint()); 1078 m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint());
1079 postSetNeedsRedrawToMainThread(); 1079 postSetNeedsRedrawToMainThread();
1080 } 1080 }
1081 1081
1082 void requestStartPageScaleAnimation() 1082 void requestStartPageScaleAnimation()
1083 { 1083 {
1084 layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, 0); 1084 layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, 0);
1085 } 1085 }
1086 1086
1087 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1087 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1088 { 1088 {
1089 impl->rootLayer()->setScrollable(true); 1089 impl->rootLayer()->setScrollable(true);
1090 impl->rootLayer()->setScrollPosition(IntPoint()); 1090 impl->rootLayer()->setScrollPosition(IntPoint());
1091 impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2); 1091 impl->setPageScaleFactorAndLimits(impl->pageScaleFactor(), 0.5, 2);
1092 1092
1093 // We request animation only once. 1093 // We request animation only once.
1094 if (!m_animationRequested) { 1094 if (!m_animationRequested) {
1095 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCLayerTreeHos tTestStartPageScaleAnimation::requestStartPageScaleAnimation)); 1095 m_mainThreadProxy->postTask(createThreadTask(this, &LayerTreeHostTes tStartPageScaleAnimation::requestStartPageScaleAnimation));
1096 m_animationRequested = true; 1096 m_animationRequested = true;
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OV ERRIDE 1100 virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) OV ERRIDE
1101 { 1101 {
1102 IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); 1102 IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition();
1103 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); 1103 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
1104 m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2); 1104 m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2);
1105 } 1105 }
1106 1106
1107 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1107 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1108 { 1108 {
1109 impl->processScrollDeltas(); 1109 impl->processScrollDeltas();
1110 // We get one commit before the first draw, and the animation doesn't ha ppen until the second draw. 1110 // We get one commit before the first draw, and the animation doesn't ha ppen until the second draw.
1111 if (impl->sourceFrameNumber() == 1) { 1111 if (impl->sourceFrameNumber() == 1) {
1112 EXPECT_EQ(1.25, impl->pageScaleFactor()); 1112 EXPECT_EQ(1.25, impl->pageScaleFactor());
1113 endTest(); 1113 endTest();
1114 } else 1114 } else
1115 postSetNeedsRedrawToMainThread(); 1115 postSetNeedsRedrawToMainThread();
1116 } 1116 }
1117 1117
1118 virtual void afterTest() OVERRIDE 1118 virtual void afterTest() OVERRIDE
1119 { 1119 {
1120 } 1120 }
1121 1121
1122 private: 1122 private:
1123 bool m_animationRequested; 1123 bool m_animationRequested;
1124 }; 1124 };
1125 1125
1126 TEST_F(CCLayerTreeHostTestStartPageScaleAnimation, runTest) 1126 TEST_F(LayerTreeHostTestStartPageScaleAnimation, runTest)
1127 { 1127 {
1128 runTest(true); 1128 runTest(true);
1129 } 1129 }
1130 1130
1131 class CCLayerTreeHostTestSetVisible : public CCLayerTreeHostTest { 1131 class LayerTreeHostTestSetVisible : public LayerTreeHostTest {
1132 public: 1132 public:
1133 1133
1134 CCLayerTreeHostTestSetVisible() 1134 LayerTreeHostTestSetVisible()
1135 : m_numDraws(0) 1135 : m_numDraws(0)
1136 { 1136 {
1137 } 1137 }
1138 1138
1139 virtual void beginTest() OVERRIDE 1139 virtual void beginTest() OVERRIDE
1140 { 1140 {
1141 postSetVisibleToMainThread(false); 1141 postSetVisibleToMainThread(false);
1142 postSetNeedsRedrawToMainThread(); // This is suppressed while we're invi sible. 1142 postSetNeedsRedrawToMainThread(); // This is suppressed while we're invi sible.
1143 postSetVisibleToMainThread(true); // Triggers the redraw. 1143 postSetVisibleToMainThread(true); // Triggers the redraw.
1144 } 1144 }
1145 1145
1146 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1146 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1147 { 1147 {
1148 EXPECT_TRUE(impl->visible()); 1148 EXPECT_TRUE(impl->visible());
1149 ++m_numDraws; 1149 ++m_numDraws;
1150 endTest(); 1150 endTest();
1151 } 1151 }
1152 1152
1153 virtual void afterTest() OVERRIDE 1153 virtual void afterTest() OVERRIDE
1154 { 1154 {
1155 EXPECT_EQ(1, m_numDraws); 1155 EXPECT_EQ(1, m_numDraws);
1156 } 1156 }
1157 1157
1158 private: 1158 private:
1159 int m_numDraws; 1159 int m_numDraws;
1160 }; 1160 };
1161 1161
1162 TEST_F(CCLayerTreeHostTestSetVisible, runMultiThread) 1162 TEST_F(LayerTreeHostTestSetVisible, runMultiThread)
1163 { 1163 {
1164 runTest(true); 1164 runTest(true);
1165 } 1165 }
1166 1166
1167 class TestOpacityChangeLayerDelegate : public ContentLayerChromiumClient { 1167 class TestOpacityChangeLayerDelegate : public ContentLayerClient {
1168 public: 1168 public:
1169 TestOpacityChangeLayerDelegate(CCLayerTreeHostTest* test) 1169 TestOpacityChangeLayerDelegate(LayerTreeHostTest* test)
1170 : m_test(test) 1170 : m_test(test)
1171 { 1171 {
1172 } 1172 }
1173 1173
1174 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE 1174 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE
1175 { 1175 {
1176 // Set layer opacity to 0. 1176 // Set layer opacity to 0.
1177 m_test->layerTreeHost()->rootLayer()->setOpacity(0); 1177 m_test->layerTreeHost()->rootLayer()->setOpacity(0);
1178 } 1178 }
1179 1179
1180 private: 1180 private:
1181 CCLayerTreeHostTest* m_test; 1181 LayerTreeHostTest* m_test;
1182 }; 1182 };
1183 1183
1184 class ContentLayerChromiumWithUpdateTracking : public ContentLayerChromium { 1184 class ContentLayerWithUpdateTracking : public ContentLayer {
1185 public: 1185 public:
1186 static scoped_refptr<ContentLayerChromiumWithUpdateTracking> create(ContentL ayerChromiumClient* client) { return make_scoped_refptr(new ContentLayerChromium WithUpdateTracking(client)); } 1186 static scoped_refptr<ContentLayerWithUpdateTracking> create(ContentLayerClie nt* client) { return make_scoped_refptr(new ContentLayerWithUpdateTracking(clien t)); }
1187 1187
1188 int paintContentsCount() { return m_paintContentsCount; } 1188 int paintContentsCount() { return m_paintContentsCount; }
1189 void resetPaintContentsCount() { m_paintContentsCount = 0; } 1189 void resetPaintContentsCount() { m_paintContentsCount = 0; }
1190 1190
1191 virtual void update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* o cclusion, CCRenderingStats& stats) OVERRIDE 1191 virtual void update(TextureUpdateQueue& queue, const OcclusionTracker* occlu sion, RenderingStats& stats) OVERRIDE
1192 { 1192 {
1193 ContentLayerChromium::update(queue, occlusion, stats); 1193 ContentLayer::update(queue, occlusion, stats);
1194 m_paintContentsCount++; 1194 m_paintContentsCount++;
1195 } 1195 }
1196 1196
1197 private: 1197 private:
1198 explicit ContentLayerChromiumWithUpdateTracking(ContentLayerChromiumClient* client) 1198 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client)
1199 : ContentLayerChromium(client) 1199 : ContentLayer(client)
1200 , m_paintContentsCount(0) 1200 , m_paintContentsCount(0)
1201 { 1201 {
1202 setAnchorPoint(FloatPoint(0, 0)); 1202 setAnchorPoint(FloatPoint(0, 0));
1203 setBounds(IntSize(10, 10)); 1203 setBounds(IntSize(10, 10));
1204 setIsDrawable(true); 1204 setIsDrawable(true);
1205 } 1205 }
1206 virtual ~ContentLayerChromiumWithUpdateTracking() 1206 virtual ~ContentLayerWithUpdateTracking()
1207 { 1207 {
1208 } 1208 }
1209 1209
1210 int m_paintContentsCount; 1210 int m_paintContentsCount;
1211 }; 1211 };
1212 1212
1213 // Layer opacity change during paint should not prevent compositor resources fro m being updated during commit. 1213 // Layer opacity change during paint should not prevent compositor resources fro m being updated during commit.
1214 class CCLayerTreeHostTestOpacityChange : public CCLayerTreeHostTest { 1214 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
1215 public: 1215 public:
1216 CCLayerTreeHostTestOpacityChange() 1216 LayerTreeHostTestOpacityChange()
1217 : m_testOpacityChangeDelegate(this) 1217 : m_testOpacityChangeDelegate(this)
1218 , m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_t estOpacityChangeDelegate)) 1218 , m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpaci tyChangeDelegate))
1219 { 1219 {
1220 } 1220 }
1221 1221
1222 virtual void beginTest() OVERRIDE 1222 virtual void beginTest() OVERRIDE
1223 { 1223 {
1224 m_layerTreeHost->setRootLayer(m_updateCheckLayer); 1224 m_layerTreeHost->setRootLayer(m_updateCheckLayer);
1225 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 1225 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
1226 1226
1227 postSetNeedsCommitToMainThread(); 1227 postSetNeedsCommitToMainThread();
1228 } 1228 }
1229 1229
1230 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 1230 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
1231 { 1231 {
1232 endTest(); 1232 endTest();
1233 } 1233 }
1234 1234
1235 virtual void afterTest() OVERRIDE 1235 virtual void afterTest() OVERRIDE
1236 { 1236 {
1237 // update() should have been called once. 1237 // update() should have been called once.
1238 EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount()); 1238 EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount());
1239 1239
1240 // clear m_updateCheckLayer so CCLayerTreeHost dies. 1240 // clear m_updateCheckLayer so LayerTreeHost dies.
1241 m_updateCheckLayer = NULL; 1241 m_updateCheckLayer = NULL;
1242 } 1242 }
1243 1243
1244 private: 1244 private:
1245 TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate; 1245 TestOpacityChangeLayerDelegate m_testOpacityChangeDelegate;
1246 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_updateCheckLayer; 1246 scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer;
1247 }; 1247 };
1248 1248
1249 TEST_F(CCLayerTreeHostTestOpacityChange, runMultiThread) 1249 TEST_F(LayerTreeHostTestOpacityChange, runMultiThread)
1250 { 1250 {
1251 runTest(true); 1251 runTest(true);
1252 } 1252 }
1253 1253
1254 class MockContentLayerChromiumClient : public ContentLayerChromiumClient { 1254 class MockContentLayerClient : public ContentLayerClient {
1255 public: 1255 public:
1256 bool drawsContent() const { return true; } 1256 bool drawsContent() const { return true; }
1257 MOCK_CONST_METHOD0(preserves3D, bool()); 1257 MOCK_CONST_METHOD0(preserves3D, bool());
1258 void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { } 1258 void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { }
1259 void notifySyncRequired() { } 1259 void notifySyncRequired() { }
1260 }; 1260 };
1261 1261
1262 class NoScaleContentLayerChromium : public ContentLayerChromium { 1262 class NoScaleContentLayer : public ContentLayer {
1263 public: 1263 public:
1264 static scoped_refptr<NoScaleContentLayerChromium> create(ContentLayerChromiu mClient* client) { return make_scoped_refptr(new NoScaleContentLayerChromium(cli ent)); } 1264 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client) { return make_scoped_refptr(new NoScaleContentLayer(client)); }
1265 1265
1266 virtual bool needsContentsScale() const OVERRIDE { return false; } 1266 virtual bool needsContentsScale() const OVERRIDE { return false; }
1267 1267
1268 private: 1268 private:
1269 explicit NoScaleContentLayerChromium(ContentLayerChromiumClient* client) 1269 explicit NoScaleContentLayer(ContentLayerClient* client)
1270 : ContentLayerChromium(client) { } 1270 : ContentLayer(client) { }
1271 virtual ~NoScaleContentLayerChromium() { } 1271 virtual ~NoScaleContentLayer() { }
1272 }; 1272 };
1273 1273
1274 class CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public CCLay erTreeHostTest { 1274 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public LayerTr eeHostTest {
1275 public: 1275 public:
1276 1276
1277 CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() 1277 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers()
1278 : m_rootLayer(NoScaleContentLayerChromium::create(&m_client)) 1278 : m_rootLayer(NoScaleContentLayer::create(&m_client))
1279 , m_childLayer(ContentLayerChromium::create(&m_client)) 1279 , m_childLayer(ContentLayer::create(&m_client))
1280 { 1280 {
1281 } 1281 }
1282 1282
1283 virtual void beginTest() OVERRIDE 1283 virtual void beginTest() OVERRIDE
1284 { 1284 {
1285 m_layerTreeHost->setViewportSize(IntSize(40, 40), IntSize(60, 60)); 1285 m_layerTreeHost->setViewportSize(IntSize(40, 40), IntSize(60, 60));
1286 m_layerTreeHost->setDeviceScaleFactor(1.5); 1286 m_layerTreeHost->setDeviceScaleFactor(1.5);
1287 EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->layoutViewportSize()); 1287 EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->layoutViewportSize());
1288 EXPECT_EQ(IntSize(60, 60), m_layerTreeHost->deviceViewportSize()); 1288 EXPECT_EQ(IntSize(60, 60), m_layerTreeHost->deviceViewportSize());
1289 1289
1290 m_rootLayer->addChild(m_childLayer); 1290 m_rootLayer->addChild(m_childLayer);
1291 1291
1292 m_rootLayer->setIsDrawable(true); 1292 m_rootLayer->setIsDrawable(true);
1293 m_rootLayer->setBounds(IntSize(30, 30)); 1293 m_rootLayer->setBounds(IntSize(30, 30));
1294 m_rootLayer->setAnchorPoint(FloatPoint(0, 0)); 1294 m_rootLayer->setAnchorPoint(FloatPoint(0, 0));
1295 1295
1296 m_childLayer->setIsDrawable(true); 1296 m_childLayer->setIsDrawable(true);
1297 m_childLayer->setPosition(IntPoint(2, 2)); 1297 m_childLayer->setPosition(IntPoint(2, 2));
1298 m_childLayer->setBounds(IntSize(10, 10)); 1298 m_childLayer->setBounds(IntSize(10, 10));
1299 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); 1299 m_childLayer->setAnchorPoint(FloatPoint(0, 0));
1300 1300
1301 m_layerTreeHost->setRootLayer(m_rootLayer); 1301 m_layerTreeHost->setRootLayer(m_rootLayer);
1302 } 1302 }
1303 1303
1304 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1304 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1305 { 1305 {
1306 // Get access to protected methods. 1306 // Get access to protected methods.
1307 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im pl); 1307 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im pl);
1308 1308
1309 // Should only do one commit. 1309 // Should only do one commit.
1310 EXPECT_EQ(0, impl->sourceFrameNumber()); 1310 EXPECT_EQ(0, impl->sourceFrameNumber());
1311 // Device scale factor should come over to impl. 1311 // Device scale factor should come over to impl.
1312 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001); 1312 EXPECT_NEAR(impl->deviceScaleFactor(), 1.5, 0.00001);
1313 1313
1314 // Both layers are on impl. 1314 // Both layers are on impl.
1315 ASSERT_EQ(1u, impl->rootLayer()->children().size()); 1315 ASSERT_EQ(1u, impl->rootLayer()->children().size());
1316 1316
1317 // Device viewport is scaled. 1317 // Device viewport is scaled.
1318 EXPECT_EQ(IntSize(40, 40), impl->layoutViewportSize()); 1318 EXPECT_EQ(IntSize(40, 40), impl->layoutViewportSize());
1319 EXPECT_EQ(IntSize(60, 60), impl->deviceViewportSize()); 1319 EXPECT_EQ(IntSize(60, 60), impl->deviceViewportSize());
1320 1320
1321 CCLayerImpl* root = impl->rootLayer(); 1321 LayerImpl* root = impl->rootLayer();
1322 CCLayerImpl* child = impl->rootLayer()->children()[0]; 1322 LayerImpl* child = impl->rootLayer()->children()[0];
1323 1323
1324 // Positions remain in layout pixels. 1324 // Positions remain in layout pixels.
1325 EXPECT_EQ(IntPoint(0, 0), root->position()); 1325 EXPECT_EQ(IntPoint(0, 0), root->position());
1326 EXPECT_EQ(IntPoint(2, 2), child->position()); 1326 EXPECT_EQ(IntPoint(2, 2), child->position());
1327 1327
1328 // Compute all the layer transforms for the frame. 1328 // Compute all the layer transforms for the frame.
1329 MockLayerTreeHostImpl::CCLayerList renderSurfaceLayerList; 1329 MockLayerTreeHostImpl::LayerList renderSurfaceLayerList;
1330 mockImpl->calculateRenderSurfaceLayerList(renderSurfaceLayerList); 1330 mockImpl->calculateRenderSurfaceLayerList(renderSurfaceLayerList);
1331 1331
1332 // Both layers should be drawing into the root render surface. 1332 // Both layers should be drawing into the root render surface.
1333 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 1333 ASSERT_EQ(1u, renderSurfaceLayerList.size());
1334 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e()); 1334 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e());
1335 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); 1335 ASSERT_EQ(2u, root->renderSurface()->layerList().size());
1336 1336
1337 // The root render surface is the size of the viewport. 1337 // The root render surface is the size of the viewport.
1338 EXPECT_RECT_EQ(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect ()); 1338 EXPECT_RECT_EQ(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect ());
1339 1339
(...skipping 23 matching lines...) Expand all
1363 endTest(); 1363 endTest();
1364 } 1364 }
1365 1365
1366 virtual void afterTest() OVERRIDE 1366 virtual void afterTest() OVERRIDE
1367 { 1367 {
1368 m_rootLayer = NULL; 1368 m_rootLayer = NULL;
1369 m_childLayer = NULL; 1369 m_childLayer = NULL;
1370 } 1370 }
1371 1371
1372 private: 1372 private:
1373 MockContentLayerChromiumClient m_client; 1373 MockContentLayerClient m_client;
1374 scoped_refptr<NoScaleContentLayerChromium> m_rootLayer; 1374 scoped_refptr<NoScaleContentLayer> m_rootLayer;
1375 scoped_refptr<ContentLayerChromium> m_childLayer; 1375 scoped_refptr<ContentLayer> m_childLayer;
1376 }; 1376 };
1377 1377
1378 // Test is flaky - http://crbug.com/148490 1378 // Test is flaky - http://crbug.com/148490
1379 TEST_F(CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, DISABLED_run MultiThread) 1379 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, DISABLED_runMu ltiThread)
1380 { 1380 {
1381 runTest(true); 1381 runTest(true);
1382 } 1382 }
1383 1383
1384 // Verify atomicity of commits and reuse of textures. 1384 // Verify atomicity of commits and reuse of textures.
1385 class CCLayerTreeHostTestAtomicCommit : public CCLayerTreeHostTest { 1385 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest {
1386 public: 1386 public:
1387 CCLayerTreeHostTestAtomicCommit() 1387 LayerTreeHostTestAtomicCommit()
1388 : m_layer(ContentLayerChromiumWithUpdateTracking::create(&m_client)) 1388 : m_layer(ContentLayerWithUpdateTracking::create(&m_client))
1389 { 1389 {
1390 // Make sure partial texture updates are turned off. 1390 // Make sure partial texture updates are turned off.
1391 m_settings.maxPartialTextureUpdates = 0; 1391 m_settings.maxPartialTextureUpdates = 0;
1392 } 1392 }
1393 1393
1394 virtual void beginTest() OVERRIDE 1394 virtual void beginTest() OVERRIDE
1395 { 1395 {
1396 m_layerTreeHost->setRootLayer(m_layer); 1396 m_layerTreeHost->setRootLayer(m_layer);
1397 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 1397 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
1398 1398
1399 postSetNeedsCommitToMainThread(); 1399 postSetNeedsCommitToMainThread();
1400 postSetNeedsRedrawToMainThread(); 1400 postSetNeedsRedrawToMainThread();
1401 } 1401 }
1402 1402
1403 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1403 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1404 { 1404 {
1405 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1405 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D());
1406 1406
1407 switch (impl->sourceFrameNumber()) { 1407 switch (impl->sourceFrameNumber()) {
1408 case 0: 1408 case 0:
1409 // Number of textures should be one. 1409 // Number of textures should be one.
1410 ASSERT_EQ(1, context->numTextures()); 1410 ASSERT_EQ(1, context->numTextures());
1411 // Number of textures used for commit should be one. 1411 // Number of textures used for commit should be one.
1412 EXPECT_EQ(1, context->numUsedTextures()); 1412 EXPECT_EQ(1, context->numUsedTextures());
1413 // Verify that used texture is correct. 1413 // Verify that used texture is correct.
(...skipping 13 matching lines...) Expand all
1427 EXPECT_TRUE(context->usedTexture(context->texture(1))); 1427 EXPECT_TRUE(context->usedTexture(context->texture(1)));
1428 1428
1429 context->resetUsedTextures(); 1429 context->resetUsedTextures();
1430 break; 1430 break;
1431 default: 1431 default:
1432 ASSERT_NOT_REACHED(); 1432 ASSERT_NOT_REACHED();
1433 break; 1433 break;
1434 } 1434 }
1435 } 1435 }
1436 1436
1437 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1437 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1438 { 1438 {
1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D());
1440 1440
1441 // Number of textures used for draw should always be one. 1441 // Number of textures used for draw should always be one.
1442 EXPECT_EQ(1, context->numUsedTextures()); 1442 EXPECT_EQ(1, context->numUsedTextures());
1443 1443
1444 if (impl->sourceFrameNumber() < 1) { 1444 if (impl->sourceFrameNumber() < 1) {
1445 context->resetUsedTextures(); 1445 context->resetUsedTextures();
1446 postSetNeedsAnimateAndCommitToMainThread(); 1446 postSetNeedsAnimateAndCommitToMainThread();
1447 postSetNeedsRedrawToMainThread(); 1447 postSetNeedsRedrawToMainThread();
1448 } else 1448 } else
1449 endTest(); 1449 endTest();
1450 } 1450 }
1451 1451
1452 virtual void layout() OVERRIDE 1452 virtual void layout() OVERRIDE
1453 { 1453 {
1454 m_layer->setNeedsDisplay(); 1454 m_layer->setNeedsDisplay();
1455 } 1455 }
1456 1456
1457 virtual void afterTest() OVERRIDE 1457 virtual void afterTest() OVERRIDE
1458 { 1458 {
1459 } 1459 }
1460 1460
1461 private: 1461 private:
1462 MockContentLayerChromiumClient m_client; 1462 MockContentLayerClient m_client;
1463 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_layer; 1463 scoped_refptr<ContentLayerWithUpdateTracking> m_layer;
1464 }; 1464 };
1465 1465
1466 TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread) 1466 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread)
1467 { 1467 {
1468 runTest(true); 1468 runTest(true);
1469 } 1469 }
1470 1470
1471 static void setLayerPropertiesForTesting(LayerChromium* layer, LayerChromium* pa rent, const WebTransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque) 1471 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const WebT ransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& posi tion, const IntSize& bounds, bool opaque)
1472 { 1472 {
1473 layer->removeAllChildren(); 1473 layer->removeAllChildren();
1474 if (parent) 1474 if (parent)
1475 parent->addChild(layer); 1475 parent->addChild(layer);
1476 layer->setTransform(transform); 1476 layer->setTransform(transform);
1477 layer->setAnchorPoint(anchor); 1477 layer->setAnchorPoint(anchor);
1478 layer->setPosition(position); 1478 layer->setPosition(position);
1479 layer->setBounds(bounds); 1479 layer->setBounds(bounds);
1480 layer->setContentsOpaque(opaque); 1480 layer->setContentsOpaque(opaque);
1481 } 1481 }
1482 1482
1483 class CCLayerTreeHostTestAtomicCommitWithPartialUpdate : public CCLayerTreeHostT est { 1483 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest {
1484 public: 1484 public:
1485 CCLayerTreeHostTestAtomicCommitWithPartialUpdate() 1485 LayerTreeHostTestAtomicCommitWithPartialUpdate()
1486 : m_parent(ContentLayerChromiumWithUpdateTracking::create(&m_client)) 1486 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
1487 , m_child(ContentLayerChromiumWithUpdateTracking::create(&m_client)) 1487 , m_child(ContentLayerWithUpdateTracking::create(&m_client))
1488 , m_numCommits(0) 1488 , m_numCommits(0)
1489 { 1489 {
1490 // Allow one partial texture update. 1490 // Allow one partial texture update.
1491 m_settings.maxPartialTextureUpdates = 1; 1491 m_settings.maxPartialTextureUpdates = 1;
1492 } 1492 }
1493 1493
1494 virtual void beginTest() OVERRIDE 1494 virtual void beginTest() OVERRIDE
1495 { 1495 {
1496 m_layerTreeHost->setRootLayer(m_parent); 1496 m_layerTreeHost->setRootLayer(m_parent);
1497 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); 1497 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
1498 1498
1499 WebTransformationMatrix identityMatrix; 1499 WebTransformationMatrix identityMatrix;
1500 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi nt(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); 1500 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi nt(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
1501 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, FloatPoint(0, 0), FloatPoint(0, 10), IntSize(10, 10), false); 1501 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, FloatPoint(0, 0), FloatPoint(0, 10), IntSize(10, 10), false);
1502 1502
1503 postSetNeedsCommitToMainThread(); 1503 postSetNeedsCommitToMainThread();
1504 postSetNeedsRedrawToMainThread(); 1504 postSetNeedsRedrawToMainThread();
1505 } 1505 }
1506 1506
1507 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1507 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1508 { 1508 {
1509 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1509 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D());
1510 1510
1511 switch (impl->sourceFrameNumber()) { 1511 switch (impl->sourceFrameNumber()) {
1512 case 0: 1512 case 0:
1513 // Number of textures should be two. 1513 // Number of textures should be two.
1514 ASSERT_EQ(2, context->numTextures()); 1514 ASSERT_EQ(2, context->numTextures());
1515 // Number of textures used for commit should be two. 1515 // Number of textures used for commit should be two.
1516 EXPECT_EQ(2, context->numUsedTextures()); 1516 EXPECT_EQ(2, context->numUsedTextures());
1517 // Verify that used textures are correct. 1517 // Verify that used textures are correct.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 EXPECT_EQ(1, context->numUsedTextures()); 1549 EXPECT_EQ(1, context->numUsedTextures());
1550 1550
1551 context->resetUsedTextures(); 1551 context->resetUsedTextures();
1552 break; 1552 break;
1553 default: 1553 default:
1554 ASSERT_NOT_REACHED(); 1554 ASSERT_NOT_REACHED();
1555 break; 1555 break;
1556 } 1556 }
1557 } 1557 }
1558 1558
1559 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 1559 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1560 { 1560 {
1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D());
1562 1562
1563 // Number of textures used for drawing should two except for frame 4 1563 // Number of textures used for drawing should two except for frame 4
1564 // where the viewport only contains one layer. 1564 // where the viewport only contains one layer.
1565 if (impl->sourceFrameNumber() == 3) 1565 if (impl->sourceFrameNumber() == 3)
1566 EXPECT_EQ(1, context->numUsedTextures()); 1566 EXPECT_EQ(1, context->numUsedTextures());
1567 else 1567 else
1568 EXPECT_EQ(2, context->numUsedTextures()); 1568 EXPECT_EQ(2, context->numUsedTextures());
1569 1569
(...skipping 29 matching lines...) Expand all
1599 ASSERT_NOT_REACHED(); 1599 ASSERT_NOT_REACHED();
1600 break; 1600 break;
1601 } 1601 }
1602 } 1602 }
1603 1603
1604 virtual void afterTest() OVERRIDE 1604 virtual void afterTest() OVERRIDE
1605 { 1605 {
1606 } 1606 }
1607 1607
1608 private: 1608 private:
1609 MockContentLayerChromiumClient m_client; 1609 MockContentLayerClient m_client;
1610 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_parent; 1610 scoped_refptr<ContentLayerWithUpdateTracking> m_parent;
1611 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_child; 1611 scoped_refptr<ContentLayerWithUpdateTracking> m_child;
1612 int m_numCommits; 1612 int m_numCommits;
1613 }; 1613 };
1614 1614
1615 TEST_F(CCLayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) 1615 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread)
1616 { 1616 {
1617 runTest(true); 1617 runTest(true);
1618 } 1618 }
1619 1619
1620 class TestLayerChromium : public LayerChromium { 1620 class TestLayer : public Layer {
1621 public: 1621 public:
1622 static scoped_refptr<TestLayerChromium> create() { return make_scoped_refptr (new TestLayerChromium()); } 1622 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes tLayer()); }
1623 1623
1624 virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker* occlusi on, CCRenderingStats&) OVERRIDE 1624 virtual void update(TextureUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE
1625 { 1625 {
1626 // Gain access to internals of the CCOcclusionTracker. 1626 // Gain access to internals of the OcclusionTracker.
1627 const TestCCOcclusionTracker* testOcclusion = static_cast<const TestCCOc clusionTracker*>(occlusion); 1627 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus ionTracker*>(occlusion);
1628 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen Space() : Region(); 1628 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen Space() : Region();
1629 } 1629 }
1630 1630
1631 virtual bool drawsContent() const OVERRIDE { return true; } 1631 virtual bool drawsContent() const OVERRIDE { return true; }
1632 1632
1633 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } 1633 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; }
1634 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); } 1634 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); }
1635 1635
1636 private: 1636 private:
1637 TestLayerChromium() : LayerChromium() { } 1637 TestLayer() : Layer() { }
1638 virtual ~TestLayerChromium() { } 1638 virtual ~TestLayer() { }
1639 1639
1640 Region m_occludedScreenSpace; 1640 Region m_occludedScreenSpace;
1641 }; 1641 };
1642 1642
1643 static void setTestLayerPropertiesForTesting(TestLayerChromium* layer, LayerChro mium* parent, const WebTransformationMatrix& transform, const FloatPoint& anchor , const FloatPoint& position, const IntSize& bounds, bool opaque) 1643 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co nst WebTransformationMatrix& transform, const FloatPoint& anchor, const FloatPoi nt& position, const IntSize& bounds, bool opaque)
1644 { 1644 {
1645 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque); 1645 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque);
1646 layer->clearOccludedScreenSpace(); 1646 layer->clearOccludedScreenSpace();
1647 } 1647 }
1648 1648
1649 class CCLayerTreeHostTestLayerOcclusion : public CCLayerTreeHostTest { 1649 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest {
1650 public: 1650 public:
1651 CCLayerTreeHostTestLayerOcclusion() { } 1651 LayerTreeHostTestLayerOcclusion() { }
1652 1652
1653 virtual void beginTest() OVERRIDE 1653 virtual void beginTest() OVERRIDE
1654 { 1654 {
1655 scoped_refptr<TestLayerChromium> rootLayer = TestLayerChromium::create() ; 1655 scoped_refptr<TestLayer> rootLayer = TestLayer::create();
1656 scoped_refptr<TestLayerChromium> child = TestLayerChromium::create(); 1656 scoped_refptr<TestLayer> child = TestLayer::create();
1657 scoped_refptr<TestLayerChromium> child2 = TestLayerChromium::create(); 1657 scoped_refptr<TestLayer> child2 = TestLayer::create();
1658 scoped_refptr<TestLayerChromium> grandChild = TestLayerChromium::create( ); 1658 scoped_refptr<TestLayer> grandChild = TestLayer::create();
1659 scoped_refptr<TestLayerChromium> mask = TestLayerChromium::create(); 1659 scoped_refptr<TestLayer> mask = TestLayer::create();
1660 1660
1661 WebTransformationMatrix identityMatrix; 1661 WebTransformationMatrix identityMatrix;
1662 WebTransformationMatrix childTransform; 1662 WebTransformationMatrix childTransform;
1663 childTransform.translate(250, 250); 1663 childTransform.translate(250, 250);
1664 childTransform.rotate(90); 1664 childTransform.rotate(90);
1665 childTransform.translate(-250, -250); 1665 childTransform.translate(-250, -250);
1666 1666
1667 child->setMasksToBounds(true); 1667 child->setMasksToBounds(true);
1668 1668
1669 // See CCLayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotate dSurface for a nice visual of these layers and how they end up 1669 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS urface for a nice visual of these layers and how they end up
1670 // positioned on the screen. 1670 // positioned on the screen.
1671 1671
1672 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer 1672 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer
1673 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); 1673 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true);
1674 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); 1674 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);
1675 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); 1675 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
1676 1676
1677 m_layerTreeHost->setRootLayer(rootLayer); 1677 m_layerTreeHost->setRootLayer(rootLayer);
1678 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1678 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1679 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1679 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1680 CCTextureUpdateQueue queue; 1680 TextureUpdateQueue queue;
1681 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1681 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1682 m_layerTreeHost->commitComplete(); 1682 m_layerTreeHost->commitComplete();
1683 1683
1684 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds()); 1684 EXPECT_RECT_EQ(IntRect(), grandChild->occludedScreenSpace().bounds());
1685 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); 1685 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());
1686 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds()); 1686 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds());
1687 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); 1687 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());
1688 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), rootLayer->occludedScreenSpace ().bounds()); 1688 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), rootLayer->occludedScreenSpace ().bounds());
1689 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); 1689 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());
1690 1690
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 m_layerTreeHost.reset(); 1840 m_layerTreeHost.reset();
1841 1841
1842 endTest(); 1842 endTest();
1843 } 1843 }
1844 1844
1845 virtual void afterTest() OVERRIDE 1845 virtual void afterTest() OVERRIDE
1846 { 1846 {
1847 } 1847 }
1848 }; 1848 };
1849 1849
1850 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion) 1850 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusion)
1851 1851
1852 class CCLayerTreeHostTestLayerOcclusionWithFilters : public CCLayerTreeHostTest { 1852 class LayerTreeHostTestLayerOcclusionWithFilters : public LayerTreeHostTest {
1853 public: 1853 public:
1854 CCLayerTreeHostTestLayerOcclusionWithFilters() { } 1854 LayerTreeHostTestLayerOcclusionWithFilters() { }
1855 1855
1856 virtual void beginTest() OVERRIDE 1856 virtual void beginTest() OVERRIDE
1857 { 1857 {
1858 scoped_refptr<TestLayerChromium> rootLayer = TestLayerChromium::create() ; 1858 scoped_refptr<TestLayer> rootLayer = TestLayer::create();
1859 scoped_refptr<TestLayerChromium> child = TestLayerChromium::create(); 1859 scoped_refptr<TestLayer> child = TestLayer::create();
1860 scoped_refptr<TestLayerChromium> child2 = TestLayerChromium::create(); 1860 scoped_refptr<TestLayer> child2 = TestLayer::create();
1861 scoped_refptr<TestLayerChromium> grandChild = TestLayerChromium::create( ); 1861 scoped_refptr<TestLayer> grandChild = TestLayer::create();
1862 scoped_refptr<TestLayerChromium> mask = TestLayerChromium::create(); 1862 scoped_refptr<TestLayer> mask = TestLayer::create();
1863 1863
1864 WebTransformationMatrix identityMatrix; 1864 WebTransformationMatrix identityMatrix;
1865 WebTransformationMatrix childTransform; 1865 WebTransformationMatrix childTransform;
1866 childTransform.translate(250, 250); 1866 childTransform.translate(250, 250);
1867 childTransform.rotate(90); 1867 childTransform.rotate(90);
1868 childTransform.translate(-250, -250); 1868 childTransform.translate(-250, -250);
1869 1869
1870 child->setMasksToBounds(true); 1870 child->setMasksToBounds(true);
1871 1871
1872 // If the child layer has a filter that changes alpha values, and is bel ow child2, then child2 should contribute to occlusion on everything, 1872 // If the child layer has a filter that changes alpha values, and is bel ow child2, then child2 should contribute to occlusion on everything,
1873 // and child shouldn't contribute to the rootLayer 1873 // and child shouldn't contribute to the rootLayer
1874 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); 1874 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true);
1875 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); 1875 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);
1876 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); 1876 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);
1877 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); 1877 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);
1878 1878
1879 { 1879 {
1880 WebFilterOperations filters; 1880 WebFilterOperations filters;
1881 filters.append(WebFilterOperation::createOpacityFilter(0.5)); 1881 filters.append(WebFilterOperation::createOpacityFilter(0.5));
1882 child->setFilters(filters); 1882 child->setFilters(filters);
1883 } 1883 }
1884 1884
1885 m_layerTreeHost->setRootLayer(rootLayer); 1885 m_layerTreeHost->setRootLayer(rootLayer);
1886 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1886 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1887 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1887 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1888 CCTextureUpdateQueue queue; 1888 TextureUpdateQueue queue;
1889 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1889 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1890 m_layerTreeHost->commitComplete(); 1890 m_layerTreeHost->commitComplete();
1891 1891
1892 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds()); 1892 EXPECT_RECT_EQ(IntRect(), child2->occludedScreenSpace().bounds());
1893 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); 1893 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());
1894 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac e().bounds()); 1894 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), grandChild->occludedScreenSpac e().bounds());
1895 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); 1895 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size());
1896 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b ounds()); 1896 EXPECT_RECT_EQ(IntRect(10, 40, 190, 160), child->occludedScreenSpace().b ounds());
1897 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); 1897 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size());
1898 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds()); 1898 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds());
(...skipping 23 matching lines...) Expand all
1922 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); 1922 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());
1923 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds()); 1923 EXPECT_RECT_EQ(IntRect(30, 40, 170, 160), child->occludedScreenSpace().b ounds());
1924 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); 1924 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());
1925 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds()); 1925 EXPECT_RECT_EQ(IntRect(10, 70, 190, 130), rootLayer->occludedScreenSpace ().bounds());
1926 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); 1926 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());
1927 1927
1928 // Kill the layerTreeHost immediately. 1928 // Kill the layerTreeHost immediately.
1929 m_layerTreeHost->setRootLayer(0); 1929 m_layerTreeHost->setRootLayer(0);
1930 m_layerTreeHost.reset(); 1930 m_layerTreeHost.reset();
1931 1931
1932 CCLayerTreeHost::setNeedsFilterContext(false); 1932 LayerTreeHost::setNeedsFilterContext(false);
1933 endTest(); 1933 endTest();
1934 } 1934 }
1935 1935
1936 virtual void afterTest() OVERRIDE 1936 virtual void afterTest() OVERRIDE
1937 { 1937 {
1938 } 1938 }
1939 }; 1939 };
1940 1940
1941 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusionWithFilters) 1941 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusionWithFilters)
1942 1942
1943 class CCLayerTreeHostTestManySurfaces : public CCLayerTreeHostTest { 1943 class LayerTreeHostTestManySurfaces : public LayerTreeHostTest {
1944 public: 1944 public:
1945 CCLayerTreeHostTestManySurfaces() { } 1945 LayerTreeHostTestManySurfaces() { }
1946 1946
1947 virtual void beginTest() OVERRIDE 1947 virtual void beginTest() OVERRIDE
1948 { 1948 {
1949 // We create enough RenderSurfaces that it will trigger Vector reallocat ion while computing occlusion. 1949 // We create enough RenderSurfaces that it will trigger Vector reallocat ion while computing occlusion.
1950 Region occluded; 1950 Region occluded;
1951 const WebTransformationMatrix identityMatrix; 1951 const WebTransformationMatrix identityMatrix;
1952 std::vector<scoped_refptr<TestLayerChromium> > layers; 1952 std::vector<scoped_refptr<TestLayer> > layers;
1953 std::vector<scoped_refptr<TestLayerChromium> > children; 1953 std::vector<scoped_refptr<TestLayer> > children;
1954 int numSurfaces = 20; 1954 int numSurfaces = 20;
1955 scoped_refptr<TestLayerChromium> replica = TestLayerChromium::create(); 1955 scoped_refptr<TestLayer> replica = TestLayer::create();
1956 1956
1957 for (int i = 0; i < numSurfaces; ++i) { 1957 for (int i = 0; i < numSurfaces; ++i) {
1958 layers.push_back(TestLayerChromium::create()); 1958 layers.push_back(TestLayer::create());
1959 if (!i) { 1959 if (!i) {
1960 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true); 1960 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(200, 200), true);
1961 layers.back()->createRenderSurface(); 1961 layers.back()->createRenderSurface();
1962 } else { 1962 } else {
1963 setTestLayerPropertiesForTesting(layers.back().get(), layers[lay ers.size()-2].get(), identityMatrix, FloatPoint(0, 0), FloatPoint(1, 1), IntSize (200-i, 200-i), true); 1963 setTestLayerPropertiesForTesting(layers.back().get(), layers[lay ers.size()-2].get(), identityMatrix, FloatPoint(0, 0), FloatPoint(1, 1), IntSize (200-i, 200-i), true);
1964 layers.back()->setMasksToBounds(true); 1964 layers.back()->setMasksToBounds(true);
1965 layers.back()->setReplicaLayer(replica.get()); // Make it have a RenderSurface 1965 layers.back()->setReplicaLayer(replica.get()); // Make it have a RenderSurfaceImpl
1966 } 1966 }
1967 } 1967 }
1968 1968
1969 for (int i = 1; i < numSurfaces; ++i) { 1969 for (int i = 1; i < numSurfaces; ++i) {
1970 children.push_back(TestLayerChromium::create()); 1970 children.push_back(TestLayer::create());
1971 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge t(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), fals e); 1971 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge t(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), fals e);
1972 } 1972 }
1973 1973
1974 m_layerTreeHost->setRootLayer(layers[0].get()); 1974 m_layerTreeHost->setRootLayer(layers[0].get());
1975 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( )); 1975 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( ));
1976 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1976 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1977 CCTextureUpdateQueue queue; 1977 TextureUpdateQueue queue;
1978 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1978 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1979 m_layerTreeHost->commitComplete(); 1979 m_layerTreeHost->commitComplete();
1980 1980
1981 for (int i = 0; i < numSurfaces-1; ++i) { 1981 for (int i = 0; i < numSurfaces-1; ++i) {
1982 IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); 1982 IntRect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1);
1983 1983
1984 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b ounds()); 1984 EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().b ounds());
1985 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size()); 1985 EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size());
1986 } 1986 }
1987 1987
1988 // Kill the layerTreeHost immediately. 1988 // Kill the layerTreeHost immediately.
1989 m_layerTreeHost->setRootLayer(0); 1989 m_layerTreeHost->setRootLayer(0);
1990 m_layerTreeHost.reset(); 1990 m_layerTreeHost.reset();
1991 1991
1992 endTest(); 1992 endTest();
1993 } 1993 }
1994 1994
1995 virtual void afterTest() OVERRIDE 1995 virtual void afterTest() OVERRIDE
1996 { 1996 {
1997 } 1997 }
1998 }; 1998 };
1999 1999
2000 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestManySurfaces) 2000 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces)
2001 2001
2002 // A loseContext(1) should lead to a didRecreateOutputSurface(true) 2002 // A loseContext(1) should lead to a didRecreateOutputSurface(true)
2003 class CCLayerTreeHostTestSetSingleLostContext : public CCLayerTreeHostTest { 2003 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest {
2004 public: 2004 public:
2005 CCLayerTreeHostTestSetSingleLostContext() 2005 LayerTreeHostTestSetSingleLostContext()
2006 { 2006 {
2007 } 2007 }
2008 2008
2009 virtual void beginTest() OVERRIDE 2009 virtual void beginTest() OVERRIDE
2010 { 2010 {
2011 postSetNeedsCommitToMainThread(); 2011 postSetNeedsCommitToMainThread();
2012 } 2012 }
2013 2013
2014 virtual void didCommitAndDrawFrame() OVERRIDE 2014 virtual void didCommitAndDrawFrame() OVERRIDE
2015 { 2015 {
2016 m_layerTreeHost->loseContext(1); 2016 m_layerTreeHost->loseContext(1);
2017 } 2017 }
2018 2018
2019 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE 2019 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
2020 { 2020 {
2021 EXPECT_TRUE(succeeded); 2021 EXPECT_TRUE(succeeded);
2022 endTest(); 2022 endTest();
2023 } 2023 }
2024 2024
2025 virtual void afterTest() OVERRIDE 2025 virtual void afterTest() OVERRIDE
2026 { 2026 {
2027 } 2027 }
2028 }; 2028 };
2029 2029
2030 TEST_F(CCLayerTreeHostTestSetSingleLostContext, runMultiThread) 2030 TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread)
2031 { 2031 {
2032 runTest(true); 2032 runTest(true);
2033 } 2033 }
2034 2034
2035 // A loseContext(10) should lead to a didRecreateOutputSurface(false), and 2035 // A loseContext(10) should lead to a didRecreateOutputSurface(false), and
2036 // a finishAllRendering() should not hang. 2036 // a finishAllRendering() should not hang.
2037 class CCLayerTreeHostTestSetRepeatedLostContext : public CCLayerTreeHostTest { 2037 class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest {
2038 public: 2038 public:
2039 CCLayerTreeHostTestSetRepeatedLostContext() 2039 LayerTreeHostTestSetRepeatedLostContext()
2040 { 2040 {
2041 } 2041 }
2042 2042
2043 virtual void beginTest() OVERRIDE 2043 virtual void beginTest() OVERRIDE
2044 { 2044 {
2045 postSetNeedsCommitToMainThread(); 2045 postSetNeedsCommitToMainThread();
2046 } 2046 }
2047 2047
2048 virtual void didCommitAndDrawFrame() OVERRIDE 2048 virtual void didCommitAndDrawFrame() OVERRIDE
2049 { 2049 {
2050 m_layerTreeHost->loseContext(10); 2050 m_layerTreeHost->loseContext(10);
2051 } 2051 }
2052 2052
2053 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE 2053 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
2054 { 2054 {
2055 EXPECT_FALSE(succeeded); 2055 EXPECT_FALSE(succeeded);
2056 m_layerTreeHost->finishAllRendering(); 2056 m_layerTreeHost->finishAllRendering();
2057 endTest(); 2057 endTest();
2058 } 2058 }
2059 2059
2060 virtual void afterTest() OVERRIDE 2060 virtual void afterTest() OVERRIDE
2061 { 2061 {
2062 } 2062 }
2063 }; 2063 };
2064 2064
2065 TEST_F(CCLayerTreeHostTestSetRepeatedLostContext, runMultiThread) 2065 TEST_F(LayerTreeHostTestSetRepeatedLostContext, runMultiThread)
2066 { 2066 {
2067 runTest(true); 2067 runTest(true);
2068 } 2068 }
2069 2069
2070 class CCLayerTreeHostTestFractionalScroll : public CCLayerTreeHostTest { 2070 class LayerTreeHostTestFractionalScroll : public LayerTreeHostTest {
2071 public: 2071 public:
2072 CCLayerTreeHostTestFractionalScroll() 2072 LayerTreeHostTestFractionalScroll()
2073 : m_scrollAmount(1.75, 0) 2073 : m_scrollAmount(1.75, 0)
2074 { 2074 {
2075 } 2075 }
2076 2076
2077 virtual void beginTest() OVERRIDE 2077 virtual void beginTest() OVERRIDE
2078 { 2078 {
2079 m_layerTreeHost->rootLayer()->setScrollable(true); 2079 m_layerTreeHost->rootLayer()->setScrollable(true);
2080 postSetNeedsCommitToMainThread(); 2080 postSetNeedsCommitToMainThread();
2081 } 2081 }
2082 2082
2083 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2083 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2084 { 2084 {
2085 CCLayerImpl* root = impl->rootLayer(); 2085 LayerImpl* root = impl->rootLayer();
2086 root->setMaxScrollPosition(IntSize(100, 100)); 2086 root->setMaxScrollPosition(IntSize(100, 100));
2087 2087
2088 // Check that a fractional scroll delta is correctly accumulated over mu ltiple commits. 2088 // Check that a fractional scroll delta is correctly accumulated over mu ltiple commits.
2089 if (!impl->sourceFrameNumber()) { 2089 if (!impl->sourceFrameNumber()) {
2090 EXPECT_EQ(root->scrollPosition(), IntPoint(0, 0)); 2090 EXPECT_EQ(root->scrollPosition(), IntPoint(0, 0));
2091 EXPECT_EQ(root->scrollDelta(), FloatSize(0, 0)); 2091 EXPECT_EQ(root->scrollDelta(), FloatSize(0, 0));
2092 postSetNeedsCommitToMainThread(); 2092 postSetNeedsCommitToMainThread();
2093 } else if (impl->sourceFrameNumber() == 1) { 2093 } else if (impl->sourceFrameNumber() == 1) {
2094 EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount)); 2094 EXPECT_EQ(root->scrollPosition(), flooredIntPoint(m_scrollAmount));
2095 EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(m_scrollAmount.width() , 1), 0)); 2095 EXPECT_EQ(root->scrollDelta(), FloatSize(fmod(m_scrollAmount.width() , 1), 0));
(...skipping 12 matching lines...) Expand all
2108 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); 2108 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta);
2109 } 2109 }
2110 2110
2111 virtual void afterTest() OVERRIDE 2111 virtual void afterTest() OVERRIDE
2112 { 2112 {
2113 } 2113 }
2114 private: 2114 private:
2115 FloatSize m_scrollAmount; 2115 FloatSize m_scrollAmount;
2116 }; 2116 };
2117 2117
2118 TEST_F(CCLayerTreeHostTestFractionalScroll, runMultiThread) 2118 TEST_F(LayerTreeHostTestFractionalScroll, runMultiThread)
2119 { 2119 {
2120 runTest(true); 2120 runTest(true);
2121 } 2121 }
2122 2122
2123 class CCLayerTreeHostTestFinishAllRendering : public CCLayerTreeHostTest { 2123 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
2124 public: 2124 public:
2125 CCLayerTreeHostTestFinishAllRendering() 2125 LayerTreeHostTestFinishAllRendering()
2126 : m_once(false) 2126 : m_once(false)
2127 , m_drawCount(0) 2127 , m_drawCount(0)
2128 { 2128 {
2129 } 2129 }
2130 2130
2131 virtual void beginTest() OVERRIDE 2131 virtual void beginTest() OVERRIDE
2132 { 2132 {
2133 m_layerTreeHost->setNeedsRedraw(); 2133 m_layerTreeHost->setNeedsRedraw();
2134 } 2134 }
2135 2135
2136 virtual void didCommitAndDrawFrame() OVERRIDE 2136 virtual void didCommitAndDrawFrame() OVERRIDE
2137 { 2137 {
2138 if (m_once) 2138 if (m_once)
2139 return; 2139 return;
2140 m_once = true; 2140 m_once = true;
2141 m_layerTreeHost->setNeedsRedraw(); 2141 m_layerTreeHost->setNeedsRedraw();
2142 m_layerTreeHost->acquireLayerTextures(); 2142 m_layerTreeHost->acquireLayerTextures();
2143 { 2143 {
2144 base::AutoLock lock(m_lock); 2144 base::AutoLock lock(m_lock);
2145 m_drawCount = 0; 2145 m_drawCount = 0;
2146 } 2146 }
2147 m_layerTreeHost->finishAllRendering(); 2147 m_layerTreeHost->finishAllRendering();
2148 { 2148 {
2149 base::AutoLock lock(m_lock); 2149 base::AutoLock lock(m_lock);
2150 EXPECT_EQ(0, m_drawCount); 2150 EXPECT_EQ(0, m_drawCount);
2151 } 2151 }
2152 endTest(); 2152 endTest();
2153 } 2153 }
2154 2154
2155 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2155 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2156 { 2156 {
2157 base::AutoLock lock(m_lock); 2157 base::AutoLock lock(m_lock);
2158 ++m_drawCount; 2158 ++m_drawCount;
2159 } 2159 }
2160 2160
2161 virtual void afterTest() OVERRIDE 2161 virtual void afterTest() OVERRIDE
2162 { 2162 {
2163 } 2163 }
2164 private: 2164 private:
2165 2165
2166 bool m_once; 2166 bool m_once;
2167 base::Lock m_lock; 2167 base::Lock m_lock;
2168 int m_drawCount; 2168 int m_drawCount;
2169 }; 2169 };
2170 2170
2171 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestFinishAllRendering) 2171 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFinishAllRendering)
2172 2172
2173 // Layers added to tree with existing active animations should have the animatio n 2173 // Layers added to tree with existing active animations should have the animatio n
2174 // correctly recognized. 2174 // correctly recognized.
2175 class CCLayerTreeHostTestLayerAddedWithAnimation : public CCLayerTreeHostTest { 2175 class LayerTreeHostTestLayerAddedWithAnimation : public LayerTreeHostTest {
2176 public: 2176 public:
2177 CCLayerTreeHostTestLayerAddedWithAnimation() 2177 LayerTreeHostTestLayerAddedWithAnimation()
2178 : m_addedAnimation(false) 2178 : m_addedAnimation(false)
2179 { 2179 {
2180 } 2180 }
2181 2181
2182 virtual void beginTest() OVERRIDE 2182 virtual void beginTest() OVERRIDE
2183 { 2183 {
2184 EXPECT_FALSE(m_addedAnimation); 2184 EXPECT_FALSE(m_addedAnimation);
2185 2185
2186 scoped_refptr<LayerChromium> layer = LayerChromium::create(); 2186 scoped_refptr<Layer> layer = Layer::create();
2187 layer->setLayerAnimationDelegate(this); 2187 layer->setLayerAnimationDelegate(this);
2188 2188
2189 // Any valid CCAnimationCurve will do here. 2189 // Any valid AnimationCurve will do here.
2190 scoped_ptr<CCAnimationCurve> curve(CCEaseTimingFunction::create()); 2190 scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create());
2191 scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve. Pass(), 1, 1, CCActiveAnimation::Opacity)); 2191 scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.Pass (), 1, 1, ActiveAnimation::Opacity));
2192 layer->layerAnimationController()->addAnimation(animation.Pass()); 2192 layer->layerAnimationController()->addAnimation(animation.Pass());
2193 2193
2194 // We add the animation *before* attaching the layer to the tree. 2194 // We add the animation *before* attaching the layer to the tree.
2195 m_layerTreeHost->rootLayer()->addChild(layer); 2195 m_layerTreeHost->rootLayer()->addChild(layer);
2196 EXPECT_TRUE(m_addedAnimation); 2196 EXPECT_TRUE(m_addedAnimation);
2197 2197
2198 endTest(); 2198 endTest();
2199 } 2199 }
2200 2200
2201 virtual void didAddAnimation() OVERRIDE 2201 virtual void didAddAnimation() OVERRIDE
2202 { 2202 {
2203 m_addedAnimation = true; 2203 m_addedAnimation = true;
2204 } 2204 }
2205 2205
2206 virtual void afterTest() OVERRIDE { } 2206 virtual void afterTest() OVERRIDE { }
2207 2207
2208 private: 2208 private:
2209 bool m_addedAnimation; 2209 bool m_addedAnimation;
2210 }; 2210 };
2211 2211
2212 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation) 2212 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerAddedWithAnimation)
2213 2213
2214 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public W ebLayerScrollClient { 2214 class LayerTreeHostTestScrollChildLayer : public LayerTreeHostTest, public WebLa yerScrollClient {
2215 public: 2215 public:
2216 CCLayerTreeHostTestScrollChildLayer() 2216 LayerTreeHostTestScrollChildLayer()
2217 : m_scrollAmount(2, 1) 2217 : m_scrollAmount(2, 1)
2218 { 2218 {
2219 } 2219 }
2220 2220
2221 virtual void beginTest() OVERRIDE 2221 virtual void beginTest() OVERRIDE
2222 { 2222 {
2223 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 2223 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
2224 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); 2224 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
2225 2225
2226 m_rootScrollLayer = ContentLayerChromium::create(&m_mockDelegate); 2226 m_rootScrollLayer = ContentLayer::create(&m_mockDelegate);
2227 m_rootScrollLayer->setBounds(IntSize(10, 10)); 2227 m_rootScrollLayer->setBounds(IntSize(10, 10));
2228 2228
2229 m_rootScrollLayer->setPosition(FloatPoint(0, 0)); 2229 m_rootScrollLayer->setPosition(FloatPoint(0, 0));
2230 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0)); 2230 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0));
2231 2231
2232 m_rootScrollLayer->setIsDrawable(true); 2232 m_rootScrollLayer->setIsDrawable(true);
2233 m_rootScrollLayer->setScrollable(true); 2233 m_rootScrollLayer->setScrollable(true);
2234 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); 2234 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
2235 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); 2235 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
2236 m_childLayer = ContentLayerChromium::create(&m_mockDelegate); 2236 m_childLayer = ContentLayer::create(&m_mockDelegate);
2237 m_childLayer->setLayerScrollClient(this); 2237 m_childLayer->setLayerScrollClient(this);
2238 m_childLayer->setBounds(IntSize(50, 50)); 2238 m_childLayer->setBounds(IntSize(50, 50));
2239 m_childLayer->setIsDrawable(true); 2239 m_childLayer->setIsDrawable(true);
2240 m_childLayer->setScrollable(true); 2240 m_childLayer->setScrollable(true);
2241 m_childLayer->setMaxScrollPosition(IntSize(100, 100)); 2241 m_childLayer->setMaxScrollPosition(IntSize(100, 100));
2242 2242
2243 m_childLayer->setPosition(FloatPoint(0, 0)); 2243 m_childLayer->setPosition(FloatPoint(0, 0));
2244 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); 2244 m_childLayer->setAnchorPoint(FloatPoint(0, 0));
2245 2245
2246 m_rootScrollLayer->addChild(m_childLayer); 2246 m_rootScrollLayer->addChild(m_childLayer);
2247 postSetNeedsCommitToMainThread(); 2247 postSetNeedsCommitToMainThread();
2248 } 2248 }
2249 2249
2250 virtual void didScroll() OVERRIDE 2250 virtual void didScroll() OVERRIDE
2251 { 2251 {
2252 m_finalScrollPosition = m_childLayer->scrollPosition(); 2252 m_finalScrollPosition = m_childLayer->scrollPosition();
2253 } 2253 }
2254 2254
2255 virtual void applyScrollAndScale(const IntSize& scrollDelta, float) OVERRIDE 2255 virtual void applyScrollAndScale(const IntSize& scrollDelta, float) OVERRIDE
2256 { 2256 {
2257 IntPoint position = m_rootScrollLayer->scrollPosition(); 2257 IntPoint position = m_rootScrollLayer->scrollPosition();
2258 m_rootScrollLayer->setScrollPosition(position + scrollDelta); 2258 m_rootScrollLayer->setScrollPosition(position + scrollDelta);
2259 } 2259 }
2260 2260
2261 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2261 virtual void beginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE
2262 { 2262 {
2263 EXPECT_EQ(m_rootScrollLayer->scrollPosition(), IntPoint()); 2263 EXPECT_EQ(m_rootScrollLayer->scrollPosition(), IntPoint());
2264 if (!m_layerTreeHost->commitNumber()) 2264 if (!m_layerTreeHost->commitNumber())
2265 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint()); 2265 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint());
2266 else 2266 else
2267 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint() + m_scrollAmoun t); 2267 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint() + m_scrollAmoun t);
2268 } 2268 }
2269 2269
2270 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2270 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2271 { 2271 {
2272 if (impl->sourceAnimationFrameNumber() == 1) { 2272 if (impl->sourceAnimationFrameNumber() == 1) {
2273 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wh eel), CCInputHandlerClient::ScrollStarted); 2273 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
2274 impl->scrollBy(IntPoint(), m_scrollAmount); 2274 impl->scrollBy(IntPoint(), m_scrollAmount);
2275 impl->scrollEnd(); 2275 impl->scrollEnd();
2276 } else if (impl->sourceAnimationFrameNumber() == 2) 2276 } else if (impl->sourceAnimationFrameNumber() == 2)
2277 endTest(); 2277 endTest();
2278 } 2278 }
2279 2279
2280 virtual void afterTest() OVERRIDE 2280 virtual void afterTest() OVERRIDE
2281 { 2281 {
2282 EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition); 2282 EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition);
2283 } 2283 }
2284 2284
2285 private: 2285 private:
2286 const IntSize m_scrollAmount; 2286 const IntSize m_scrollAmount;
2287 IntPoint m_finalScrollPosition; 2287 IntPoint m_finalScrollPosition;
2288 MockContentLayerChromiumClient m_mockDelegate; 2288 MockContentLayerClient m_mockDelegate;
2289 scoped_refptr<LayerChromium> m_childLayer; 2289 scoped_refptr<Layer> m_childLayer;
2290 scoped_refptr<LayerChromium> m_rootScrollLayer; 2290 scoped_refptr<Layer> m_rootScrollLayer;
2291 }; 2291 };
2292 2292
2293 TEST_F(CCLayerTreeHostTestScrollChildLayer, runMultiThread) 2293 TEST_F(LayerTreeHostTestScrollChildLayer, runMultiThread)
2294 { 2294 {
2295 runTest(true); 2295 runTest(true);
2296 } 2296 }
2297 2297
2298 class CCLayerTreeHostTestCompositeAndReadbackCleanup : public CCLayerTreeHostTes t { 2298 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest {
2299 public: 2299 public:
2300 CCLayerTreeHostTestCompositeAndReadbackCleanup() { } 2300 LayerTreeHostTestCompositeAndReadbackCleanup() { }
2301 2301
2302 virtual void beginTest() OVERRIDE 2302 virtual void beginTest() OVERRIDE
2303 { 2303 {
2304 LayerChromium* rootLayer = m_layerTreeHost->rootLayer(); 2304 Layer* rootLayer = m_layerTreeHost->rootLayer();
2305 2305
2306 scoped_array<char> pixels(new char[4]); 2306 scoped_array<char> pixels(new char[4]);
2307 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get()), IntRect(0, 0, 1, 1)); 2307 m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get()), IntRect(0, 0, 1, 1));
2308 EXPECT_FALSE(rootLayer->renderSurface()); 2308 EXPECT_FALSE(rootLayer->renderSurface());
2309 2309
2310 endTest(); 2310 endTest();
2311 } 2311 }
2312 2312
2313 virtual void afterTest() OVERRIDE 2313 virtual void afterTest() OVERRIDE
2314 { 2314 {
2315 } 2315 }
2316 }; 2316 };
2317 2317
2318 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestCompositeAndReadbackCleanup) 2318 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup)
2319 2319
2320 class CCLayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public CCLayerTreeHostTest { 2320 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public L ayerTreeHostTest {
2321 public: 2321 public:
2322 CCLayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() 2322 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit()
2323 : m_rootLayer(ContentLayerChromiumWithUpdateTracking::create(&m_mockDele gate)) 2323 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_mockDelegate))
2324 , m_surfaceLayer1(ContentLayerChromiumWithUpdateTracking::create(&m_mock Delegate)) 2324 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate ))
2325 , m_replicaLayer1(ContentLayerChromiumWithUpdateTracking::create(&m_mock Delegate)) 2325 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate ))
2326 , m_surfaceLayer2(ContentLayerChromiumWithUpdateTracking::create(&m_mock Delegate)) 2326 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate ))
2327 , m_replicaLayer2(ContentLayerChromiumWithUpdateTracking::create(&m_mock Delegate)) 2327 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate ))
2328 { 2328 {
2329 } 2329 }
2330 2330
2331 virtual void beginTest() OVERRIDE 2331 virtual void beginTest() OVERRIDE
2332 { 2332 {
2333 m_layerTreeHost->setViewportSize(IntSize(100, 100), IntSize(100, 100)); 2333 m_layerTreeHost->setViewportSize(IntSize(100, 100), IntSize(100, 100));
2334 2334
2335 m_rootLayer->setBounds(IntSize(100, 100)); 2335 m_rootLayer->setBounds(IntSize(100, 100));
2336 m_surfaceLayer1->setBounds(IntSize(100, 100)); 2336 m_surfaceLayer1->setBounds(IntSize(100, 100));
2337 m_surfaceLayer1->setForceRenderSurface(true); 2337 m_surfaceLayer1->setForceRenderSurface(true);
2338 m_surfaceLayer1->setOpacity(0.5); 2338 m_surfaceLayer1->setOpacity(0.5);
2339 m_surfaceLayer2->setBounds(IntSize(100, 100)); 2339 m_surfaceLayer2->setBounds(IntSize(100, 100));
2340 m_surfaceLayer2->setForceRenderSurface(true); 2340 m_surfaceLayer2->setForceRenderSurface(true);
2341 m_surfaceLayer2->setOpacity(0.5); 2341 m_surfaceLayer2->setOpacity(0.5);
2342 2342
2343 m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get()); 2343 m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get());
2344 m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get()); 2344 m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get());
2345 2345
2346 m_rootLayer->addChild(m_surfaceLayer1); 2346 m_rootLayer->addChild(m_surfaceLayer1);
2347 m_surfaceLayer1->addChild(m_surfaceLayer2); 2347 m_surfaceLayer1->addChild(m_surfaceLayer2);
2348 m_layerTreeHost->setRootLayer(m_rootLayer); 2348 m_layerTreeHost->setRootLayer(m_rootLayer);
2349 } 2349 }
2350 2350
2351 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* hostImpl) OVERRIDE 2351 virtual void drawLayersOnThread(LayerTreeHostImpl* hostImpl) OVERRIDE
2352 { 2352 {
2353 CCRenderer* renderer = hostImpl->renderer(); 2353 Renderer* renderer = hostImpl->renderer();
2354 CCRenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children( )[0]->renderSurface()->renderPassId(); 2354 RenderPass::Id surface1RenderPassId = hostImpl->rootLayer()->children()[ 0]->renderSurface()->renderPassId();
2355 CCRenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children( )[0]->children()[0]->renderSurface()->renderPassId(); 2355 RenderPass::Id surface2RenderPassId = hostImpl->rootLayer()->children()[ 0]->children()[0]->renderSurface()->renderPassId();
2356 2356
2357 switch (hostImpl->sourceFrameNumber()) { 2357 switch (hostImpl->sourceFrameNumber()) {
2358 case 0: 2358 case 0:
2359 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface1Ren derPassId)); 2359 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface1Ren derPassId));
2360 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface2Ren derPassId)); 2360 EXPECT_TRUE(renderer->haveCachedResourcesForRenderPassId(surface2Ren derPassId));
2361 2361
2362 // Reduce the memory limit to only fit the root layer and one render surface. This 2362 // Reduce the memory limit to only fit the root layer and one render surface. This
2363 // prevents any contents drawing into surfaces from being allocated. 2363 // prevents any contents drawing into surfaces from being allocated.
2364 hostImpl->setMemoryAllocationLimitBytes(100 * 100 * 4 * 2); 2364 hostImpl->setMemoryAllocationLimitBytes(100 * 100 * 4 * 2);
2365 break; 2365 break;
2366 case 1: 2366 case 1:
2367 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface1Re nderPassId)); 2367 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface1Re nderPassId));
2368 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface2Re nderPassId)); 2368 EXPECT_FALSE(renderer->haveCachedResourcesForRenderPassId(surface2Re nderPassId));
2369 2369
2370 endTest(); 2370 endTest();
2371 break; 2371 break;
2372 } 2372 }
2373 } 2373 }
2374 2374
2375 virtual void afterTest() OVERRIDE 2375 virtual void afterTest() OVERRIDE
2376 { 2376 {
2377 EXPECT_EQ(2, m_rootLayer->paintContentsCount()); 2377 EXPECT_EQ(2, m_rootLayer->paintContentsCount());
2378 EXPECT_EQ(2, m_surfaceLayer1->paintContentsCount()); 2378 EXPECT_EQ(2, m_surfaceLayer1->paintContentsCount());
2379 EXPECT_EQ(2, m_surfaceLayer2->paintContentsCount()); 2379 EXPECT_EQ(2, m_surfaceLayer2->paintContentsCount());
2380 2380
2381 // Clear layer references so CCLayerTreeHost dies. 2381 // Clear layer references so LayerTreeHost dies.
2382 m_rootLayer = NULL; 2382 m_rootLayer = NULL;
2383 m_surfaceLayer1 = NULL; 2383 m_surfaceLayer1 = NULL;
2384 m_replicaLayer1 = NULL; 2384 m_replicaLayer1 = NULL;
2385 m_surfaceLayer2 = NULL; 2385 m_surfaceLayer2 = NULL;
2386 m_replicaLayer2 = NULL; 2386 m_replicaLayer2 = NULL;
2387 } 2387 }
2388 2388
2389 private: 2389 private:
2390 MockContentLayerChromiumClient m_mockDelegate; 2390 MockContentLayerClient m_mockDelegate;
2391 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_rootLayer; 2391 scoped_refptr<ContentLayerWithUpdateTracking> m_rootLayer;
2392 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer1; 2392 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer1;
2393 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer1; 2393 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer1;
2394 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer2; 2394 scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2;
2395 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer2; 2395 scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2;
2396 }; 2396 };
2397 2397
2398 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSurfaceNotAllocatedForLayersOu tsideMemoryLimit) 2398 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOuts ideMemoryLimit)
2399 2399
2400 class EvictionTestLayer : public LayerChromium { 2400 class EvictionTestLayer : public Layer {
2401 public: 2401 public:
2402 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); } 2402 static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr (new EvictionTestLayer()); }
2403 2403
2404 virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRend eringStats&) OVERRIDE; 2404 virtual void update(TextureUpdateQueue&, const OcclusionTracker*, RenderingS tats&) OVERRIDE;
2405 virtual bool drawsContent() const OVERRIDE { return true; } 2405 virtual bool drawsContent() const OVERRIDE { return true; }
2406 2406
2407 virtual scoped_ptr<CCLayerImpl> createCCLayerImpl() OVERRIDE; 2407 virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE;
2408 virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE; 2408 virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
2409 virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE; 2409 virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
2410 2410
2411 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; } 2411 bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBa ckingTexture() : false; }
2412 2412
2413 private: 2413 private:
2414 EvictionTestLayer() : LayerChromium() { } 2414 EvictionTestLayer() : Layer() { }
2415 virtual ~EvictionTestLayer() { } 2415 virtual ~EvictionTestLayer() { }
2416 2416
2417 void createTextureIfNeeded() 2417 void createTextureIfNeeded()
2418 { 2418 {
2419 if (m_texture.get()) 2419 if (m_texture.get())
2420 return; 2420 return;
2421 m_texture = CCPrioritizedTexture::create(layerTreeHost()->contentsTextur eManager()); 2421 m_texture = PrioritizedTexture::create(layerTreeHost()->contentsTextureM anager());
2422 m_texture->setDimensions(IntSize(10, 10), cc::GraphicsContext3D::RGBA); 2422 m_texture->setDimensions(IntSize(10, 10), cc::GraphicsContext3D::RGBA);
2423 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 2423 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
2424 } 2424 }
2425 2425
2426 scoped_ptr<CCPrioritizedTexture> m_texture; 2426 scoped_ptr<PrioritizedTexture> m_texture;
2427 SkBitmap m_bitmap; 2427 SkBitmap m_bitmap;
2428 }; 2428 };
2429 2429
2430 class EvictionTestLayerImpl : public CCLayerImpl { 2430 class EvictionTestLayerImpl : public LayerImpl {
2431 public: 2431 public:
2432 static scoped_ptr<EvictionTestLayerImpl> create(int id) 2432 static scoped_ptr<EvictionTestLayerImpl> create(int id)
2433 { 2433 {
2434 return make_scoped_ptr(new EvictionTestLayerImpl(id)); 2434 return make_scoped_ptr(new EvictionTestLayerImpl(id));
2435 } 2435 }
2436 virtual ~EvictionTestLayerImpl() { } 2436 virtual ~EvictionTestLayerImpl() { }
2437 2437
2438 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&) OVERRIDE 2438 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData&) OVERRIDE
2439 { 2439 {
2440 ASSERT_TRUE(m_hasTexture); 2440 ASSERT_TRUE(m_hasTexture);
2441 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources()); 2441 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources());
2442 } 2442 }
2443 2443
2444 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } 2444 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; }
2445 2445
2446 private: 2446 private:
2447 explicit EvictionTestLayerImpl(int id) 2447 explicit EvictionTestLayerImpl(int id)
2448 : CCLayerImpl(id) 2448 : LayerImpl(id)
2449 , m_hasTexture(false) { } 2449 , m_hasTexture(false) { }
2450 2450
2451 bool m_hasTexture; 2451 bool m_hasTexture;
2452 }; 2452 };
2453 2453
2454 void EvictionTestLayer::setTexturePriorities(const CCPriorityCalculator&) 2454 void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&)
2455 { 2455 {
2456 createTextureIfNeeded(); 2456 createTextureIfNeeded();
2457 if (!m_texture.get()) 2457 if (!m_texture.get())
2458 return; 2458 return;
2459 m_texture->setRequestPriority(CCPriorityCalculator::uiPriority(true)); 2459 m_texture->setRequestPriority(PriorityCalculator::uiPriority(true));
2460 } 2460 }
2461 2461
2462 void EvictionTestLayer::update(CCTextureUpdateQueue& queue, const CCOcclusionTra cker*, CCRenderingStats&) 2462 void EvictionTestLayer::update(TextureUpdateQueue& queue, const OcclusionTracker *, RenderingStats&)
2463 { 2463 {
2464 createTextureIfNeeded(); 2464 createTextureIfNeeded();
2465 if (!m_texture.get()) 2465 if (!m_texture.get())
2466 return; 2466 return;
2467 IntRect fullRect(0, 0, 10, 10); 2467 IntRect fullRect(0, 0, 10, 10);
2468 TextureUploader::Parameters upload = { m_texture.get(), &m_bitmap, NULL, { f ullRect, fullRect, IntSize() } }; 2468 TextureUploader::Parameters upload = { m_texture.get(), &m_bitmap, NULL, { f ullRect, fullRect, IntSize() } };
2469 queue.appendFullUpload(upload); 2469 queue.appendFullUpload(upload);
2470 } 2470 }
2471 2471
2472 scoped_ptr<CCLayerImpl> EvictionTestLayer::createCCLayerImpl() 2472 scoped_ptr<LayerImpl> EvictionTestLayer::createLayerImpl()
2473 { 2473 {
2474 return EvictionTestLayerImpl::create(m_layerId).PassAs<CCLayerImpl>(); 2474 return EvictionTestLayerImpl::create(m_layerId).PassAs<LayerImpl>();
2475 } 2475 }
2476 2476
2477 void EvictionTestLayer::pushPropertiesTo(CCLayerImpl* layerImpl) 2477 void EvictionTestLayer::pushPropertiesTo(LayerImpl* layerImpl)
2478 { 2478 {
2479 LayerChromium::pushPropertiesTo(layerImpl); 2479 Layer::pushPropertiesTo(layerImpl);
2480 2480
2481 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl); 2481 EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(l ayerImpl);
2482 testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); 2482 testLayerImpl->setHasTexture(m_texture->haveBackingTexture());
2483 } 2483 }
2484 2484
2485 class CCLayerTreeHostTestEvictTextures : public CCLayerTreeHostTest { 2485 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest {
2486 public: 2486 public:
2487 CCLayerTreeHostTestEvictTextures() 2487 LayerTreeHostTestEvictTextures()
2488 : m_layer(EvictionTestLayer::create()) 2488 : m_layer(EvictionTestLayer::create())
2489 , m_implForEvictTextures(0) 2489 , m_implForEvictTextures(0)
2490 , m_numCommits(0) 2490 , m_numCommits(0)
2491 { 2491 {
2492 } 2492 }
2493 2493
2494 virtual void beginTest() OVERRIDE 2494 virtual void beginTest() OVERRIDE
2495 { 2495 {
2496 m_layerTreeHost->setRootLayer(m_layer); 2496 m_layerTreeHost->setRootLayer(m_layer);
2497 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); 2497 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
2498 2498
2499 WebTransformationMatrix identityMatrix; 2499 WebTransformationMatrix identityMatrix;
2500 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); 2500 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
2501 } 2501 }
2502 2502
2503 class EvictTexturesTask : public WebKit::WebThread::Task { 2503 class EvictTexturesTask : public WebKit::WebThread::Task {
2504 public: 2504 public:
2505 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test) { } 2505 EvictTexturesTask(LayerTreeHostTestEvictTextures* test) : m_test(test) { }
2506 virtual ~EvictTexturesTask() { } 2506 virtual ~EvictTexturesTask() { }
2507 virtual void run() OVERRIDE 2507 virtual void run() OVERRIDE
2508 { 2508 {
2509 ASSERT(m_test->m_implForEvictTextures); 2509 ASSERT(m_test->m_implForEvictTextures);
2510 m_test->m_implForEvictTextures->reduceContentsTextureMemoryOnImplThr ead(0); 2510 m_test->m_implForEvictTextures->reduceContentsTextureMemoryOnImplThr ead(0);
2511 } 2511 }
2512 2512
2513 private: 2513 private:
2514 CCLayerTreeHostTestEvictTextures* m_test; 2514 LayerTreeHostTestEvictTextures* m_test;
2515 }; 2515 };
2516 2516
2517 void postEvictTextures() 2517 void postEvictTextures()
2518 { 2518 {
2519 ASSERT(webThread()); 2519 ASSERT(webThread());
2520 webThread()->postTask(new EvictTexturesTask(this)); 2520 webThread()->postTask(new EvictTexturesTask(this));
2521 } 2521 }
2522 2522
2523 // Commit 1: Just commit and draw normally, then post an eviction at the end 2523 // Commit 1: Just commit and draw normally, then post an eviction at the end
2524 // that will trigger a commit. 2524 // that will trigger a commit.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 case 6: 2564 case 6:
2565 EXPECT_TRUE(m_layer->haveBackingTexture()); 2565 EXPECT_TRUE(m_layer->haveBackingTexture());
2566 endTest(); 2566 endTest();
2567 break; 2567 break;
2568 default: 2568 default:
2569 ASSERT_NOT_REACHED(); 2569 ASSERT_NOT_REACHED();
2570 break; 2570 break;
2571 } 2571 }
2572 } 2572 }
2573 2573
2574 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2574 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
2575 { 2575 {
2576 m_implForEvictTextures = impl; 2576 m_implForEvictTextures = impl;
2577 } 2577 }
2578 2578
2579 virtual void layout() OVERRIDE 2579 virtual void layout() OVERRIDE
2580 { 2580 {
2581 ++m_numCommits; 2581 ++m_numCommits;
2582 switch (m_numCommits) { 2582 switch (m_numCommits) {
2583 case 1: 2583 case 1:
2584 case 2: 2584 case 2:
(...skipping 17 matching lines...) Expand all
2602 ASSERT_NOT_REACHED(); 2602 ASSERT_NOT_REACHED();
2603 break; 2603 break;
2604 } 2604 }
2605 } 2605 }
2606 2606
2607 virtual void afterTest() OVERRIDE 2607 virtual void afterTest() OVERRIDE
2608 { 2608 {
2609 } 2609 }
2610 2610
2611 private: 2611 private:
2612 MockContentLayerChromiumClient m_client; 2612 MockContentLayerClient m_client;
2613 scoped_refptr<EvictionTestLayer> m_layer; 2613 scoped_refptr<EvictionTestLayer> m_layer;
2614 CCLayerTreeHostImpl* m_implForEvictTextures; 2614 LayerTreeHostImpl* m_implForEvictTextures;
2615 int m_numCommits; 2615 int m_numCommits;
2616 }; 2616 };
2617 2617
2618 TEST_F(CCLayerTreeHostTestEvictTextures, runMultiThread) 2618 TEST_F(LayerTreeHostTestEvictTextures, runMultiThread)
2619 { 2619 {
2620 runTest(true); 2620 runTest(true);
2621 } 2621 }
2622 2622
2623 class CCLayerTreeHostTestLostContextAfterEvictTextures : public CCLayerTreeHostT est { 2623 class LayerTreeHostTestLostContextAfterEvictTextures : public LayerTreeHostTest {
2624 public: 2624 public:
2625 CCLayerTreeHostTestLostContextAfterEvictTextures() 2625 LayerTreeHostTestLostContextAfterEvictTextures()
2626 : m_layer(EvictionTestLayer::create()) 2626 : m_layer(EvictionTestLayer::create())
2627 , m_implForEvictTextures(0) 2627 , m_implForEvictTextures(0)
2628 , m_numCommits(0) 2628 , m_numCommits(0)
2629 { 2629 {
2630 } 2630 }
2631 2631
2632 virtual void beginTest() OVERRIDE 2632 virtual void beginTest() OVERRIDE
2633 { 2633 {
2634 m_layerTreeHost->setRootLayer(m_layer); 2634 m_layerTreeHost->setRootLayer(m_layer);
2635 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); 2635 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
2636 2636
2637 WebTransformationMatrix identityMatrix; 2637 WebTransformationMatrix identityMatrix;
2638 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); 2638 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
2639 } 2639 }
2640 2640
2641 class EvictTexturesTask : public WebKit::WebThread::Task { 2641 class EvictTexturesTask : public WebKit::WebThread::Task {
2642 public: 2642 public:
2643 EvictTexturesTask(CCLayerTreeHostTestLostContextAfterEvictTextures* test ) : m_test(test) { } 2643 EvictTexturesTask(LayerTreeHostTestLostContextAfterEvictTextures* test) : m_test(test) { }
2644 virtual ~EvictTexturesTask() { } 2644 virtual ~EvictTexturesTask() { }
2645 virtual void run() OVERRIDE 2645 virtual void run() OVERRIDE
2646 { 2646 {
2647 m_test->evictTexturesOnImplThread(); 2647 m_test->evictTexturesOnImplThread();
2648 } 2648 }
2649 2649
2650 private: 2650 private:
2651 CCLayerTreeHostTestLostContextAfterEvictTextures* m_test; 2651 LayerTreeHostTestLostContextAfterEvictTextures* m_test;
2652 }; 2652 };
2653 2653
2654 void postEvictTextures() 2654 void postEvictTextures()
2655 { 2655 {
2656 if (webThread()) 2656 if (webThread())
2657 webThread()->postTask(new EvictTexturesTask(this)); 2657 webThread()->postTask(new EvictTexturesTask(this));
2658 else { 2658 else {
2659 DebugScopedSetImplThread impl; 2659 DebugScopedSetImplThread impl;
2660 evictTexturesOnImplThread(); 2660 evictTexturesOnImplThread();
2661 } 2661 }
(...skipping 20 matching lines...) Expand all
2682 m_layerTreeHost->setVisible(false); 2682 m_layerTreeHost->setVisible(false);
2683 postEvictTextures(); 2683 postEvictTextures();
2684 m_layerTreeHost->loseContext(1); 2684 m_layerTreeHost->loseContext(1);
2685 m_layerTreeHost->setVisible(true); 2685 m_layerTreeHost->setVisible(true);
2686 break; 2686 break;
2687 default: 2687 default:
2688 break; 2688 break;
2689 } 2689 }
2690 } 2690 }
2691 2691
2692 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2692 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
2693 { 2693 {
2694 m_implForEvictTextures = impl; 2694 m_implForEvictTextures = impl;
2695 } 2695 }
2696 2696
2697 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE 2697 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
2698 { 2698 {
2699 EXPECT_TRUE(succeeded); 2699 EXPECT_TRUE(succeeded);
2700 endTest(); 2700 endTest();
2701 } 2701 }
2702 2702
2703 virtual void afterTest() OVERRIDE 2703 virtual void afterTest() OVERRIDE
2704 { 2704 {
2705 } 2705 }
2706 2706
2707 private: 2707 private:
2708 MockContentLayerChromiumClient m_client; 2708 MockContentLayerClient m_client;
2709 scoped_refptr<EvictionTestLayer> m_layer; 2709 scoped_refptr<EvictionTestLayer> m_layer;
2710 CCLayerTreeHostImpl* m_implForEvictTextures; 2710 LayerTreeHostImpl* m_implForEvictTextures;
2711 int m_numCommits; 2711 int m_numCommits;
2712 }; 2712 };
2713 2713
2714 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLostContextAfterEvictTextures) 2714 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLostContextAfterEvictTextures)
2715 2715
2716 class CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext : public WebKit::CompositorFakeWebGraphicsContext3D { 2716 class CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext : public WebKit::CompositorFakeWebGraphicsContext3D {
2717 public: 2717 public:
2718 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostC ontext> create(Attributes attrs) 2718 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostC ontext> create(Attributes attrs)
2719 { 2719 {
2720 return make_scoped_ptr(new CompositorFakeWebGraphicsContext3DWithEndQuer yCausingLostContext(attrs)); 2720 return make_scoped_ptr(new CompositorFakeWebGraphicsContext3DWithEndQuer yCausingLostContext(attrs));
2721 } 2721 }
2722 2722
2723 virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback ) { m_contextLostCallback = callback; } 2723 virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback ) { m_contextLostCallback = callback; }
2724 virtual bool isContextLost() { return m_isContextLost; } 2724 virtual bool isContextLost() { return m_isContextLost; }
(...skipping 17 matching lines...) Expand all
2742 private: 2742 private:
2743 explicit CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext(At tributes attrs) 2743 explicit CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext(At tributes attrs)
2744 : CompositorFakeWebGraphicsContext3D(attrs) 2744 : CompositorFakeWebGraphicsContext3D(attrs)
2745 , m_contextLostCallback(0) 2745 , m_contextLostCallback(0)
2746 , m_isContextLost(false) { } 2746 , m_isContextLost(false) { }
2747 2747
2748 WebGraphicsContextLostCallback* m_contextLostCallback; 2748 WebGraphicsContextLostCallback* m_contextLostCallback;
2749 bool m_isContextLost; 2749 bool m_isContextLost;
2750 }; 2750 };
2751 2751
2752 class CCLayerTreeHostTestLostContextWhileUpdatingResources : public CCLayerTreeH ostTest { 2752 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est {
2753 public: 2753 public:
2754 CCLayerTreeHostTestLostContextWhileUpdatingResources() 2754 LayerTreeHostTestLostContextWhileUpdatingResources()
2755 : m_parent(ContentLayerChromiumWithUpdateTracking::create(&m_client)) 2755 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
2756 , m_numChildren(50) 2756 , m_numChildren(50)
2757 { 2757 {
2758 for (int i = 0; i < m_numChildren; i++) 2758 for (int i = 0; i < m_numChildren; i++)
2759 m_children.push_back(ContentLayerChromiumWithUpdateTracking::create( &m_client)); 2759 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t));
2760 } 2760 }
2761 2761
2762 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() 2762 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface()
2763 { 2763 {
2764 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>(); 2764 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>();
2765 } 2765 }
2766 2766
2767 virtual void beginTest() 2767 virtual void beginTest()
2768 { 2768 {
2769 m_layerTreeHost->setRootLayer(m_parent); 2769 m_layerTreeHost->setRootLayer(m_parent);
2770 m_layerTreeHost->setViewportSize(IntSize(m_numChildren, 1), IntSize(m_nu mChildren, 1)); 2770 m_layerTreeHost->setViewportSize(IntSize(m_numChildren, 1), IntSize(m_nu mChildren, 1));
2771 2771
2772 WebTransformationMatrix identityMatrix; 2772 WebTransformationMatrix identityMatrix;
2773 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi nt(0, 0), FloatPoint(0, 0), IntSize(m_numChildren, 1), true); 2773 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi nt(0, 0), FloatPoint(0, 0), IntSize(m_numChildren, 1), true);
2774 for (int i = 0; i < m_numChildren; i++) 2774 for (int i = 0; i < m_numChildren; i++)
2775 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id entityMatrix, FloatPoint(0, 0), FloatPoint(i, 0), IntSize(1, 1), false); 2775 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id entityMatrix, FloatPoint(0, 0), FloatPoint(i, 0), IntSize(1, 1), false);
2776 2776
2777 postSetNeedsCommitToMainThread(); 2777 postSetNeedsCommitToMainThread();
2778 } 2778 }
2779 2779
2780 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) 2780 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl)
2781 { 2781 {
2782 endTest(); 2782 endTest();
2783 } 2783 }
2784 2784
2785 virtual void layout() 2785 virtual void layout()
2786 { 2786 {
2787 m_parent->setNeedsDisplay(); 2787 m_parent->setNeedsDisplay();
2788 for (int i = 0; i < m_numChildren; i++) 2788 for (int i = 0; i < m_numChildren; i++)
2789 m_children[i]->setNeedsDisplay(); 2789 m_children[i]->setNeedsDisplay();
2790 } 2790 }
2791 2791
2792 virtual void afterTest() 2792 virtual void afterTest()
2793 { 2793 {
2794 } 2794 }
2795 2795
2796 private: 2796 private:
2797 MockContentLayerChromiumClient m_client; 2797 MockContentLayerClient m_client;
2798 scoped_refptr<ContentLayerChromiumWithUpdateTracking> m_parent; 2798 scoped_refptr<ContentLayerWithUpdateTracking> m_parent;
2799 int m_numChildren; 2799 int m_numChildren;
2800 std::vector<scoped_refptr<ContentLayerChromiumWithUpdateTracking> > m_childr en; 2800 std::vector<scoped_refptr<ContentLayerWithUpdateTracking> > m_children;
2801 }; 2801 };
2802 2802
2803 TEST_F(CCLayerTreeHostTestLostContextWhileUpdatingResources, runMultiThread) 2803 TEST_F(LayerTreeHostTestLostContextWhileUpdatingResources, runMultiThread)
2804 { 2804 {
2805 runTest(true); 2805 runTest(true);
2806 } 2806 }
2807 2807
2808 class CCLayerTreeHostTestContinuousCommit : public CCLayerTreeHostTest { 2808 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest {
2809 public: 2809 public:
2810 CCLayerTreeHostTestContinuousCommit() 2810 LayerTreeHostTestContinuousCommit()
2811 : m_numCommitComplete(0) 2811 : m_numCommitComplete(0)
2812 , m_numDrawLayers(0) 2812 , m_numDrawLayers(0)
2813 { 2813 {
2814 } 2814 }
2815 2815
2816 virtual void beginTest() OVERRIDE 2816 virtual void beginTest() OVERRIDE
2817 { 2817 {
2818 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 2818 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
2819 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); 2819 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
2820 2820
2821 postSetNeedsCommitToMainThread(); 2821 postSetNeedsCommitToMainThread();
2822 } 2822 }
2823 2823
2824 virtual void didCommit() OVERRIDE 2824 virtual void didCommit() OVERRIDE
2825 { 2825 {
2826 postSetNeedsCommitToMainThread(); 2826 postSetNeedsCommitToMainThread();
2827 } 2827 }
2828 2828
2829 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 2829 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
2830 { 2830 {
2831 if (m_numDrawLayers == 1) 2831 if (m_numDrawLayers == 1)
2832 m_numCommitComplete++; 2832 m_numCommitComplete++;
2833 } 2833 }
2834 2834
2835 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2835 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2836 { 2836 {
2837 m_numDrawLayers++; 2837 m_numDrawLayers++;
2838 if (m_numDrawLayers == 2) 2838 if (m_numDrawLayers == 2)
2839 endTest(); 2839 endTest();
2840 } 2840 }
2841 2841
2842 virtual void afterTest() OVERRIDE 2842 virtual void afterTest() OVERRIDE
2843 { 2843 {
2844 // Check that we didn't commit twice between first and second draw. 2844 // Check that we didn't commit twice between first and second draw.
2845 EXPECT_EQ(1, m_numCommitComplete); 2845 EXPECT_EQ(1, m_numCommitComplete);
2846 } 2846 }
2847 2847
2848 private: 2848 private:
2849 int m_numCommitComplete; 2849 int m_numCommitComplete;
2850 int m_numDrawLayers; 2850 int m_numDrawLayers;
2851 }; 2851 };
2852 2852
2853 TEST_F(CCLayerTreeHostTestContinuousCommit, runMultiThread) 2853 TEST_F(LayerTreeHostTestContinuousCommit, runMultiThread)
2854 { 2854 {
2855 runTest(true); 2855 runTest(true);
2856 } 2856 }
2857 2857
2858 class CCLayerTreeHostTestContinuousInvalidate : public CCLayerTreeHostTest { 2858 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
2859 public: 2859 public:
2860 CCLayerTreeHostTestContinuousInvalidate() 2860 LayerTreeHostTestContinuousInvalidate()
2861 : m_numCommitComplete(0) 2861 : m_numCommitComplete(0)
2862 , m_numDrawLayers(0) 2862 , m_numDrawLayers(0)
2863 { 2863 {
2864 } 2864 }
2865 2865
2866 virtual void beginTest() OVERRIDE 2866 virtual void beginTest() OVERRIDE
2867 { 2867 {
2868 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 2868 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
2869 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); 2869 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
2870 2870
2871 m_contentLayer = ContentLayerChromium::create(&m_mockDelegate); 2871 m_contentLayer = ContentLayer::create(&m_mockDelegate);
2872 m_contentLayer->setBounds(IntSize(10, 10)); 2872 m_contentLayer->setBounds(IntSize(10, 10));
2873 m_contentLayer->setPosition(FloatPoint(0, 0)); 2873 m_contentLayer->setPosition(FloatPoint(0, 0));
2874 m_contentLayer->setAnchorPoint(FloatPoint(0, 0)); 2874 m_contentLayer->setAnchorPoint(FloatPoint(0, 0));
2875 m_contentLayer->setIsDrawable(true); 2875 m_contentLayer->setIsDrawable(true);
2876 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); 2876 m_layerTreeHost->rootLayer()->addChild(m_contentLayer);
2877 2877
2878 postSetNeedsCommitToMainThread(); 2878 postSetNeedsCommitToMainThread();
2879 } 2879 }
2880 2880
2881 virtual void didCommit() OVERRIDE 2881 virtual void didCommit() OVERRIDE
2882 { 2882 {
2883 m_contentLayer->setNeedsDisplay(); 2883 m_contentLayer->setNeedsDisplay();
2884 } 2884 }
2885 2885
2886 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 2886 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
2887 { 2887 {
2888 if (m_numDrawLayers == 1) 2888 if (m_numDrawLayers == 1)
2889 m_numCommitComplete++; 2889 m_numCommitComplete++;
2890 } 2890 }
2891 2891
2892 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2892 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2893 { 2893 {
2894 m_numDrawLayers++; 2894 m_numDrawLayers++;
2895 if (m_numDrawLayers == 2) 2895 if (m_numDrawLayers == 2)
2896 endTest(); 2896 endTest();
2897 } 2897 }
2898 2898
2899 virtual void afterTest() OVERRIDE 2899 virtual void afterTest() OVERRIDE
2900 { 2900 {
2901 // Check that we didn't commit twice between first and second draw. 2901 // Check that we didn't commit twice between first and second draw.
2902 EXPECT_EQ(1, m_numCommitComplete); 2902 EXPECT_EQ(1, m_numCommitComplete);
2903 2903
2904 // Clear layer references so CCLayerTreeHost dies. 2904 // Clear layer references so LayerTreeHost dies.
2905 m_contentLayer = NULL; 2905 m_contentLayer = NULL;
2906 } 2906 }
2907 2907
2908 private: 2908 private:
2909 MockContentLayerChromiumClient m_mockDelegate; 2909 MockContentLayerClient m_mockDelegate;
2910 scoped_refptr<LayerChromium> m_contentLayer; 2910 scoped_refptr<Layer> m_contentLayer;
2911 int m_numCommitComplete; 2911 int m_numCommitComplete;
2912 int m_numDrawLayers; 2912 int m_numDrawLayers;
2913 }; 2913 };
2914 2914
2915 TEST_F(CCLayerTreeHostTestContinuousInvalidate, runMultiThread) 2915 TEST_F(LayerTreeHostTestContinuousInvalidate, runMultiThread)
2916 { 2916 {
2917 runTest(true); 2917 runTest(true);
2918 } 2918 }
2919 2919
2920 class CCLayerTreeHostTestContinuousAnimate : public CCLayerTreeHostTest { 2920 class LayerTreeHostTestContinuousAnimate : public LayerTreeHostTest {
2921 public: 2921 public:
2922 CCLayerTreeHostTestContinuousAnimate() 2922 LayerTreeHostTestContinuousAnimate()
2923 : m_numCommitComplete(0) 2923 : m_numCommitComplete(0)
2924 , m_numDrawLayers(0) 2924 , m_numDrawLayers(0)
2925 { 2925 {
2926 } 2926 }
2927 2927
2928 virtual void beginTest() OVERRIDE 2928 virtual void beginTest() OVERRIDE
2929 { 2929 {
2930 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 2930 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
2931 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); 2931 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
2932 2932
2933 postSetNeedsCommitToMainThread(); 2933 postSetNeedsCommitToMainThread();
2934 } 2934 }
2935 2935
2936 virtual void animate(double) OVERRIDE 2936 virtual void animate(double) OVERRIDE
2937 { 2937 {
2938 m_layerTreeHost->setNeedsAnimate(); 2938 m_layerTreeHost->setNeedsAnimate();
2939 } 2939 }
2940 2940
2941 virtual void layout() OVERRIDE 2941 virtual void layout() OVERRIDE
2942 { 2942 {
2943 m_layerTreeHost->rootLayer()->setNeedsDisplay(); 2943 m_layerTreeHost->rootLayer()->setNeedsDisplay();
2944 } 2944 }
2945 2945
2946 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) OVERRIDE 2946 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
2947 { 2947 {
2948 if (m_numDrawLayers == 1) 2948 if (m_numDrawLayers == 1)
2949 m_numCommitComplete++; 2949 m_numCommitComplete++;
2950 } 2950 }
2951 2951
2952 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2952 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
2953 { 2953 {
2954 m_numDrawLayers++; 2954 m_numDrawLayers++;
2955 if (m_numDrawLayers == 2) 2955 if (m_numDrawLayers == 2)
2956 endTest(); 2956 endTest();
2957 } 2957 }
2958 2958
2959 virtual void afterTest() OVERRIDE 2959 virtual void afterTest() OVERRIDE
2960 { 2960 {
2961 // Check that we didn't commit twice between first and second draw. 2961 // Check that we didn't commit twice between first and second draw.
2962 EXPECT_EQ(1, m_numCommitComplete); 2962 EXPECT_EQ(1, m_numCommitComplete);
2963 } 2963 }
2964 2964
2965 private: 2965 private:
2966 int m_numCommitComplete; 2966 int m_numCommitComplete;
2967 int m_numDrawLayers; 2967 int m_numDrawLayers;
2968 }; 2968 };
2969 2969
2970 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) 2970 TEST_F(LayerTreeHostTestContinuousAnimate, runMultiThread)
2971 { 2971 {
2972 runTest(true); 2972 runTest(true);
2973 } 2973 }
2974 2974
2975 } // namespace 2975 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698