OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
no sievers
2016/04/05 19:02:41
#include <memory>
Mostyn Bramley-Moore
2016/04/05 21:35:32
Done.
| |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "gpu/command_buffer/service/gpu_switches.h" | 12 #include "gpu/command_buffer/service/gpu_switches.h" |
13 #include "gpu/command_buffer/tests/gl_manager.h" | 13 #include "gpu/command_buffer/tests/gl_manager.h" |
14 #include "gpu/command_buffer/tests/gl_test_utils.h" | 14 #include "gpu/command_buffer/tests/gl_test_utils.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 #define SHADER(Src) #Src | 18 #define SHADER(Src) #Src |
19 | 19 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 // The test tests that CoverageModulation call works. | 166 // The test tests that CoverageModulation call works. |
167 // The fractional pixels of both triangles end up being modulated | 167 // The fractional pixels of both triangles end up being modulated |
168 // by the coverage of the fragment. Test that drawing with and without | 168 // by the coverage of the fragment. Test that drawing with and without |
169 // CoverageModulation causes the result to be different. | 169 // CoverageModulation causes the result to be different. |
170 TEST_F(CHROMIUMFramebufferMixedSamplesTest, CoverageModulation) { | 170 TEST_F(CHROMIUMFramebufferMixedSamplesTest, CoverageModulation) { |
171 if (!IsApplicable()) { | 171 if (!IsApplicable()) { |
172 return; | 172 return; |
173 } | 173 } |
174 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; | 174 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; |
175 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; | 175 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; |
176 scoped_ptr<uint8_t[]> results[3]; | 176 std::unique_ptr<uint8_t[]> results[3]; |
177 const GLint kResultSize = kWidth * kHeight * 4; | 177 const GLint kResultSize = kWidth * kHeight * 4; |
178 | 178 |
179 for (int pass = 0; pass < 3; ++pass) { | 179 for (int pass = 0; pass < 3; ++pass) { |
180 SetupState(MixedSampleFBO); | 180 SetupState(MixedSampleFBO); |
181 if (pass == 1) { | 181 if (pass == 1) { |
182 glCoverageModulationCHROMIUM(GL_RGBA); | 182 glCoverageModulationCHROMIUM(GL_RGBA); |
183 } | 183 } |
184 glUniform4fv(color_loc_, 1, kGreen); | 184 glUniform4fv(color_loc_, 1, kGreen); |
185 glDrawArrays(GL_TRIANGLES, 0, 3); | 185 glDrawArrays(GL_TRIANGLES, 0, 3); |
186 | 186 |
(...skipping 19 matching lines...) Expand all Loading... | |
206 // color buffer is single-sampled. Draws the same pattern with single-sample | 206 // color buffer is single-sampled. Draws the same pattern with single-sample |
207 // stencil buffer and with multisample stencil buffer. The images should differ. | 207 // stencil buffer and with multisample stencil buffer. The images should differ. |
208 TEST_F(CHROMIUMFramebufferMixedSamplesTest, MultisampleStencilEffective) { | 208 TEST_F(CHROMIUMFramebufferMixedSamplesTest, MultisampleStencilEffective) { |
209 if (!IsApplicable()) { | 209 if (!IsApplicable()) { |
210 return; | 210 return; |
211 } | 211 } |
212 | 212 |
213 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; | 213 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; |
214 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; | 214 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; |
215 | 215 |
216 scoped_ptr<uint8_t[]> results[3]; | 216 std::unique_ptr<uint8_t[]> results[3]; |
217 const GLint kResultSize = kWidth * kHeight * 4; | 217 const GLint kResultSize = kWidth * kHeight * 4; |
218 | 218 |
219 for (int pass = 0; pass < 3; ++pass) { | 219 for (int pass = 0; pass < 3; ++pass) { |
220 if (pass == 1) { | 220 if (pass == 1) { |
221 SetupState(MixedSampleFBO); | 221 SetupState(MixedSampleFBO); |
222 } else { | 222 } else { |
223 SetupState(SingleSampleFBO); | 223 SetupState(SingleSampleFBO); |
224 } | 224 } |
225 glUniform4fv(color_loc_, 1, kGreen); | 225 glUniform4fv(color_loc_, 1, kGreen); |
226 glDrawArrays(GL_TRIANGLES, 0, 3); | 226 glDrawArrays(GL_TRIANGLES, 0, 3); |
227 | 227 |
228 glUniform4fv(color_loc_, 1, kBlue); | 228 glUniform4fv(color_loc_, 1, kBlue); |
229 glDrawArrays(GL_TRIANGLES, 3, 3); | 229 glDrawArrays(GL_TRIANGLES, 3, 3); |
230 | 230 |
231 results[pass].reset(new uint8_t[kResultSize]); | 231 results[pass].reset(new uint8_t[kResultSize]); |
232 memset(results[pass].get(), GLTestHelper::kCheckClearValue, kResultSize); | 232 memset(results[pass].get(), GLTestHelper::kCheckClearValue, kResultSize); |
233 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | 233 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, |
234 results[pass].get()); | 234 results[pass].get()); |
235 } | 235 } |
236 | 236 |
237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); | 237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); |
238 // Verify that rendering is deterministic, so that the pass above does not | 238 // Verify that rendering is deterministic, so that the pass above does not |
239 // come from non-deterministic rendering. | 239 // come from non-deterministic rendering. |
240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); | 240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); |
241 } | 241 } |
242 | 242 |
243 } // namespace gpu | 243 } // namespace gpu |
OLD | NEW |