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

Side by Side Diff: gpu/command_buffer/tests/gl_chromium_framebuffer_mixed_samples_unittest.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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
OLDNEW
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>
10 10
11 #include <memory>
12
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "gpu/command_buffer/service/gpu_switches.h" 14 #include "gpu/command_buffer/service/gpu_switches.h"
13 #include "gpu/command_buffer/tests/gl_manager.h" 15 #include "gpu/command_buffer/tests/gl_manager.h"
14 #include "gpu/command_buffer/tests/gl_test_utils.h" 16 #include "gpu/command_buffer/tests/gl_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 #define SHADER(Src) #Src 20 #define SHADER(Src) #Src
19 21
20 namespace gpu { 22 namespace gpu {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // The test tests that CoverageModulation call works. 168 // The test tests that CoverageModulation call works.
167 // The fractional pixels of both triangles end up being modulated 169 // The fractional pixels of both triangles end up being modulated
168 // by the coverage of the fragment. Test that drawing with and without 170 // by the coverage of the fragment. Test that drawing with and without
169 // CoverageModulation causes the result to be different. 171 // CoverageModulation causes the result to be different.
170 TEST_F(CHROMIUMFramebufferMixedSamplesTest, CoverageModulation) { 172 TEST_F(CHROMIUMFramebufferMixedSamplesTest, CoverageModulation) {
171 if (!IsApplicable()) { 173 if (!IsApplicable()) {
172 return; 174 return;
173 } 175 }
174 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; 176 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}; 177 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f};
176 scoped_ptr<uint8_t[]> results[3]; 178 std::unique_ptr<uint8_t[]> results[3];
177 const GLint kResultSize = kWidth * kHeight * 4; 179 const GLint kResultSize = kWidth * kHeight * 4;
178 180
179 for (int pass = 0; pass < 3; ++pass) { 181 for (int pass = 0; pass < 3; ++pass) {
180 SetupState(MixedSampleFBO); 182 SetupState(MixedSampleFBO);
181 if (pass == 1) { 183 if (pass == 1) {
182 glCoverageModulationCHROMIUM(GL_RGBA); 184 glCoverageModulationCHROMIUM(GL_RGBA);
183 } 185 }
184 glUniform4fv(color_loc_, 1, kGreen); 186 glUniform4fv(color_loc_, 1, kGreen);
185 glDrawArrays(GL_TRIANGLES, 0, 3); 187 glDrawArrays(GL_TRIANGLES, 0, 3);
186 188
(...skipping 19 matching lines...) Expand all
206 // color buffer is single-sampled. Draws the same pattern with single-sample 208 // color buffer is single-sampled. Draws the same pattern with single-sample
207 // stencil buffer and with multisample stencil buffer. The images should differ. 209 // stencil buffer and with multisample stencil buffer. The images should differ.
208 TEST_F(CHROMIUMFramebufferMixedSamplesTest, MultisampleStencilEffective) { 210 TEST_F(CHROMIUMFramebufferMixedSamplesTest, MultisampleStencilEffective) {
209 if (!IsApplicable()) { 211 if (!IsApplicable()) {
210 return; 212 return;
211 } 213 }
212 214
213 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; 215 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}; 216 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f};
215 217
216 scoped_ptr<uint8_t[]> results[3]; 218 std::unique_ptr<uint8_t[]> results[3];
217 const GLint kResultSize = kWidth * kHeight * 4; 219 const GLint kResultSize = kWidth * kHeight * 4;
218 220
219 for (int pass = 0; pass < 3; ++pass) { 221 for (int pass = 0; pass < 3; ++pass) {
220 if (pass == 1) { 222 if (pass == 1) {
221 SetupState(MixedSampleFBO); 223 SetupState(MixedSampleFBO);
222 } else { 224 } else {
223 SetupState(SingleSampleFBO); 225 SetupState(SingleSampleFBO);
224 } 226 }
225 glUniform4fv(color_loc_, 1, kGreen); 227 glUniform4fv(color_loc_, 1, kGreen);
226 glDrawArrays(GL_TRIANGLES, 0, 3); 228 glDrawArrays(GL_TRIANGLES, 0, 3);
227 229
228 glUniform4fv(color_loc_, 1, kBlue); 230 glUniform4fv(color_loc_, 1, kBlue);
229 glDrawArrays(GL_TRIANGLES, 3, 3); 231 glDrawArrays(GL_TRIANGLES, 3, 3);
230 232
231 results[pass].reset(new uint8_t[kResultSize]); 233 results[pass].reset(new uint8_t[kResultSize]);
232 memset(results[pass].get(), GLTestHelper::kCheckClearValue, kResultSize); 234 memset(results[pass].get(), GLTestHelper::kCheckClearValue, kResultSize);
233 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 235 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
234 results[pass].get()); 236 results[pass].get());
235 } 237 }
236 238
237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); 239 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize));
238 // Verify that rendering is deterministic, so that the pass above does not 240 // Verify that rendering is deterministic, so that the pass above does not
239 // come from non-deterministic rendering. 241 // come from non-deterministic rendering.
240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); 242 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize));
241 } 243 }
242 244
243 } // namespace gpu 245 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698