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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h>
9 #include <stdint.h>
8 #include <cmath> 10 #include <cmath>
9 11
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "gpu/command_buffer/service/gpu_switches.h" 13 #include "gpu/command_buffer/service/gpu_switches.h"
12 #include "gpu/command_buffer/tests/gl_manager.h" 14 #include "gpu/command_buffer/tests/gl_manager.h"
13 #include "gpu/command_buffer/tests/gl_test_utils.h" 15 #include "gpu/command_buffer/tests/gl_test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 #define SHADER(Src) #Src 19 #define SHADER(Src) #Src
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 glPathParameteriCHROMIUM(path, GL_PATH_JOIN_STYLE_CHROMIUM, 143 glPathParameteriCHROMIUM(path, GL_PATH_JOIN_STYLE_CHROMIUM,
142 GL_ROUND_CHROMIUM); 144 GL_ROUND_CHROMIUM);
143 glPathParameteriCHROMIUM(path, GL_PATH_END_CAPS_CHROMIUM, 145 glPathParameteriCHROMIUM(path, GL_PATH_END_CAPS_CHROMIUM,
144 GL_SQUARE_CHROMIUM); 146 GL_SQUARE_CHROMIUM);
145 } 147 }
146 148
147 void VerifyTestPatternFill(float x, float y) { 149 void VerifyTestPatternFill(float x, float y) {
148 SCOPED_TRACE(testing::Message() << "Verifying fill at " << x << "," << y); 150 SCOPED_TRACE(testing::Message() << "Verifying fill at " << x << "," << y);
149 static const float kFillCoords[] = {55.0f, 54.0f, 50.0f, 151 static const float kFillCoords[] = {55.0f, 54.0f, 50.0f,
150 28.0f, 66.0f, 63.0f}; 152 28.0f, 66.0f, 63.0f};
151 static const uint8 kBlue[] = {0, 0, 255, 255}; 153 static const uint8_t kBlue[] = {0, 0, 255, 255};
152 154
153 for (size_t i = 0; i < arraysize(kFillCoords); i += 2) { 155 for (size_t i = 0; i < arraysize(kFillCoords); i += 2) {
154 float fx = kFillCoords[i]; 156 float fx = kFillCoords[i];
155 float fy = kFillCoords[i + 1]; 157 float fy = kFillCoords[i + 1];
156 158
157 EXPECT_TRUE(GLTestHelper::CheckPixels(x + fx, y + fy, 1, 1, 0, kBlue)); 159 EXPECT_TRUE(GLTestHelper::CheckPixels(x + fx, y + fy, 1, 1, 0, kBlue));
158 } 160 }
159 } 161 }
160 162
161 void VerifyTestPatternBg(float x, float y) { 163 void VerifyTestPatternBg(float x, float y) {
162 SCOPED_TRACE(testing::Message() << "Verifying background at " << x << "," 164 SCOPED_TRACE(testing::Message() << "Verifying background at " << x << ","
163 << y); 165 << y);
164 const float kBackgroundCoords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f}; 166 const float kBackgroundCoords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f};
165 const uint8 kExpectedColor[] = {0, 0, 0, 0}; 167 const uint8_t kExpectedColor[] = {0, 0, 0, 0};
166 168
167 for (size_t i = 0; i < arraysize(kBackgroundCoords); i += 2) { 169 for (size_t i = 0; i < arraysize(kBackgroundCoords); i += 2) {
168 float bx = kBackgroundCoords[i]; 170 float bx = kBackgroundCoords[i];
169 float by = kBackgroundCoords[i + 1]; 171 float by = kBackgroundCoords[i + 1];
170 172
171 EXPECT_TRUE( 173 EXPECT_TRUE(
172 GLTestHelper::CheckPixels(x + bx, y + by, 1, 1, 0, kExpectedColor)); 174 GLTestHelper::CheckPixels(x + bx, y + by, 1, 1, 0, kExpectedColor));
173 } 175 }
174 } 176 }
175 177
176 void VerifyTestPatternStroke(float x, float y) { 178 void VerifyTestPatternStroke(float x, float y) {
177 SCOPED_TRACE(testing::Message() << "Verifying stroke at " << x << "," << y); 179 SCOPED_TRACE(testing::Message() << "Verifying stroke at " << x << "," << y);
178 // Inside the stroke we should have green. 180 // Inside the stroke we should have green.
179 const uint8 kGreen[] = {0, 255, 0, 255}; 181 const uint8_t kGreen[] = {0, 255, 0, 255};
180 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 50, y + 53, 1, 1, 0, kGreen)); 182 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 50, y + 53, 1, 1, 0, kGreen));
181 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 26, y + 76, 1, 1, 0, kGreen)); 183 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 26, y + 76, 1, 1, 0, kGreen));
182 184
183 // Outside the path we should have black. 185 // Outside the path we should have black.
184 const uint8 black[] = {0, 0, 0, 0}; 186 const uint8_t black[] = {0, 0, 0, 0};
185 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 10, y + 10, 1, 1, 0, black)); 187 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 10, y + 10, 1, 1, 0, black));
186 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 80, y + 80, 1, 1, 0, black)); 188 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 80, y + 80, 1, 1, 0, black));
187 } 189 }
188 static const GLfloat kProjectionMatrix[16]; 190 static const GLfloat kProjectionMatrix[16];
189 GLint color_loc_; 191 GLint color_loc_;
190 }; 192 };
191 193
192 const GLfloat CHROMIUMPathRenderingDrawTest::kProjectionMatrix[16] = { 194 const GLfloat CHROMIUMPathRenderingDrawTest::kProjectionMatrix[16] = {
193 2.0f / (CHROMIUMPathRenderingTest::kResolution - 1), 195 2.0f / (CHROMIUMPathRenderingTest::kResolution - 1),
194 0.0f, 196 0.0f,
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // Document a bit of an inconsistency: "clearing" a used path name causes 449 // Document a bit of an inconsistency: "clearing" a used path name causes
448 // path to acquire state. 450 // path to acquire state.
449 path = glGenPathsCHROMIUM(1); 451 path = glGenPathsCHROMIUM(1);
450 EXPECT_FALSE(glIsPathCHROMIUM(path)); 452 EXPECT_FALSE(glIsPathCHROMIUM(path));
451 glPathCommandsCHROMIUM(path, 0, NULL, 0, GL_FLOAT, NULL); 453 glPathCommandsCHROMIUM(path, 0, NULL, 0, GL_FLOAT, NULL);
452 EXPECT_TRUE(glIsPathCHROMIUM(path)); // The surprise. 454 EXPECT_TRUE(glIsPathCHROMIUM(path)); // The surprise.
453 glDeletePathsCHROMIUM(path, 1); 455 glDeletePathsCHROMIUM(path, 1);
454 456
455 // Make sure nothing got drawn by the drawing commands that should not produce 457 // Make sure nothing got drawn by the drawing commands that should not produce
456 // anything. 458 // anything.
457 const uint8 black[] = {0, 0, 0, 0}; 459 const uint8_t black[] = {0, 0, 0, 0};
458 EXPECT_TRUE( 460 EXPECT_TRUE(
459 GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 0, black)); 461 GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 0, black));
460 } 462 }
461 463
462 TEST_F(CHROMIUMPathRenderingTest, TestUnnamedPathsErrors) { 464 TEST_F(CHROMIUMPathRenderingTest, TestUnnamedPathsErrors) {
463 if (!IsApplicable()) 465 if (!IsApplicable())
464 return; 466 return;
465 467
466 // Unnamed paths: Trying to create a path object with non-existing path name 468 // Unnamed paths: Trying to create a path object with non-existing path name
467 // produces error. (Not a error in real NV_path_rendering). 469 // produces error. (Not a error in real NV_path_rendering).
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 for (int j = 0; j < kTestRows; ++j) { 1074 for (int j = 0; j < kTestRows; ++j) {
1073 for (int i = 0; i < kTestColumns; ++i) { 1075 for (int i = 0; i < kTestColumns; ++i) {
1074 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { 1076 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
1075 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i 1077 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
1076 << ", " << j << " coord " << k); 1078 << ", " << j << " coord " << k);
1077 float fx = kFillCoords[k]; 1079 float fx = kFillCoords[k];
1078 float fy = kFillCoords[k + 1]; 1080 float fy = kFillCoords[k + 1];
1079 float px = i * kShapeWidth; 1081 float px = i * kShapeWidth;
1080 float py = j * kShapeHeight; 1082 float py = j * kShapeHeight;
1081 1083
1082 uint8 color[4]; 1084 uint8_t color[4];
1083 color[0] = roundf((px + fx) / kResolution * 255.0f); 1085 color[0] = roundf((px + fx) / kResolution * 255.0f);
1084 color[1] = roundf((py + fy) / kResolution * 255.0f); 1086 color[1] = roundf((py + fy) / kResolution * 255.0f);
1085 color[2] = 0; 1087 color[2] = 0;
1086 color[3] = 255; 1088 color[3] = 255;
1087 1089
1088 EXPECT_TRUE( 1090 EXPECT_TRUE(
1089 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); 1091 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color));
1090 } 1092 }
1091 } 1093 }
1092 } 1094 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 for (int j = 0; j < kTestRows; ++j) { 1174 for (int j = 0; j < kTestRows; ++j) {
1173 for (int i = 0; i < kTestColumns; ++i) { 1175 for (int i = 0; i < kTestColumns; ++i) {
1174 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { 1176 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
1175 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i 1177 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
1176 << ", " << j << " coord " << k); 1178 << ", " << j << " coord " << k);
1177 float fx = kFillCoords[k]; 1179 float fx = kFillCoords[k];
1178 float fy = kFillCoords[k + 1]; 1180 float fy = kFillCoords[k + 1];
1179 float px = i * kShapeWidth; 1181 float px = i * kShapeWidth;
1180 float py = j * kShapeHeight; 1182 float py = j * kShapeHeight;
1181 1183
1182 uint8 color[4]; 1184 uint8_t color[4];
1183 color[0] = roundf(fx / kShapeWidth * 255.0f); 1185 color[0] = roundf(fx / kShapeWidth * 255.0f);
1184 color[1] = roundf(fy / kShapeHeight * 255.0f); 1186 color[1] = roundf(fy / kShapeHeight * 255.0f);
1185 color[2] = 0; 1187 color[2] = 0;
1186 color[3] = 255; 1188 color[3] = 255;
1187 1189
1188 EXPECT_TRUE( 1190 EXPECT_TRUE(
1189 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); 1191 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color));
1190 } 1192 }
1191 } 1193 }
1192 } 1194 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 for (int j = 0; j < kTestRows; ++j) { 1577 for (int j = 0; j < kTestRows; ++j) {
1576 for (int i = 0; i < kTestColumns; ++i) { 1578 for (int i = 0; i < kTestColumns; ++i) {
1577 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { 1579 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
1578 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i 1580 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
1579 << ", " << j << " coord " << k); 1581 << ", " << j << " coord " << k);
1580 float fx = kFillCoords[k]; 1582 float fx = kFillCoords[k];
1581 float fy = kFillCoords[k + 1]; 1583 float fy = kFillCoords[k + 1];
1582 float px = i * kShapeWidth; 1584 float px = i * kShapeWidth;
1583 float py = j * kShapeHeight; 1585 float py = j * kShapeHeight;
1584 1586
1585 uint8 color[4] = {0, 255, 0, 255}; 1587 uint8_t color[4] = {0, 255, 0, 255};
1586 1588
1587 EXPECT_TRUE( 1589 EXPECT_TRUE(
1588 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); 1590 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color));
1589 } 1591 }
1590 } 1592 }
1591 } 1593 }
1592 TeardownStateForTestPattern(); 1594 TeardownStateForTestPattern();
1593 } 1595 }
1594 1596
1595 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 1597 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 for (int j = 0; j < kTestRows; ++j) { 1671 for (int j = 0; j < kTestRows; ++j) {
1670 for (int i = 0; i < kTestColumns; ++i) { 1672 for (int i = 0; i < kTestColumns; ++i) {
1671 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { 1673 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
1672 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i 1674 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
1673 << ", " << j << " coord " << k); 1675 << ", " << j << " coord " << k);
1674 float fx = kFillCoords[k]; 1676 float fx = kFillCoords[k];
1675 float fy = kFillCoords[k + 1]; 1677 float fy = kFillCoords[k + 1];
1676 float px = i * kShapeWidth; 1678 float px = i * kShapeWidth;
1677 float py = j * kShapeHeight; 1679 float py = j * kShapeHeight;
1678 1680
1679 uint8 color[4] = {0, 255, 0, 255}; 1681 uint8_t color[4] = {0, 255, 0, 255};
1680 1682
1681 EXPECT_TRUE( 1683 EXPECT_TRUE(
1682 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); 1684 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color));
1683 } 1685 }
1684 } 1686 }
1685 } 1687 }
1686 1688
1687 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 1689 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
1688 TeardownStateForTestPattern(); 1690 TeardownStateForTestPattern();
1689 } 1691 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 glProgramPathFragmentInputGenCHROMIUM(program, kUnboundLocation, 1773 glProgramPathFragmentInputGenCHROMIUM(program, kUnboundLocation,
1772 GL_CONSTANT_CHROMIUM, 4, kColor); 1774 GL_CONSTANT_CHROMIUM, 4, kColor);
1773 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); 1775 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
1774 } 1776 }
1775 1777
1776 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, 1778 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping,
1777 CHROMIUMPathRenderingWithTexturingTest, 1779 CHROMIUMPathRenderingWithTexturingTest,
1778 ::testing::Bool()); 1780 ::testing::Bool());
1779 1781
1780 } // namespace gpu 1782 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698