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

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

Issue 14135011: cc: Add software renderer pixel tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fuzzy only for software 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') | no next file » | 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 "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"
11 #include "cc/output/software_renderer.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"
17 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 18 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
18 19
19 namespace cc { 20 namespace cc {
20 21
(...skipping 22 matching lines...) Expand all
43 } 44 }
44 virtual bool AllowPartialSwap() const OVERRIDE { 45 virtual bool AllowPartialSwap() const OVERRIDE {
45 return true; 46 return true;
46 } 47 }
47 48
48 private: 49 private:
49 gfx::Size device_viewport_size_; 50 gfx::Size device_viewport_size_;
50 LayerTreeSettings settings_; 51 LayerTreeSettings settings_;
51 }; 52 };
52 53
53 PixelTest::PixelTest() : device_viewport_size_(gfx::Size(200, 200)) {} 54 PixelTest::PixelTest()
55 : device_viewport_size_(gfx::Size(200, 200)),
56 fake_client_(new PixelTestRendererClient(device_viewport_size_)) {}
54 57
55 PixelTest::~PixelTest() {} 58 PixelTest::~PixelTest() {}
56 59
57 void PixelTest::SetUp() {
58 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
59
60 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
61 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d(
62 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
63 WebKit::WebGraphicsContext3D::Attributes()));
64 output_surface_.reset(new OutputSurface(
65 context3d.PassAs<WebKit::WebGraphicsContext3D>()));
66 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
67 fake_client_ =
68 make_scoped_ptr(new PixelTestRendererClient(device_viewport_size_));
69 renderer_ = GLRenderer::Create(fake_client_.get(),
70 output_surface_.get(),
71 resource_provider_.get(),
72 0);
73
74 scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts =
75 webkit::gpu::ContextProviderInProcess::Create();
76 ASSERT_TRUE(offscreen_contexts->BindToCurrentThread());
77 resource_provider_->set_offscreen_context_provider(offscreen_contexts);
78 }
79
80 bool PixelTest::RunPixelTest(RenderPassList* pass_list, 60 bool PixelTest::RunPixelTest(RenderPassList* pass_list,
81 const base::FilePath& ref_file, 61 const base::FilePath& ref_file,
82 const PixelComparator& comparator) { 62 const PixelComparator& comparator) {
83 pass_list->back()->copy_callbacks.push_back( 63 pass_list->back()->copy_callbacks.push_back(
84 base::Bind(&PixelTest::ReadbackResult, base::Unretained(this))); 64 base::Bind(&PixelTest::ReadbackResult, base::Unretained(this)));
85 65
86 renderer_->DecideRenderPassAllocationsForFrame(*pass_list); 66 renderer_->DecideRenderPassAllocationsForFrame(*pass_list);
87 renderer_->DrawFrame(pass_list); 67 renderer_->DrawFrame(pass_list);
88 68
89 // TODO(danakj): When the glReadPixels is async, wait for it to finish. 69 // TODO(danakj): When the glReadPixels is async, wait for it to finish.
(...skipping 16 matching lines...) Expand all
106 return false; 86 return false;
107 87
108 // To rebaseline: 88 // To rebaseline:
109 // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true); 89 // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true);
110 90
111 return MatchesPNGFile(*result_bitmap_, 91 return MatchesPNGFile(*result_bitmap_,
112 test_data_dir.Append(ref_file), 92 test_data_dir.Append(ref_file),
113 comparator); 93 comparator);
114 } 94 }
115 95
96 void PixelTest::SetUpGLRenderer() {
97 CHECK(fake_client_);
98 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
99
100 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
101 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d(
102 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
103 WebKit::WebGraphicsContext3D::Attributes()));
104 output_surface_.reset(new OutputSurface(
105 context3d.PassAs<WebKit::WebGraphicsContext3D>()));
106 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
107 renderer_ = GLRenderer::Create(fake_client_.get(),
108 output_surface_.get(),
109 resource_provider_.get(),
110 0).PassAs<DirectRenderer>();
111
112 scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts =
113 webkit::gpu::ContextProviderInProcess::Create();
114 ASSERT_TRUE(offscreen_contexts->BindToCurrentThread());
115 resource_provider_->set_offscreen_context_provider(offscreen_contexts);
116 }
117
118 void PixelTest::SetUpSoftwareRenderer() {
119 CHECK(fake_client_);
120
121 scoped_ptr<SoftwareOutputDevice> device(new SoftwareOutputDevice());
122 output_surface_.reset(new OutputSurface(device.Pass()));
123 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
124 renderer_ = SoftwareRenderer::Create(
125 fake_client_.get(),
126 output_surface_.get(),
127 resource_provider_.get()).PassAs<DirectRenderer>();
128 }
129
116 } // namespace cc 130 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/pixel_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698