| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame_metadata.h" | 7 #include "cc/output/compositor_frame_metadata.h" |
| 8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
| 9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
| 10 #include "cc/resources/sync_point_helper.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/mock_quad_culler.h" | 14 #include "cc/test/mock_quad_culler.h" |
| 14 #include "cc/test/pixel_test.h" | 15 #include "cc/test/pixel_test.h" |
| 15 #include "cc/test/render_pass_test_common.h" | 16 #include "cc/test/render_pass_test_common.h" |
| 16 #include "cc/test/render_pass_test_utils.h" | 17 #include "cc/test/render_pass_test_utils.h" |
| 17 #include "cc/test/test_web_graphics_context_3d.h" | 18 #include "cc/test/test_web_graphics_context_3d.h" |
| 19 #include "gpu/GLES2/gl2extchromium.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
| 21 #include "third_party/skia/include/core/SkImageFilter.h" | 23 #include "third_party/skia/include/core/SkImageFilter.h" |
| 22 #include "third_party/skia/include/core/SkMatrix.h" | 24 #include "third_party/skia/include/core/SkMatrix.h" |
| 23 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" | 25 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" |
| 24 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 26 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
| 25 #include "ui/gfx/transform.h" | 27 #include "ui/gfx/transform.h" |
| 26 | 28 |
| 27 using testing::_; | 29 using testing::_; |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 fake_settings.compositor_frame_message = true; | 1421 fake_settings.compositor_frame_message = true; |
| 1420 return fake_settings; | 1422 return fake_settings; |
| 1421 } | 1423 } |
| 1422 }; | 1424 }; |
| 1423 | 1425 |
| 1424 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { | 1426 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { |
| 1425 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); | 1427 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); |
| 1426 DrawFrame(); | 1428 DrawFrame(); |
| 1427 } | 1429 } |
| 1428 | 1430 |
| 1431 class GLRendererTestSyncPoint : public GLRendererPixelTest { |
| 1432 protected: |
| 1433 static void SyncPointCallback(int* callback_count) { |
| 1434 ++(*callback_count); |
| 1435 base::MessageLoop::current()->QuitWhenIdle(); |
| 1436 } |
| 1437 |
| 1438 static void OtherCallback(int* callback_count) { |
| 1439 ++(*callback_count); |
| 1440 base::MessageLoop::current()->QuitWhenIdle(); |
| 1441 } |
| 1442 }; |
| 1443 |
| 1444 TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) { |
| 1445 int sync_point_callback_count = 0; |
| 1446 int other_callback_count = 0; |
| 1447 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); |
| 1448 |
| 1449 output_surface_->context3d()->loseContextCHROMIUM( |
| 1450 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 1451 |
| 1452 SyncPointHelper::SignalSyncPoint( |
| 1453 output_surface_->context3d(), |
| 1454 sync_point, |
| 1455 base::Bind(&SyncPointCallback, &sync_point_callback_count)); |
| 1456 EXPECT_EQ(0, sync_point_callback_count); |
| 1457 EXPECT_EQ(0, other_callback_count); |
| 1458 |
| 1459 // Make the sync point happen. |
| 1460 output_surface_->context3d()->finish(); |
| 1461 // Post a task after the sync point. |
| 1462 base::MessageLoop::current()->PostTask( |
| 1463 FROM_HERE, |
| 1464 base::Bind(&OtherCallback, &other_callback_count)); |
| 1465 |
| 1466 base::MessageLoop::current()->Run(); |
| 1467 |
| 1468 // The sync point shouldn't have happened since the context was lost. |
| 1469 EXPECT_EQ(0, sync_point_callback_count); |
| 1470 EXPECT_EQ(1, other_callback_count); |
| 1471 } |
| 1472 |
| 1473 TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) { |
| 1474 int sync_point_callback_count = 0; |
| 1475 int other_callback_count = 0; |
| 1476 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); |
| 1477 |
| 1478 SyncPointHelper::SignalSyncPoint( |
| 1479 output_surface_->context3d(), |
| 1480 sync_point, |
| 1481 base::Bind(&SyncPointCallback, &sync_point_callback_count)); |
| 1482 EXPECT_EQ(0, sync_point_callback_count); |
| 1483 EXPECT_EQ(0, other_callback_count); |
| 1484 |
| 1485 // Make the sync point happen. |
| 1486 output_surface_->context3d()->finish(); |
| 1487 // Post a task after the sync point. |
| 1488 base::MessageLoop::current()->PostTask( |
| 1489 FROM_HERE, |
| 1490 base::Bind(&OtherCallback, &other_callback_count)); |
| 1491 |
| 1492 base::MessageLoop::current()->Run(); |
| 1493 |
| 1494 // The sync point should have happened. |
| 1495 EXPECT_EQ(1, sync_point_callback_count); |
| 1496 EXPECT_EQ(1, other_callback_count); |
| 1497 } |
| 1498 |
| 1429 } // namespace | 1499 } // namespace |
| 1430 } // namespace cc | 1500 } // namespace cc |
| OLD | NEW |