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

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

Issue 169603002: Add initial support for NV_path_rendering extension to gpu command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 6 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h>
8 #include <cmath>
9
10 #include "gpu/command_buffer/tests/gl_manager.h"
11 #include "gpu/command_buffer/tests/gl_test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15
16 namespace gpu {
17
18 class CHROMIUMPathRenderingTest : public testing::Test {
19 public:
20 static const GLsizei kResolution = 100;
21
22 protected:
23 virtual void SetUp() {
24 GLManager::Options options;
25 options.size = gfx::Size(kResolution, kResolution);
26 gl_.Initialize(options);
27 }
28
29 virtual void TearDown() { gl_.Destroy(); }
30
31 void ExpectEqualMatrix(const GLfloat* expected, const GLfloat* actual) {
32 for (size_t i = 0; i < 16; ++i) {
33 EXPECT_EQ(expected[i], actual[i]);
34 }
35 }
36 void ExpectEqualMatrix(const GLfloat* expected, const GLint* actual) {
37 for (size_t i = 0; i < 16; ++i) {
38 EXPECT_EQ(static_cast<GLint>(round(expected[i])), actual[i]);
39 }
40 }
41 GLManager gl_;
42 };
43
44 TEST_F(CHROMIUMPathRenderingTest, TestMatrix) {
45 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) {
46 return;
47 }
48 static const GLfloat kIdentityMatrix[16] =
49 {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
50 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
51 0.0f, 0.0f, 0.0f, 1.0f};
52 static const GLfloat kSeqMatrix[16] =
53 {0.5f, -0.5f, -0.1f, -0.8f, 4.4f, 5.5f,
54 6.6f, 7.7f, 8.8f, 9.9f, 10.11f, 11.22f,
55 12.33f, 13.44f, 14.55f, 15.66f};
56 static const GLenum kMatrixModes[] = {GL_PATH_MODELVIEW_CHROMIUM,
57 GL_PATH_PROJECTION_CHROMIUM};
58 static const GLenum kGetMatrixModes[] = {GL_PATH_MODELVIEW_MATRIX_CHROMIUM,
59 GL_PATH_PROJECTION_MATRIX_CHROMIUM};
60
61 for (size_t i = 0; i < arraysize(kMatrixModes); ++i) {
62 GLfloat mf[16];
63 GLint mi[16];
64 memset(mf, 0, sizeof(mf));
65 memset(mi, 0, sizeof(mi));
66 glGetFloatv(kGetMatrixModes[i], mf);
67 glGetIntegerv(kGetMatrixModes[i], mi);
68 ExpectEqualMatrix(kIdentityMatrix, mf);
69 ExpectEqualMatrix(kIdentityMatrix, mi);
70
71 glMatrixLoadfCHROMIUM(kMatrixModes[i], kSeqMatrix);
72 memset(mf, 0, sizeof(mf));
73 memset(mi, 0, sizeof(mi));
74 glGetFloatv(kGetMatrixModes[i], mf);
75 glGetIntegerv(kGetMatrixModes[i], mi);
76 ExpectEqualMatrix(kSeqMatrix, mf);
77 ExpectEqualMatrix(kSeqMatrix, mi);
78
79 glMatrixLoadIdentityCHROMIUM(kMatrixModes[i]);
80 memset(mf, 0, sizeof(mf));
81 memset(mi, 0, sizeof(mi));
82 glGetFloatv(kGetMatrixModes[i], mf);
83 glGetIntegerv(kGetMatrixModes[i], mi);
84 ExpectEqualMatrix(kIdentityMatrix, mf);
85 ExpectEqualMatrix(kIdentityMatrix, mi);
86
87 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
88 }
89 }
90
91 TEST_F(CHROMIUMPathRenderingTest, TestMatrixErrors) {
92 if (!GLTestHelper::HasExtension("GL_CHROMIUM_path_rendering")) {
93 return;
94 }
95 GLfloat mf[16];
96 memset(mf, 0, sizeof(mf));
97
98 // This should fail.
99 glMatrixLoadfCHROMIUM(GL_PATH_MODELVIEW_CHROMIUM - 1, mf);
100 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError());
101
102 glMatrixLoadfCHROMIUM(GL_PATH_MODELVIEW_CHROMIUM, mf);
103 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
104
105 // This should fail.
106 glMatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM + 1);
107 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError());
108
109 glMatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
110 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
111 }
112
113 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698