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

Side by Side Diff: cc/test/pixel_test.cc

Issue 14273026: cc: Make async readback path use async glRreadPixels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding 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/test/pixel_test.h ('k') | cc/test/test_web_graphics_context_3d.h » ('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 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 "base/run_loop.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/output/software_renderer.h" 12 #include "cc/output/software_renderer.h"
12 #include "cc/resources/resource_provider.h" 13 #include "cc/resources/resource_provider.h"
13 #include "cc/test/paths.h" 14 #include "cc/test/paths.h"
14 #include "cc/test/pixel_test_utils.h" 15 #include "cc/test/pixel_test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gl/gl_implementation.h" 17 #include "ui/gl/gl_implementation.h"
17 #include "webkit/gpu/context_provider_in_process.h" 18 #include "webkit/gpu/context_provider_in_process.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 PixelTest::PixelTest() 55 PixelTest::PixelTest()
55 : device_viewport_size_(gfx::Size(200, 200)), 56 : device_viewport_size_(gfx::Size(200, 200)),
56 fake_client_(new PixelTestRendererClient(device_viewport_size_)) {} 57 fake_client_(new PixelTestRendererClient(device_viewport_size_)) {}
57 58
58 PixelTest::~PixelTest() {} 59 PixelTest::~PixelTest() {}
59 60
60 bool PixelTest::RunPixelTest(RenderPassList* pass_list, 61 bool PixelTest::RunPixelTest(RenderPassList* pass_list,
61 const base::FilePath& ref_file, 62 const base::FilePath& ref_file,
62 const PixelComparator& comparator) { 63 const PixelComparator& comparator) {
64 base::RunLoop run_loop;
65
63 pass_list->back()->copy_callbacks.push_back( 66 pass_list->back()->copy_callbacks.push_back(
64 base::Bind(&PixelTest::ReadbackResult, base::Unretained(this))); 67 base::Bind(&PixelTest::ReadbackResult,
68 base::Unretained(this),
69 run_loop.QuitClosure()));
65 70
66 renderer_->DecideRenderPassAllocationsForFrame(*pass_list); 71 renderer_->DecideRenderPassAllocationsForFrame(*pass_list);
67 renderer_->DrawFrame(pass_list); 72 renderer_->DrawFrame(pass_list);
68 73
69 // TODO(danakj): When the glReadPixels is async, wait for it to finish. 74 // Wait for the readback to complete.
75 resource_provider_->Finish();
76 run_loop.Run();
70 77
71 return PixelsMatchReference(ref_file, comparator); 78 return PixelsMatchReference(ref_file, comparator);
72 } 79 }
73 80
74 void PixelTest::ReadbackResult(scoped_ptr<SkBitmap> bitmap) { 81 void PixelTest::ReadbackResult(base::Closure quit_run_loop,
82 scoped_ptr<SkBitmap> bitmap) {
75 result_bitmap_ = bitmap.Pass(); 83 result_bitmap_ = bitmap.Pass();
84 quit_run_loop.Run();
76 } 85 }
77 86
78 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, 87 bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file,
79 const PixelComparator& comparator) { 88 const PixelComparator& comparator) {
80 base::FilePath test_data_dir; 89 base::FilePath test_data_dir;
81 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) 90 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir))
82 return false; 91 return false;
83 92
84 // If this is false, we didn't set up a readback on a render pass. 93 // If this is false, we didn't set up a readback on a render pass.
85 if (!result_bitmap_) 94 if (!result_bitmap_)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 scoped_ptr<SoftwareOutputDevice> device(new SoftwareOutputDevice()); 130 scoped_ptr<SoftwareOutputDevice> device(new SoftwareOutputDevice());
122 output_surface_.reset(new OutputSurface(device.Pass())); 131 output_surface_.reset(new OutputSurface(device.Pass()));
123 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); 132 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
124 renderer_ = SoftwareRenderer::Create( 133 renderer_ = SoftwareRenderer::Create(
125 fake_client_.get(), 134 fake_client_.get(),
126 output_surface_.get(), 135 output_surface_.get(),
127 resource_provider_.get()).PassAs<DirectRenderer>(); 136 resource_provider_.get()).PassAs<DirectRenderer>();
128 } 137 }
129 138
130 } // namespace cc 139 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/pixel_test.h ('k') | cc/test/test_web_graphics_context_3d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698