OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 private: | 271 private: |
272 int m_numCommits; | 272 int m_numCommits; |
273 int m_numDraws; | 273 int m_numDraws; |
274 }; | 274 }; |
275 | 275 |
276 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) | 276 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) |
277 { | 277 { |
278 runTest(true); | 278 runTest(true); |
279 } | 279 } |
280 | 280 |
| 281 class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest { |
| 282 public: |
| 283 LayerTreeHostTestCompositeAndReadback() |
| 284 : m_numCommits(0) |
| 285 { |
| 286 } |
| 287 |
| 288 virtual void beginTest() OVERRIDE |
| 289 { |
| 290 postSetNeedsCommitToMainThread(); |
| 291 } |
| 292 |
| 293 virtual void didCommit() OVERRIDE |
| 294 { |
| 295 m_numCommits++; |
| 296 if (m_numCommits == 1) { |
| 297 char pixels[4]; |
| 298 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
| 299 } else if (m_numCommits == 2) { |
| 300 // This is inside the readback. We should get another commit after i
t. |
| 301 } else if (m_numCommits == 3) { |
| 302 endTest(); |
| 303 } else { |
| 304 NOTREACHED(); |
| 305 } |
| 306 } |
| 307 |
| 308 virtual void afterTest() OVERRIDE |
| 309 { |
| 310 } |
| 311 |
| 312 private: |
| 313 int m_numCommits; |
| 314 }; |
| 315 |
| 316 TEST_F(LayerTreeHostTestCompositeAndReadback, runMultiThread) |
| 317 { |
| 318 runTest(true); |
| 319 } |
| 320 |
| 321 class LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws : public La
yerTreeHostTest { |
| 322 public: |
| 323 LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws() |
| 324 : m_numCommits(0) |
| 325 { |
| 326 } |
| 327 |
| 328 virtual void beginTest() OVERRIDE |
| 329 { |
| 330 postSetNeedsCommitToMainThread(); |
| 331 } |
| 332 |
| 333 virtual void didCommit() OVERRIDE |
| 334 { |
| 335 m_numCommits++; |
| 336 if (m_numCommits == 1) { |
| 337 m_layerTreeHost->setNeedsCommit(); |
| 338 } else if (m_numCommits == 2) { |
| 339 char pixels[4]; |
| 340 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
| 341 } else if (m_numCommits == 3) { |
| 342 // This is inside the readback. We should get another commit after i
t. |
| 343 } else if (m_numCommits == 4) { |
| 344 endTest(); |
| 345 } else { |
| 346 NOTREACHED(); |
| 347 } |
| 348 } |
| 349 |
| 350 virtual void afterTest() OVERRIDE |
| 351 { |
| 352 } |
| 353 |
| 354 private: |
| 355 int m_numCommits; |
| 356 }; |
| 357 |
| 358 TEST_F(LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws, runMultiT
hread) |
| 359 { |
| 360 runTest(true); |
| 361 } |
| 362 |
281 // If the layerTreeHost says it can't draw, then we should not try to draw. | 363 // If the layerTreeHost says it can't draw, then we should not try to draw. |
282 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { | 364 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { |
283 public: | 365 public: |
284 LayerTreeHostTestCanDrawBlocksDrawing() | 366 LayerTreeHostTestCanDrawBlocksDrawing() |
285 : m_numCommits(0) | 367 : m_numCommits(0) |
286 , m_done(false) | 368 , m_done(false) |
287 { | 369 { |
288 } | 370 } |
289 | 371 |
290 virtual void beginTest() OVERRIDE | 372 virtual void beginTest() OVERRIDE |
(...skipping 23 matching lines...) Expand all Loading... |
314 virtual void didCommit() OVERRIDE | 396 virtual void didCommit() OVERRIDE |
315 { | 397 { |
316 m_numCommits++; | 398 m_numCommits++; |
317 if (m_numCommits == 1) { | 399 if (m_numCommits == 1) { |
318 // Make the viewport empty so the host says it can't draw. | 400 // Make the viewport empty so the host says it can't draw. |
319 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); | 401 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); |
320 } else if (m_numCommits == 2) { | 402 } else if (m_numCommits == 2) { |
321 char pixels[4]; | 403 char pixels[4]; |
322 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); | 404 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
323 } else if (m_numCommits == 3) { | 405 } else if (m_numCommits == 3) { |
324 postSetNeedsRedrawToMainThread(); | |
325 postSetNeedsCommitToMainThread(); | |
326 } else if (m_numCommits == 4) { | |
327 // Let it draw so we go idle and end the test. | 406 // Let it draw so we go idle and end the test. |
328 m_layerTreeHost->setViewportSize(gfx::Size(1, 1), gfx::Size(1, 1)); | 407 m_layerTreeHost->setViewportSize(gfx::Size(1, 1), gfx::Size(1, 1)); |
329 m_done = true; | 408 m_done = true; |
330 endTest(); | 409 endTest(); |
331 } | 410 } |
332 } | 411 } |
333 | 412 |
334 virtual void afterTest() OVERRIDE | 413 virtual void afterTest() OVERRIDE |
335 { | 414 { |
336 } | 415 } |
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 LayerTreeSettings settings; | 3492 LayerTreeSettings settings; |
3414 settings.maxPartialTextureUpdates = 4; | 3493 settings.maxPartialTextureUpdates = 4; |
3415 | 3494 |
3416 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 3495 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
3417 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 3496 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
3418 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 3497 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
3419 } | 3498 } |
3420 | 3499 |
3421 } // namespace | 3500 } // namespace |
3422 } // namespace cc | 3501 } // namespace cc |
OLD | NEW |