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 <cmath> | 8 #include <cmath> |
9 | 9 |
| 10 #include "base/strings/stringprintf.h" |
10 #include "gpu/command_buffer/tests/gl_manager.h" | 11 #include "gpu/command_buffer/tests/gl_manager.h" |
11 #include "gpu/command_buffer/tests/gl_test_utils.h" | 12 #include "gpu/command_buffer/tests/gl_test_utils.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
| 16 #define SHADER(Src) #Src |
15 | 17 |
16 namespace gpu { | 18 namespace gpu { |
17 | 19 |
18 class CHROMIUMPathRenderingTest : public testing::Test { | 20 class CHROMIUMPathRenderingTest : public testing::Test { |
19 public: | 21 public: |
20 static const GLsizei kResolution = 100; | 22 static const GLsizei kResolution = 100; |
21 | 23 |
22 protected: | 24 protected: |
23 virtual void SetUp() { | 25 virtual void SetUp() { |
24 GLManager::Options options; | 26 GLManager::Options options; |
25 options.size = gfx::Size(kResolution, kResolution); | 27 options.size = gfx::Size(kResolution, kResolution); |
26 gl_.Initialize(options); | 28 gl_.Initialize(options); |
27 } | 29 } |
28 | 30 |
29 virtual void TearDown() { gl_.Destroy(); } | 31 virtual void TearDown() { gl_.Destroy(); } |
30 | 32 |
31 void ExpectEqualMatrix(const GLfloat* expected, const GLfloat* actual) { | 33 void ExpectEqualMatrix(const GLfloat* expected, const GLfloat* actual) { |
32 for (size_t i = 0; i < 16; ++i) { | 34 for (size_t i = 0; i < 16; ++i) { |
33 EXPECT_EQ(expected[i], actual[i]); | 35 EXPECT_EQ(expected[i], actual[i]); |
34 } | 36 } |
35 } | 37 } |
36 void ExpectEqualMatrix(const GLfloat* expected, const GLint* actual) { | 38 void ExpectEqualMatrix(const GLfloat* expected, const GLint* actual) { |
37 for (size_t i = 0; i < 16; ++i) { | 39 for (size_t i = 0; i < 16; ++i) { |
38 EXPECT_EQ(static_cast<GLint>(round(expected[i])), actual[i]); | 40 EXPECT_EQ(static_cast<GLint>(round(expected[i])), actual[i]); |
39 } | 41 } |
40 } | 42 } |
| 43 |
| 44 void SetupStateForTestPattern() { |
| 45 glViewport(0, 0, kResolution, kResolution); |
| 46 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 47 glStencilMask(0xffffffff); |
| 48 glClearStencil(0); |
| 49 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 50 |
| 51 static const char* v_shader_src = |
| 52 SHADER(void main() { gl_Position = vec4(1); }); |
| 53 static const char* f_shader_src = |
| 54 "#extension GL_CHROMIUM_path_rendering: require\n" SHADER( |
| 55 precision mediump float; |
| 56 void main() { gl_FragColor = gl_TexCoord[0] + gl_TexCoord[1]; }); |
| 57 |
| 58 GLuint program = GLTestHelper::LoadProgram(v_shader_src, f_shader_src); |
| 59 glUseProgram(program); |
| 60 glDeleteProgram(program); |
| 61 |
| 62 // Set up orthogonal projection with near/far plane distance of 2. |
| 63 static GLfloat matrix[16] = { |
| 64 2.0f / (kResolution - 1), 0.0f, 0.0f, 0.0f, |
| 65 0.0f, 2.0f / (kResolution - 1), 0.0f, 0.0f, |
| 66 0.0f, 0.0f, -1.0f, 0.0f, |
| 67 -1.0f, -1.0f, 0.0f, 1.0f}; |
| 68 glMatrixLoadfCHROMIUM(GL_PROJECTION_CHROMIUM, matrix); |
| 69 glMatrixLoadIdentityCHROMIUM(GL_MODELVIEW_CHROMIUM); |
| 70 |
| 71 glEnable(GL_STENCIL_TEST); |
| 72 |
| 73 GLTestHelper::CheckGLError("no errors at state setup", __LINE__); |
| 74 } |
| 75 |
| 76 void SetupPathStateForTestPattern(GLuint path) { |
| 77 GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_LINE_TO_CHROMIUM, |
| 78 GL_QUADRATIC_CURVE_TO_CHROMIUM, |
| 79 GL_CUBIC_CURVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM}; |
| 80 |
| 81 GLfloat coords[] = {50.0f, 50.0f, 75.0f, 75.0f, 100.0f, 62.5f, 50.0f, |
| 82 25.5f, 0.0f, 62.5f, 50.0f, 50.0f, 25.0f, 75.0f}; |
| 83 |
| 84 glPathCommandsCHROMIUM(path, |
| 85 arraysize(commands), |
| 86 commands, |
| 87 arraysize(coords), |
| 88 GL_FLOAT, |
| 89 coords); |
| 90 |
| 91 glPathParameterfCHROMIUM(path, GL_PATH_STROKE_WIDTH_CHROMIUM, 5.0f); |
| 92 glPathParameterfCHROMIUM(path, GL_PATH_MITER_LIMIT_CHROMIUM, 1.0f); |
| 93 glPathParameteriCHROMIUM( |
| 94 path, GL_PATH_JOIN_STYLE_CHROMIUM, GL_ROUND_CHROMIUM); |
| 95 glPathParameteriCHROMIUM( |
| 96 path, GL_PATH_INITIAL_END_CAP_CHROMIUM, GL_SQUARE_CHROMIUM); |
| 97 glPathParameteriCHROMIUM( |
| 98 path, GL_PATH_TERMINAL_END_CAP_CHROMIUM, GL_FLAT_CHROMIUM); |
| 99 } |
| 100 |
| 101 void VerifyTestPatternFill(float x, float y) { |
| 102 // Inside the fill we should have color formed by the texture coordinate set |
| 103 // coefficients. |
| 104 const float fill_coords[] = {55.0f, 55.0f, 50.0f, 28.0f, 66.0f, 63.0f}; |
| 105 |
| 106 for (size_t i = 0; i < arraysize(fill_coords); i += 2) { |
| 107 float fx = fill_coords[i]; |
| 108 float fy = fill_coords[i + 1]; |
| 109 uint8 expected_color[] = { |
| 110 255 * (fx * 1.0f / kResolution - fx * 0.2f / kResolution), |
| 111 255 * (fy * 1.0f / kResolution - fy * 0.2f / kResolution), |
| 112 0, // The calculations cancel each other. |
| 113 255}; |
| 114 // Note: we compare with a bit of tolerance, since CPU float computation |
| 115 // will not always match the shader computation. |
| 116 EXPECT_TRUE( |
| 117 GLTestHelper::CheckPixels(x + fx, y + fy, 1, 1, 2, expected_color)); |
| 118 } |
| 119 } |
| 120 |
| 121 void VerifyTestPatternBg(float x, float y) { |
| 122 const float bg_coords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f}; |
| 123 uint8 expected_color[] = {0, 0, 0, 0}; |
| 124 |
| 125 for (size_t i = 0; i < arraysize(bg_coords); i += 2) { |
| 126 float bx = bg_coords[i]; |
| 127 float by = bg_coords[i + 1]; |
| 128 |
| 129 EXPECT_TRUE( |
| 130 GLTestHelper::CheckPixels(x + bx, y + by, 1, 1, 0, expected_color)); |
| 131 } |
| 132 } |
| 133 |
| 134 void VerifyTestPatternStroke(float x, float y) { |
| 135 // Inside the stroke we should have green. |
| 136 const uint8 green[] = {0, 255, 0, 255}; |
| 137 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 50, y + 53, 1, 1, 0, green)); |
| 138 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 26, y + 76, 1, 1, 0, green)); |
| 139 |
| 140 // Outside the path we should have black. |
| 141 const uint8 black[] = {0, 0, 0, 0}; |
| 142 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 10, y + 10, 1, 1, 0, black)); |
| 143 EXPECT_TRUE(GLTestHelper::CheckPixels(x + 80, y + 80, 1, 1, 0, black)); |
| 144 } |
| 145 |
41 GLManager gl_; | 146 GLManager gl_; |
| 147 static GLfloat fill_coefficients_[3 * 3 * 2]; |
| 148 static GLfloat stroke_coefficients_[3 * 3]; |
| 149 }; |
| 150 |
| 151 GLfloat CHROMIUMPathRenderingTest::fill_coefficients_[] = { |
| 152 1.0f / kResolution, 0.0f, 0.0f, |
| 153 0.0f, 1.0f / kResolution, 0.0f, |
| 154 1.0f / kResolution, 1.0f / kResolution, 0.0f, |
| 155 -0.2f / kResolution, 0.0f, 0.0f, |
| 156 0.0f, -0.2f / kResolution, 0.0f, |
| 157 -1.0f / kResolution, -1.0f / kResolution, 0.0}; |
| 158 |
| 159 // Stroke should be constant green. |
| 160 GLfloat CHROMIUMPathRenderingTest::stroke_coefficients_[] = { |
| 161 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, |
42 }; | 162 }; |
43 | 163 |
44 TEST_F(CHROMIUMPathRenderingTest, TestMatrix) { | 164 TEST_F(CHROMIUMPathRenderingTest, TestMatrix) { |
45 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { | 165 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { |
46 return; | 166 return; |
47 } | 167 } |
48 GLfloat identity_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, | 168 GLfloat identity_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
49 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, | 169 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
50 0.0f, 0.0f, 0.0f, 1.0f}; | 170 0.0f, 0.0f, 0.0f, 1.0f}; |
51 GLfloat seq_matrix[16] = {0.5f, -0.5f, -0.1f, -0.8f, 4.4f, 5.5f, | 171 GLfloat seq_matrix[16] = {0.5f, -0.5f, -0.1f, -0.8f, 4.4f, 5.5f, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 220 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
101 | 221 |
102 // This should fail. | 222 // This should fail. |
103 glMatrixLoadIdentityCHROMIUM(GL_PROJECTION_CHROMIUM + 1); | 223 glMatrixLoadIdentityCHROMIUM(GL_PROJECTION_CHROMIUM + 1); |
104 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError()); | 224 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError()); |
105 | 225 |
106 glMatrixLoadIdentityCHROMIUM(GL_PROJECTION_CHROMIUM); | 226 glMatrixLoadIdentityCHROMIUM(GL_PROJECTION_CHROMIUM); |
107 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 227 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
108 } | 228 } |
109 | 229 |
| 230 TEST_F(CHROMIUMPathRenderingTest, TestTexCoordShader) { |
| 231 static const char* fs_str = |
| 232 "#extension GL_CHROMIUM_path_rendering: require\n" SHADER( |
| 233 precision mediump float; |
| 234 void main() { gl_FragColor = gl_TexCoord[0] + gl_TexCoord[% d]; }); |
| 235 |
| 236 GLint maxTextureCoords = -1; |
| 237 glGetIntegerv(GL_MAX_TEXTURE_COORDS_CHROMIUM, &maxTextureCoords); |
| 238 EXPECT_LT(static_cast<GLint>(0), maxTextureCoords); |
| 239 |
| 240 std::string fs_str_max = base::StringPrintf(fs_str, maxTextureCoords - 1); |
| 241 |
| 242 const char* shader_str = fs_str_max.c_str(); |
| 243 GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); |
| 244 glShaderSource(fs, 1, &shader_str, NULL); |
| 245 glCompileShader(fs); |
| 246 GLint value = 0; |
| 247 glGetShaderiv(fs, GL_COMPILE_STATUS, &value); |
| 248 if (value == 0) { |
| 249 char buffer[1024]; |
| 250 GLsizei length = 0; |
| 251 glGetShaderInfoLog(fs, sizeof(buffer), &length, buffer); |
| 252 std::string log(buffer, length); |
| 253 EXPECT_EQ(1, value) << "Error compiling shader: " << log; |
| 254 } |
| 255 |
| 256 EXPECT_EQ(static_cast<GLint>(1), value); |
| 257 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 258 glDeleteShader(fs); |
| 259 } |
| 260 |
| 261 TEST_F(CHROMIUMPathRenderingTest, TooBigTexCoordShaderFails) { |
| 262 static const char* fs_str = |
| 263 "#extension GL_CHROMIUM_path_rendering: require\n" SHADER( |
| 264 precision mediump float; |
| 265 void main() { gl_FragColor = gl_TexCoord[0] + gl_TexCoord[% d]; }); |
| 266 |
| 267 GLint maxTextureCoords = -1; |
| 268 glGetIntegerv(GL_MAX_TEXTURE_COORDS_CHROMIUM, &maxTextureCoords); |
| 269 EXPECT_LT(static_cast<GLint>(0), maxTextureCoords); |
| 270 |
| 271 // Using too big TexCoord index should fail. |
| 272 std::string fs_str_too_big = base::StringPrintf(fs_str, maxTextureCoords); |
| 273 |
| 274 const char* shader_str = fs_str_too_big.c_str(); |
| 275 GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); |
| 276 GLint value = 0; |
| 277 glShaderSource(fs, 1, &shader_str, NULL); |
| 278 glCompileShader(fs); |
| 279 glGetShaderiv(fs, GL_COMPILE_STATUS, &value); |
| 280 EXPECT_EQ(static_cast<GLint>(0), value); |
| 281 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 282 glDeleteShader(fs); |
| 283 } |
| 284 |
| 285 TEST_F(CHROMIUMPathRenderingTest, NoExtensionTexCoordShaderFails) { |
| 286 static const char* shader_str = SHADER( |
| 287 precision mediump float; void main() { gl_FragColor = gl_TexCoord[0]; }); |
| 288 GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); |
| 289 GLint value = 0; |
| 290 glShaderSource(fs, 1, &shader_str, NULL); |
| 291 glCompileShader(fs); |
| 292 glGetShaderiv(fs, GL_COMPILE_STATUS, &value); |
| 293 EXPECT_EQ(static_cast<GLint>(0), value); |
| 294 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 295 glDeleteShader(fs); |
| 296 } |
| 297 |
| 298 TEST_F(CHROMIUMPathRenderingTest, TestSimpleCalls) { |
| 299 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { |
| 300 return; |
| 301 } |
| 302 |
| 303 GLuint path = glGenPathsCHROMIUM(1); |
| 304 EXPECT_TRUE(path != 0); |
| 305 glDeletePathsCHROMIUM(path, 1); |
| 306 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 307 |
| 308 GLuint firstPath = glGenPathsCHROMIUM(5); |
| 309 EXPECT_TRUE(firstPath != 0); |
| 310 glDeletePathsCHROMIUM(firstPath, 5); |
| 311 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 312 |
| 313 // Test deleting paths that are not actually allocated: |
| 314 // "unused names in /paths/ are silently ignored" |
| 315 firstPath = glGenPathsCHROMIUM(5); |
| 316 EXPECT_TRUE(firstPath != 0); |
| 317 glDeletePathsCHROMIUM(firstPath, 6); |
| 318 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 319 |
| 320 GLint maxTextureCoords = -1; |
| 321 glGetIntegerv(GL_MAX_TEXTURE_COORDS_CHROMIUM, &maxTextureCoords); |
| 322 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 323 EXPECT_LT(static_cast<GLint>(0), maxTextureCoords); |
| 324 } |
| 325 |
| 326 TEST_F(CHROMIUMPathRenderingTest, TestErrors) { |
| 327 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { |
| 328 return; |
| 329 } |
| 330 |
| 331 // This is unspecified. |
| 332 EXPECT_EQ(static_cast<GLuint>(-1), glGenPathsCHROMIUM(0)); |
| 333 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), glGetError()); |
| 334 } |
| 335 |
| 336 // Tests that drawing with CHROMIUM_path_rendering functions work. |
| 337 TEST_F(CHROMIUMPathRenderingTest, TestPathRendering) { |
| 338 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { |
| 339 return; |
| 340 } |
| 341 |
| 342 SetupStateForTestPattern(); |
| 343 |
| 344 GLuint path = glGenPathsCHROMIUM(1); |
| 345 SetupPathStateForTestPattern(path); |
| 346 |
| 347 // Do the stencil fill, cover fill, stencil stroke, cover stroke |
| 348 // in unconventional order: |
| 349 // 1) stencil the stroke in stencil high bit |
| 350 // 2) stencil the fill in low bits |
| 351 // 3) cover the fill |
| 352 // 4) cover the stroke |
| 353 // This is done to check that glPathStencilFunc works, eg the mask |
| 354 // goes through. Stencil func is not tested ATM, for simplicity. |
| 355 |
| 356 glPathStencilFuncCHROMIUM(GL_ALWAYS, 0, 0xFF); |
| 357 glStencilStrokePathCHROMIUM(path, 0x80, 0x80); |
| 358 |
| 359 glPathStencilFuncCHROMIUM(GL_ALWAYS, 0, 0x7F); |
| 360 glStencilFillPathCHROMIUM(path, GL_COUNT_UP_CHROMIUM, 0x7F); |
| 361 |
| 362 // TexCoord generation is tested by using the TexCoord values |
| 363 // as pixel values. Transform object coords, eg. [0..width], to [0..1]. |
| 364 // Setup two texture coordinate sets so that we check the support |
| 365 // for multiple TexCoords. See the verification section on how the |
| 366 // pixel color should look like. |
| 367 glPathTexGenCHROMIUM( |
| 368 GL_TEXTURE0, GL_OBJECT_LINEAR_CHROMIUM, 3, fill_coefficients_); |
| 369 glPathTexGenCHROMIUM(GL_TEXTURE0 + 1, |
| 370 GL_OBJECT_LINEAR_CHROMIUM, |
| 371 3, |
| 372 &fill_coefficients_[3 * 3]); |
| 373 |
| 374 glStencilFunc(GL_LESS, 0, 0x7F); |
| 375 glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); |
| 376 glCoverFillPathCHROMIUM(path, GL_BOUNDING_BOX_CHROMIUM); |
| 377 |
| 378 glPathTexGenCHROMIUM( |
| 379 GL_TEXTURE0, GL_OBJECT_LINEAR_CHROMIUM, 3, stroke_coefficients_); |
| 380 glPathTexGenCHROMIUM( |
| 381 GL_TEXTURE0 + 1, GL_OBJECT_LINEAR_CHROMIUM, 3, stroke_coefficients_); |
| 382 glStencilFunc(GL_EQUAL, 0x80, 0x80); |
| 383 glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); |
| 384 glCoverStrokePathCHROMIUM(path, GL_BOUNDING_BOX_CHROMIUM); |
| 385 |
| 386 glDeletePathsCHROMIUM(path, 1); |
| 387 |
| 388 // Verify the image. |
| 389 VerifyTestPatternFill(0.f, 0.f); |
| 390 VerifyTestPatternBg(0.f, 0.f); |
| 391 VerifyTestPatternStroke(0.f, 0.f); |
| 392 } |
| 393 |
| 394 // Tests that drawing with *Instanced functions work. |
| 395 TEST_F(CHROMIUMPathRenderingTest, TestPathRenderingInstanced) { |
| 396 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) { |
| 397 return; |
| 398 } |
| 399 |
| 400 SetupStateForTestPattern(); |
| 401 |
| 402 GLuint path = glGenPathsCHROMIUM(1); |
| 403 SetupPathStateForTestPattern(path); |
| 404 |
| 405 GLuint paths[] = {1, 1, 1, 1, 1}; |
| 406 GLfloat transforms[] = { |
| 407 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, |
| 408 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 20.0f, 20.0f, 0.0f, |
| 409 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 30.0f, 30.0f, 0.0f, |
| 410 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 40.0f, 40.0f, 0.0f, |
| 411 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 50.0f, 50.0f, 0.0f, |
| 412 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 60.0f, 60.0f, 0.0f, |
| 413 }; |
| 414 |
| 415 // The test pattern is the same as in the simple draw case above, |
| 416 // except that the path is drawn 5 times with different offsets. |
| 417 glPathStencilFuncCHROMIUM(GL_ALWAYS, 0, 0xFF); |
| 418 glStencilStrokePathInstancedCHROMIUM(5, |
| 419 GL_UNSIGNED_INT, |
| 420 paths, |
| 421 path - 1, |
| 422 0x80, |
| 423 0x80, |
| 424 GL_AFFINE_3D_CHROMIUM, |
| 425 transforms); |
| 426 |
| 427 glPathStencilFuncCHROMIUM(GL_ALWAYS, 0, 0x7F); |
| 428 glStencilFillPathInstancedCHROMIUM(5, |
| 429 GL_UNSIGNED_INT, |
| 430 paths, |
| 431 path - 1, |
| 432 GL_COUNT_UP_CHROMIUM, |
| 433 0x7F, |
| 434 GL_AFFINE_3D_CHROMIUM, |
| 435 transforms); |
| 436 |
| 437 glPathTexGenCHROMIUM( |
| 438 GL_TEXTURE0, GL_OBJECT_LINEAR_CHROMIUM, 3, fill_coefficients_); |
| 439 glPathTexGenCHROMIUM(GL_TEXTURE0 + 1, |
| 440 GL_OBJECT_LINEAR_CHROMIUM, |
| 441 3, |
| 442 &fill_coefficients_[3 * 3]); |
| 443 |
| 444 glStencilFunc(GL_LESS, 0, 0x7F); |
| 445 glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); |
| 446 glCoverFillPathInstancedCHROMIUM(5, |
| 447 GL_UNSIGNED_INT, |
| 448 paths, |
| 449 path - 1, |
| 450 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 451 GL_AFFINE_3D_CHROMIUM, |
| 452 transforms); |
| 453 |
| 454 glPathTexGenCHROMIUM( |
| 455 GL_TEXTURE0, GL_OBJECT_LINEAR_CHROMIUM, 3, stroke_coefficients_); |
| 456 glPathTexGenCHROMIUM( |
| 457 GL_TEXTURE0 + 1, GL_OBJECT_LINEAR_CHROMIUM, 3, stroke_coefficients_); |
| 458 glStencilFunc(GL_EQUAL, 0x80, 0x80); |
| 459 glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); |
| 460 glCoverStrokePathInstancedCHROMIUM(5, |
| 461 GL_UNSIGNED_INT, |
| 462 paths, |
| 463 path - 1, |
| 464 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 465 GL_AFFINE_3D_CHROMIUM, |
| 466 transforms); |
| 467 |
| 468 glDeletePathsCHROMIUM(path, 1); |
| 469 #if 0 |
| 470 // FIXME: the instanced picture is not set up to be correct yet, |
| 471 // and neither is the verification. |
| 472 GLTestHelper::SaveBackbufferAsBMP("nvpr-unittest.bmp", kResolution, |
| 473 kResolution); |
| 474 // Verify the image. |
| 475 VerifyTestPatternFill(0.f, 0.f); |
| 476 VerifyTestPatternBg(0.f, 0.f); |
| 477 VerifyTestPatternStroke(0.f, 0.f); |
| 478 #endif |
| 479 } |
| 480 |
110 } // namespace gpu | 481 } // namespace gpu |
OLD | NEW |