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

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

Issue 2602563002: Refactor DrawTextureQuad and CheckPixels in gl_tests util (Closed)
Patch Set: rebase only Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 TEST_P(GLClearFramebufferTest, ClearColor) { 120 TEST_P(GLClearFramebufferTest, ClearColor) {
121 if (!IsApplicable()) { 121 if (!IsApplicable()) {
122 return; 122 return;
123 } 123 }
124 124
125 glClearColor(1.0f, 0.5f, 0.25f, 0.5f); 125 glClearColor(1.0f, 0.5f, 0.25f, 0.5f);
126 glClear(GL_COLOR_BUFFER_BIT); 126 glClear(GL_COLOR_BUFFER_BIT);
127 127
128 // Verify. 128 // Verify.
129 const uint8_t expected[] = {255, 128, 64, 128}; 129 const uint8_t expected[] = {255, 128, 64, 128};
130 EXPECT_TRUE( 130 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected,
131 GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected)); 131 nullptr));
132 } 132 }
133 133
134 TEST_P(GLClearFramebufferTest, ClearColorWithMask) { 134 TEST_P(GLClearFramebufferTest, ClearColorWithMask) {
135 if (!IsApplicable()) { 135 if (!IsApplicable()) {
136 return; 136 return;
137 } 137 }
138 138
139 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 139 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
140 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 140 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
141 glClear(GL_COLOR_BUFFER_BIT); 141 glClear(GL_COLOR_BUFFER_BIT);
142 142
143 // Verify. 143 // Verify.
144 const uint8_t expected[] = {255, 0, 0, 0}; 144 const uint8_t expected[] = {255, 0, 0, 0};
145 EXPECT_TRUE( 145 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected,
146 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); 146 nullptr));
147 } 147 }
148 148
149 // crbug.com/434094 149 // crbug.com/434094
150 #if !defined(OS_MACOSX) 150 #if !defined(OS_MACOSX)
151 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) { 151 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) {
152 if (!IsApplicable()) { 152 if (!IsApplicable()) {
153 return; 153 return;
154 } 154 }
155 155
156 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 156 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
157 glClear(GL_COLOR_BUFFER_BIT); 157 glClear(GL_COLOR_BUFFER_BIT);
158 158
159 // Verify. 159 // Verify.
160 const uint8_t expected[] = {255, 255, 255, 255}; 160 const uint8_t expected[] = {255, 255, 255, 255};
161 EXPECT_TRUE( 161 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected,
162 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); 162 nullptr));
163 163
164 glScissor(0, 0, 0, 0); 164 glScissor(0, 0, 0, 0);
165 glEnable(GL_SCISSOR_TEST); 165 glEnable(GL_SCISSOR_TEST);
166 glClearColor(0, 0, 0, 0); 166 glClearColor(0, 0, 0, 0);
167 glClear(GL_COLOR_BUFFER_BIT); 167 glClear(GL_COLOR_BUFFER_BIT);
168 168
169 // Verify - no changes. 169 // Verify - no changes.
170 EXPECT_TRUE( 170 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected,
171 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); 171 nullptr));
172 } 172 }
173 #endif 173 #endif
174 174
175 TEST_P(GLClearFramebufferTest, ClearDepthStencil) { 175 TEST_P(GLClearFramebufferTest, ClearDepthStencil) {
176 if (!IsApplicable()) { 176 if (!IsApplicable()) {
177 return; 177 return;
178 } 178 }
179 179
180 const GLuint kStencilRef = 1 << 2; 180 const GLuint kStencilRef = 1 << 2;
181 InitDraw(); 181 InitDraw();
182 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); 182 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f);
183 DrawQuad(); 183 DrawQuad();
184 // Verify. 184 // Verify.
185 const uint8_t kRed[] = {255, 0, 0, 255}; 185 const uint8_t kRed[] = {255, 0, 0, 255};
186 const uint8_t kGreen[] = {0, 255, 0, 255}; 186 const uint8_t kGreen[] = {0, 255, 0, 255};
187 EXPECT_TRUE( 187 EXPECT_TRUE(
188 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); 188 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr));
189 189
190 glClearStencil(kStencilRef); 190 glClearStencil(kStencilRef);
191 glClear(GL_STENCIL_BUFFER_BIT); 191 glClear(GL_STENCIL_BUFFER_BIT);
192 glEnable(GL_STENCIL_TEST); 192 glEnable(GL_STENCIL_TEST);
193 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 193 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
194 glStencilFunc(GL_NOTEQUAL, kStencilRef, 0xFFFFFFFF); 194 glStencilFunc(GL_NOTEQUAL, kStencilRef, 0xFFFFFFFF);
195 195
196 SetDrawColor(0.0f, 1.0f, 0.0f, 1.0f); 196 SetDrawColor(0.0f, 1.0f, 0.0f, 1.0f);
197 DrawQuad(); 197 DrawQuad();
198 // Verify - stencil should have failed, so still red. 198 // Verify - stencil should have failed, so still red.
199 EXPECT_TRUE( 199 EXPECT_TRUE(
200 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); 200 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr));
201 201
202 glStencilFunc(GL_EQUAL, kStencilRef, 0xFFFFFFFF); 202 glStencilFunc(GL_EQUAL, kStencilRef, 0xFFFFFFFF);
203 DrawQuad(); 203 DrawQuad();
204 // Verify - stencil should have passed, so green. 204 // Verify - stencil should have passed, so green.
205 EXPECT_TRUE( 205 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kGreen,
206 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kGreen)); 206 nullptr));
207 207
208 glEnable(GL_DEPTH_TEST); 208 glEnable(GL_DEPTH_TEST);
209 glClearDepthf(0.0f); 209 glClearDepthf(0.0f);
210 glClear(GL_DEPTH_BUFFER_BIT); 210 glClear(GL_DEPTH_BUFFER_BIT);
211 211
212 SetDrawDepth(0.5f); 212 SetDrawDepth(0.5f);
213 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); 213 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f);
214 DrawQuad(); 214 DrawQuad();
215 // Verify - depth test should have failed, so still green. 215 // Verify - depth test should have failed, so still green.
216 EXPECT_TRUE( 216 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kGreen,
217 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kGreen)); 217 nullptr));
218 218
219 glClearDepthf(0.9f); 219 glClearDepthf(0.9f);
220 glClear(GL_DEPTH_BUFFER_BIT); 220 glClear(GL_DEPTH_BUFFER_BIT);
221 DrawQuad(); 221 DrawQuad();
222 // Verify - depth test should have passed, so red. 222 // Verify - depth test should have passed, so red.
223 EXPECT_TRUE( 223 EXPECT_TRUE(
224 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); 224 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr));
225 } 225 }
226 226
227 } // namespace gpu 227 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698