OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/pixel_test.h" | 5 #include "cc/test/pixel_test.h" |
6 | 6 |
7 #include "base/message_loop.h" | |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
8 #include "cc/output/compositor_frame_metadata.h" | 9 #include "cc/output/compositor_frame_metadata.h" |
9 #include "cc/output/gl_renderer.h" | 10 #include "cc/output/gl_renderer.h" |
10 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
11 #include "cc/resources/resource_provider.h" | 12 #include "cc/resources/resource_provider.h" |
12 #include "cc/test/paths.h" | 13 #include "cc/test/paths.h" |
13 #include "cc/test/pixel_test_utils.h" | 14 #include "cc/test/pixel_test_utils.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
16 #include "webkit/gpu/context_provider_in_process.h" | 17 #include "webkit/gpu/context_provider_in_process.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 80 |
80 bool PixelTest::RunPixelTest(RenderPassList* pass_list, | 81 bool PixelTest::RunPixelTest(RenderPassList* pass_list, |
81 const base::FilePath& ref_file, | 82 const base::FilePath& ref_file, |
82 const PixelComparator& comparator) { | 83 const PixelComparator& comparator) { |
83 pass_list->back()->copy_callbacks.push_back( | 84 pass_list->back()->copy_callbacks.push_back( |
84 base::Bind(&PixelTest::ReadbackResult, base::Unretained(this))); | 85 base::Bind(&PixelTest::ReadbackResult, base::Unretained(this))); |
85 | 86 |
86 renderer_->DecideRenderPassAllocationsForFrame(*pass_list); | 87 renderer_->DecideRenderPassAllocationsForFrame(*pass_list); |
87 renderer_->DrawFrame(pass_list); | 88 renderer_->DrawFrame(pass_list); |
88 | 89 |
89 // TODO(danakj): When the glReadPixels is async, wait for it to finish. | 90 // Wait for the readback to complete. |
91 output_surface_->context3d()->finish(); | |
92 base::MessageLoop::current()->Run(); | |
piman
2013/04/27 00:42:25
Any way we can use base::RunLoop instead (generall
danakj
2013/04/29 14:59:05
I will introduce myself to RunLoop. (Oh, it is nee
| |
90 | 93 |
91 return PixelsMatchReference(ref_file, comparator); | 94 return PixelsMatchReference(ref_file, comparator); |
92 } | 95 } |
93 | 96 |
94 void PixelTest::ReadbackResult(scoped_ptr<SkBitmap> bitmap) { | 97 void PixelTest::ReadbackResult(scoped_ptr<SkBitmap> bitmap) { |
95 result_bitmap_ = bitmap.Pass(); | 98 result_bitmap_ = bitmap.Pass(); |
99 base::MessageLoop::current()->QuitWhenIdle(); | |
96 } | 100 } |
97 | 101 |
98 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, | 102 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, |
99 const PixelComparator& comparator) { | 103 const PixelComparator& comparator) { |
100 base::FilePath test_data_dir; | 104 base::FilePath test_data_dir; |
101 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) | 105 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) |
102 return false; | 106 return false; |
103 | 107 |
104 // If this is false, we didn't set up a readback on a render pass. | 108 // If this is false, we didn't set up a readback on a render pass. |
105 if (!result_bitmap_) | 109 if (!result_bitmap_) |
106 return false; | 110 return false; |
107 | 111 |
108 // To rebaseline: | 112 // To rebaseline: |
109 // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true); | 113 // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true); |
110 | 114 |
111 return MatchesPNGFile(*result_bitmap_, | 115 return MatchesPNGFile(*result_bitmap_, |
112 test_data_dir.Append(ref_file), | 116 test_data_dir.Append(ref_file), |
113 comparator); | 117 comparator); |
114 } | 118 } |
115 | 119 |
116 } // namespace cc | 120 } // namespace cc |
OLD | NEW |