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

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 15004009: cc: Fix readback from non-root layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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
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 #if !defined(OS_ANDROID)
1445 TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) {
1446 int sync_point_callback_count = 0;
1447 int other_callback_count = 0;
1448 unsigned sync_point = output_surface_->context3d()->insertSyncPoint();
1449
1450 output_surface_->context3d()->loseContextCHROMIUM(
1451 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
1452
1453 SyncPointHelper::SignalSyncPoint(
1454 output_surface_->context3d(),
1455 sync_point,
1456 base::Bind(&SyncPointCallback, &sync_point_callback_count));
1457 EXPECT_EQ(0, sync_point_callback_count);
1458 EXPECT_EQ(0, other_callback_count);
1459
1460 // Make the sync point happen.
1461 output_surface_->context3d()->finish();
1462 // Post a task after the sync point.
1463 base::MessageLoop::current()->PostTask(
1464 FROM_HERE,
1465 base::Bind(&OtherCallback, &other_callback_count));
1466
1467 base::MessageLoop::current()->Run();
1468
1469 // The sync point shouldn't have happened since the context was lost.
1470 EXPECT_EQ(0, sync_point_callback_count);
1471 EXPECT_EQ(1, other_callback_count);
1472 }
1473
1474 TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) {
1475 int sync_point_callback_count = 0;
1476 int other_callback_count = 0;
1477 unsigned sync_point = output_surface_->context3d()->insertSyncPoint();
1478
1479 SyncPointHelper::SignalSyncPoint(
1480 output_surface_->context3d(),
1481 sync_point,
1482 base::Bind(&SyncPointCallback, &sync_point_callback_count));
1483 EXPECT_EQ(0, sync_point_callback_count);
1484 EXPECT_EQ(0, other_callback_count);
1485
1486 // Make the sync point happen.
1487 output_surface_->context3d()->finish();
1488 // Post a task after the sync point.
1489 base::MessageLoop::current()->PostTask(
1490 FROM_HERE,
1491 base::Bind(&OtherCallback, &other_callback_count));
1492
1493 base::MessageLoop::current()->Run();
1494
1495 // The sync point should have happened.
1496 EXPECT_EQ(1, sync_point_callback_count);
1497 EXPECT_EQ(1, other_callback_count);
1498 }
1499 #endif // OS_ANDROID
1500
1429 } // namespace 1501 } // namespace
1430 } // namespace cc 1502 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698