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/path_service.h" | 7 #include "base/path_service.h" |
8 #include "cc/output/compositor_frame_metadata.h" | 8 #include "cc/output/compositor_frame_metadata.h" |
9 #include "cc/output/gl_renderer.h" | 9 #include "cc/output/gl_renderer.h" |
10 #include "cc/output/output_surface.h" | 10 #include "cc/output/output_surface.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 output_surface_.get(), | 70 output_surface_.get(), |
71 resource_provider_.get(), | 71 resource_provider_.get(), |
72 0); | 72 0); |
73 | 73 |
74 scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts = | 74 scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts = |
75 webkit::gpu::ContextProviderInProcess::Create(); | 75 webkit::gpu::ContextProviderInProcess::Create(); |
76 ASSERT_TRUE(offscreen_contexts->BindToCurrentThread()); | 76 ASSERT_TRUE(offscreen_contexts->BindToCurrentThread()); |
77 resource_provider_->set_offscreen_context_provider(offscreen_contexts); | 77 resource_provider_->set_offscreen_context_provider(offscreen_contexts); |
78 } | 78 } |
79 | 79 |
| 80 bool PixelTest::ReadbackResult(scoped_ptr<SkBitmap> bitmap) { |
| 81 result_bitmap_ = bitmap.Pass(); |
| 82 } |
| 83 |
80 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, | 84 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, |
81 const PixelComparator& comparator) { | 85 const PixelComparator& comparator) { |
82 gfx::Rect device_viewport_rect(device_viewport_size_); | |
83 | |
84 SkBitmap bitmap; | |
85 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | |
86 device_viewport_rect.width(), | |
87 device_viewport_rect.height()); | |
88 bitmap.allocPixels(); | |
89 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels()); | |
90 renderer_->GetFramebufferPixels(pixels, device_viewport_rect); | |
91 | |
92 base::FilePath test_data_dir; | 86 base::FilePath test_data_dir; |
93 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) | 87 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) |
94 return false; | 88 return false; |
95 | 89 |
| 90 // If this is false, we didn't set up a readback on a render pass. |
| 91 if (!result_bitmap_) |
| 92 return false; |
| 93 |
96 // To rebaseline: | 94 // To rebaseline: |
97 // return WritePNGFile(bitmap, test_data_dir.Append(ref_file)); | 95 // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true); |
98 | 96 |
99 return MatchesPNGFile(bitmap, test_data_dir.Append(ref_file), comparator); | 97 return MatchesPNGFile(*result_bitmap_, |
| 98 test_data_dir.Append(ref_file), |
| 99 comparator); |
100 } | 100 } |
101 | 101 |
102 } // namespace cc | 102 } // namespace cc |
OLD | NEW |