| OLD | NEW |
| 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> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void VerifyTestPatternFill(float x, float y) { | 147 void VerifyTestPatternFill(float x, float y) { |
| 148 SCOPED_TRACE(testing::Message() << "Verifying fill at " << x << "," << y); | 148 SCOPED_TRACE(testing::Message() << "Verifying fill at " << x << "," << y); |
| 149 static const float kFillCoords[] = {55.0f, 54.0f, 50.0f, | 149 static const float kFillCoords[] = {55.0f, 54.0f, 50.0f, |
| 150 28.0f, 66.0f, 63.0f}; | 150 28.0f, 66.0f, 63.0f}; |
| 151 static const uint8_t kBlue[] = {0, 0, 255, 255}; | 151 static const uint8_t kBlue[] = {0, 0, 255, 255}; |
| 152 | 152 |
| 153 for (size_t i = 0; i < arraysize(kFillCoords); i += 2) { | 153 for (size_t i = 0; i < arraysize(kFillCoords); i += 2) { |
| 154 float fx = kFillCoords[i]; | 154 float fx = kFillCoords[i]; |
| 155 float fy = kFillCoords[i + 1]; | 155 float fy = kFillCoords[i + 1]; |
| 156 | 156 |
| 157 EXPECT_TRUE(GLTestHelper::CheckPixels(x + fx, y + fy, 1, 1, 0, kBlue)); | 157 EXPECT_TRUE( |
| 158 GLTestHelper::CheckPixels(x + fx, y + fy, 1, 1, 0, kBlue, nullptr)); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 void VerifyTestPatternBg(float x, float y) { | 162 void VerifyTestPatternBg(float x, float y) { |
| 162 SCOPED_TRACE(testing::Message() << "Verifying background at " << x << "," | 163 SCOPED_TRACE(testing::Message() << "Verifying background at " << x << "," |
| 163 << y); | 164 << y); |
| 164 const float kBackgroundCoords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f}; | 165 const float kBackgroundCoords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f}; |
| 165 const uint8_t kExpectedColor[] = {0, 0, 0, 0}; | 166 const uint8_t kExpectedColor[] = {0, 0, 0, 0}; |
| 166 | 167 |
| 167 for (size_t i = 0; i < arraysize(kBackgroundCoords); i += 2) { | 168 for (size_t i = 0; i < arraysize(kBackgroundCoords); i += 2) { |
| 168 float bx = kBackgroundCoords[i]; | 169 float bx = kBackgroundCoords[i]; |
| 169 float by = kBackgroundCoords[i + 1]; | 170 float by = kBackgroundCoords[i + 1]; |
| 170 | 171 |
| 171 EXPECT_TRUE( | 172 EXPECT_TRUE(GLTestHelper::CheckPixels(x + bx, y + by, 1, 1, 0, |
| 172 GLTestHelper::CheckPixels(x + bx, y + by, 1, 1, 0, kExpectedColor)); | 173 kExpectedColor, nullptr)); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| 176 void VerifyTestPatternStroke(float x, float y) { | 177 void VerifyTestPatternStroke(float x, float y) { |
| 177 SCOPED_TRACE(testing::Message() << "Verifying stroke at " << x << "," << y); | 178 SCOPED_TRACE(testing::Message() << "Verifying stroke at " << x << "," << y); |
| 178 // Inside the stroke we should have green. | 179 // Inside the stroke we should have green. |
| 179 const uint8_t kGreen[] = {0, 255, 0, 255}; | 180 const uint8_t kGreen[] = {0, 255, 0, 255}; |
| 180 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 50, y + 53, 1, 1, 0, kGreen)); | 181 EXPECT_TRUE( |
| 181 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 26, y + 76, 1, 1, 0, kGreen)); | 182 GLTestHelper::CheckPixels(x + 50, y + 53, 1, 1, 0, kGreen, nullptr)); |
| 183 EXPECT_TRUE( |
| 184 GLTestHelper::CheckPixels(x + 26, y + 76, 1, 1, 0, kGreen, nullptr)); |
| 182 | 185 |
| 183 // Outside the path we should have black. | 186 // Outside the path we should have black. |
| 184 const uint8_t black[] = {0, 0, 0, 0}; | 187 const uint8_t black[] = {0, 0, 0, 0}; |
| 185 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 10, y + 10, 1, 1, 0, black)); | 188 EXPECT_TRUE( |
| 186 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 80, y + 80, 1, 1, 0, black)); | 189 GLTestHelper::CheckPixels(x + 10, y + 10, 1, 1, 0, black, nullptr)); |
| 190 EXPECT_TRUE( |
| 191 GLTestHelper::CheckPixels(x + 80, y + 80, 1, 1, 0, black, nullptr)); |
| 187 } | 192 } |
| 188 static const GLfloat kProjectionMatrix[16]; | 193 static const GLfloat kProjectionMatrix[16]; |
| 189 GLint color_loc_; | 194 GLint color_loc_; |
| 190 }; | 195 }; |
| 191 | 196 |
| 192 const GLfloat CHROMIUMPathRenderingDrawTest::kProjectionMatrix[16] = { | 197 const GLfloat CHROMIUMPathRenderingDrawTest::kProjectionMatrix[16] = { |
| 193 2.0f / (CHROMIUMPathRenderingTest::kResolution - 1), | 198 2.0f / (CHROMIUMPathRenderingTest::kResolution - 1), |
| 194 0.0f, | 199 0.0f, |
| 195 0.0f, | 200 0.0f, |
| 196 0.0f, | 201 0.0f, |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // path to acquire state. | 453 // path to acquire state. |
| 449 path = glGenPathsCHROMIUM(1); | 454 path = glGenPathsCHROMIUM(1); |
| 450 EXPECT_FALSE(glIsPathCHROMIUM(path)); | 455 EXPECT_FALSE(glIsPathCHROMIUM(path)); |
| 451 glPathCommandsCHROMIUM(path, 0, NULL, 0, GL_FLOAT, NULL); | 456 glPathCommandsCHROMIUM(path, 0, NULL, 0, GL_FLOAT, NULL); |
| 452 EXPECT_TRUE(glIsPathCHROMIUM(path)); // The surprise. | 457 EXPECT_TRUE(glIsPathCHROMIUM(path)); // The surprise. |
| 453 glDeletePathsCHROMIUM(path, 1); | 458 glDeletePathsCHROMIUM(path, 1); |
| 454 | 459 |
| 455 // Make sure nothing got drawn by the drawing commands that should not produce | 460 // Make sure nothing got drawn by the drawing commands that should not produce |
| 456 // anything. | 461 // anything. |
| 457 const uint8_t black[] = {0, 0, 0, 0}; | 462 const uint8_t black[] = {0, 0, 0, 0}; |
| 458 EXPECT_TRUE( | 463 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 0, |
| 459 GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 0, black)); | 464 black, nullptr)); |
| 460 } | 465 } |
| 461 | 466 |
| 462 TEST_F(CHROMIUMPathRenderingTest, TestUnnamedPathsErrors) { | 467 TEST_F(CHROMIUMPathRenderingTest, TestUnnamedPathsErrors) { |
| 463 if (!IsApplicable()) | 468 if (!IsApplicable()) |
| 464 return; | 469 return; |
| 465 | 470 |
| 466 // Unnamed paths: Trying to create a path object with non-existing path name | 471 // Unnamed paths: Trying to create a path object with non-existing path name |
| 467 // produces error. (Not a error in real NV_path_rendering). | 472 // produces error. (Not a error in real NV_path_rendering). |
| 468 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 473 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 469 GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM}; | 474 GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM}; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 float fy = kFillCoords[k + 1]; | 1083 float fy = kFillCoords[k + 1]; |
| 1079 float px = i * kShapeWidth; | 1084 float px = i * kShapeWidth; |
| 1080 float py = j * kShapeHeight; | 1085 float py = j * kShapeHeight; |
| 1081 | 1086 |
| 1082 uint8_t color[4]; | 1087 uint8_t color[4]; |
| 1083 color[0] = roundf((px + fx) / kResolution * 255.0f); | 1088 color[0] = roundf((px + fx) / kResolution * 255.0f); |
| 1084 color[1] = roundf((py + fy) / kResolution * 255.0f); | 1089 color[1] = roundf((py + fy) / kResolution * 255.0f); |
| 1085 color[2] = 0; | 1090 color[2] = 0; |
| 1086 color[3] = 255; | 1091 color[3] = 255; |
| 1087 | 1092 |
| 1088 EXPECT_TRUE( | 1093 EXPECT_TRUE(GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color, |
| 1089 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); | 1094 nullptr)); |
| 1090 } | 1095 } |
| 1091 } | 1096 } |
| 1092 } | 1097 } |
| 1093 | 1098 |
| 1094 TeardownStateForTestPattern(); | 1099 TeardownStateForTestPattern(); |
| 1095 | 1100 |
| 1096 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 1101 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1097 } | 1102 } |
| 1098 | 1103 |
| 1099 // This test tests ProgramPathFragmentInputGenCHROMIUM and | 1104 // This test tests ProgramPathFragmentInputGenCHROMIUM and |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 float fy = kFillCoords[k + 1]; | 1183 float fy = kFillCoords[k + 1]; |
| 1179 float px = i * kShapeWidth; | 1184 float px = i * kShapeWidth; |
| 1180 float py = j * kShapeHeight; | 1185 float py = j * kShapeHeight; |
| 1181 | 1186 |
| 1182 uint8_t color[4]; | 1187 uint8_t color[4]; |
| 1183 color[0] = roundf(fx / kShapeWidth * 255.0f); | 1188 color[0] = roundf(fx / kShapeWidth * 255.0f); |
| 1184 color[1] = roundf(fy / kShapeHeight * 255.0f); | 1189 color[1] = roundf(fy / kShapeHeight * 255.0f); |
| 1185 color[2] = 0; | 1190 color[2] = 0; |
| 1186 color[3] = 255; | 1191 color[3] = 255; |
| 1187 | 1192 |
| 1188 EXPECT_TRUE( | 1193 EXPECT_TRUE(GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color, |
| 1189 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); | 1194 nullptr)); |
| 1190 } | 1195 } |
| 1191 } | 1196 } |
| 1192 } | 1197 } |
| 1193 | 1198 |
| 1194 TeardownStateForTestPattern(); | 1199 TeardownStateForTestPattern(); |
| 1195 | 1200 |
| 1196 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 1201 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1197 } | 1202 } |
| 1198 | 1203 |
| 1199 TEST_P(CHROMIUMPathRenderingWithTexturingTest, | 1204 TEST_P(CHROMIUMPathRenderingWithTexturingTest, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { | 1582 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { |
| 1578 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i | 1583 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i |
| 1579 << ", " << j << " coord " << k); | 1584 << ", " << j << " coord " << k); |
| 1580 float fx = kFillCoords[k]; | 1585 float fx = kFillCoords[k]; |
| 1581 float fy = kFillCoords[k + 1]; | 1586 float fy = kFillCoords[k + 1]; |
| 1582 float px = i * kShapeWidth; | 1587 float px = i * kShapeWidth; |
| 1583 float py = j * kShapeHeight; | 1588 float py = j * kShapeHeight; |
| 1584 | 1589 |
| 1585 uint8_t color[4] = {0, 255, 0, 255}; | 1590 uint8_t color[4] = {0, 255, 0, 255}; |
| 1586 | 1591 |
| 1587 EXPECT_TRUE( | 1592 EXPECT_TRUE(GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, |
| 1588 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); | 1593 color, nullptr)); |
| 1589 } | 1594 } |
| 1590 } | 1595 } |
| 1591 } | 1596 } |
| 1592 TeardownStateForTestPattern(); | 1597 TeardownStateForTestPattern(); |
| 1593 } | 1598 } |
| 1594 | 1599 |
| 1595 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 1600 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1596 } | 1601 } |
| 1597 | 1602 |
| 1598 // Test binding with non-zero indices. | 1603 // Test binding with non-zero indices. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { | 1676 for (size_t k = 0; k < arraysize(kFillCoords); k += 2) { |
| 1672 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i | 1677 SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i |
| 1673 << ", " << j << " coord " << k); | 1678 << ", " << j << " coord " << k); |
| 1674 float fx = kFillCoords[k]; | 1679 float fx = kFillCoords[k]; |
| 1675 float fy = kFillCoords[k + 1]; | 1680 float fy = kFillCoords[k + 1]; |
| 1676 float px = i * kShapeWidth; | 1681 float px = i * kShapeWidth; |
| 1677 float py = j * kShapeHeight; | 1682 float py = j * kShapeHeight; |
| 1678 | 1683 |
| 1679 uint8_t color[4] = {0, 255, 0, 255}; | 1684 uint8_t color[4] = {0, 255, 0, 255}; |
| 1680 | 1685 |
| 1681 EXPECT_TRUE( | 1686 EXPECT_TRUE(GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color, |
| 1682 GLTestHelper::CheckPixels(px + fx, py + fy, 1, 1, 2, color)); | 1687 nullptr)); |
| 1683 } | 1688 } |
| 1684 } | 1689 } |
| 1685 } | 1690 } |
| 1686 | 1691 |
| 1687 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 1692 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 1688 TeardownStateForTestPattern(); | 1693 TeardownStateForTestPattern(); |
| 1689 } | 1694 } |
| 1690 | 1695 |
| 1691 TEST_P(CHROMIUMPathRenderingWithTexturingTest, UnusedFragmentInputUpdate) { | 1696 TEST_P(CHROMIUMPathRenderingWithTexturingTest, UnusedFragmentInputUpdate) { |
| 1692 if (!IsApplicable()) | 1697 if (!IsApplicable()) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 glProgramPathFragmentInputGenCHROMIUM(program, kUnboundLocation, | 1776 glProgramPathFragmentInputGenCHROMIUM(program, kUnboundLocation, |
| 1772 GL_CONSTANT_CHROMIUM, 4, kColor); | 1777 GL_CONSTANT_CHROMIUM, 4, kColor); |
| 1773 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); | 1778 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
| 1774 } | 1779 } |
| 1775 | 1780 |
| 1776 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, | 1781 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, |
| 1777 CHROMIUMPathRenderingWithTexturingTest, | 1782 CHROMIUMPathRenderingWithTexturingTest, |
| 1778 ::testing::Bool()); | 1783 ::testing::Bool()); |
| 1779 | 1784 |
| 1780 } // namespace gpu | 1785 } // namespace gpu |
| OLD | NEW |