OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 "base/memory/scoped_ptr.h" | |
6 #include "cc/test/test_web_graphics_context_3d.h" | |
7 #include "gpu/GLES2/gl2extchromium.h" | |
8 #include "testing/gmock/include/gmock/gmock.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 #include "third_party/khronos/GLES2/gl2ext.h" | |
11 | |
12 namespace cc { | |
13 namespace { | |
14 | |
15 static bool check_parameter_value(TestWebGraphicsContext3D* context, | |
16 GLenum pname, | |
17 GLint expected_value) { | |
18 GLint actual_value = 0; | |
19 context->getTexParameteriv(GL_TEXTURE_2D, pname, &actual_value); | |
20 return expected_value == actual_value; | |
21 } | |
22 | |
23 static void expect_default_parameter_values(TestWebGraphicsContext3D* context) { | |
24 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
25 EXPECT_TRUE(check_parameter_value( | |
26 context, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)); | |
27 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_WRAP_S, GL_REPEAT)); | |
28 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_WRAP_T, GL_REPEAT)); | |
29 EXPECT_TRUE(check_parameter_value( | |
30 context, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); | |
31 EXPECT_TRUE(check_parameter_value(context, GL_TEXTURE_USAGE_ANGLE, GL_NONE)); | |
32 } | |
33 | |
34 TEST(TestWebGraphicsContext3DTest, GetDefaultTextureParameterValues) { | |
35 scoped_ptr<TestWebGraphicsContext3D> context( | |
36 TestWebGraphicsContext3D::Create()); | |
37 | |
38 GLuint texture = context->createTexture(); | |
39 context->bindTexture(GL_TEXTURE_2D, texture); | |
40 | |
41 expect_default_parameter_values(context.get()); | |
42 } | |
43 | |
44 TEST(TestWebGraphicsContext3DTest, SetAndGetTextureParameter) { | |
45 scoped_ptr<TestWebGraphicsContext3D> context( | |
46 TestWebGraphicsContext3D::Create()); | |
47 | |
48 GLuint texture = context->createTexture(); | |
49 context->bindTexture(GL_TEXTURE_2D, texture); | |
50 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
51 | |
52 EXPECT_TRUE( | |
53 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_NEAREST)); | |
54 } | |
55 | |
56 TEST(TestWebGraphicsContext3DTest, | |
57 SetAndGetMultipleTextureParametersOnMultipleTextures) { | |
58 scoped_ptr<TestWebGraphicsContext3D> context( | |
59 TestWebGraphicsContext3D::Create()); | |
60 | |
61 // Set and get non-default texture parameters on the first texture. | |
62 GLuint first_texture = context->createTexture(); | |
63 context->bindTexture(GL_TEXTURE_2D, first_texture); | |
64 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
65 context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
66 | |
67 EXPECT_TRUE( | |
68 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
69 EXPECT_TRUE( | |
70 check_parameter_value(context.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST)); | |
71 | |
72 // Set and get different, non-default texture parameters on the second | |
73 // texture. | |
74 GLuint second_texture = context->createTexture(); | |
75 context->bindTexture(GL_TEXTURE_2D, second_texture); | |
76 context->texParameteri( | |
77 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); | |
78 context->texParameteri( | |
79 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); | |
80 | |
81 EXPECT_TRUE(check_parameter_value( | |
82 context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST)); | |
83 EXPECT_TRUE(check_parameter_value( | |
84 context.get(), GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR)); | |
85 | |
86 // Get texture parameters on the first texture and verify they are still | |
87 // intact. | |
88 context->bindTexture(GL_TEXTURE_2D, first_texture); | |
89 | |
90 EXPECT_TRUE( | |
91 check_parameter_value(context.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
92 EXPECT_TRUE( | |
93 check_parameter_value(context.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST)); | |
94 } | |
95 | |
96 TEST(TestWebGraphicsContext3DTest, UseMultipleRenderAndFramebuffers) { | |
97 scoped_ptr<TestWebGraphicsContext3D> context( | |
98 TestWebGraphicsContext3D::Create()); | |
99 | |
100 GLuint ids[2]; | |
101 context->genFramebuffers(2, ids); | |
102 EXPECT_NE(ids[0], ids[1]); | |
103 context->deleteFramebuffers(2, ids); | |
104 | |
105 context->genRenderbuffers(2, ids); | |
106 EXPECT_NE(ids[0], ids[1]); | |
107 context->deleteRenderbuffers(2, ids); | |
108 } | |
109 | |
110 } // namespace | |
111 } // namespace cc | |
OLD | NEW |