OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "gpu/command_buffer/service/feature_info.h" | 11 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/tests/gl_manager.h" | 12 #include "gpu/command_buffer/tests/gl_manager.h" |
11 #include "gpu/command_buffer/tests/gl_test_utils.h" | 13 #include "gpu/command_buffer/tests/gl_test_utils.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 namespace gpu { | 17 namespace gpu { |
16 | 18 |
17 class GLTest : public testing::Test { | 19 class GLTest : public testing::Test { |
18 protected: | 20 protected: |
(...skipping 14 matching lines...) Expand all Loading... |
33 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 35 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
34 GLTestHelper::CheckGLError("no errors", __LINE__); | 36 GLTestHelper::CheckGLError("no errors", __LINE__); |
35 } | 37 } |
36 | 38 |
37 TEST_F(GLTest, BasicFBO) { | 39 TEST_F(GLTest, BasicFBO) { |
38 GLuint tex = 0; | 40 GLuint tex = 0; |
39 glGenTextures(1, &tex); | 41 glGenTextures(1, &tex); |
40 GLuint fbo = 0; | 42 GLuint fbo = 0; |
41 glGenFramebuffers(1, &fbo); | 43 glGenFramebuffers(1, &fbo); |
42 glBindTexture(GL_TEXTURE_2D, tex); | 44 glBindTexture(GL_TEXTURE_2D, tex); |
43 scoped_ptr<uint8_t[]> pixels(new uint8_t[16 * 16 * 4]); | 45 std::unique_ptr<uint8_t[]> pixels(new uint8_t[16 * 16 * 4]); |
44 memset(pixels.get(), 0, 16*16*4); | 46 memset(pixels.get(), 0, 16*16*4); |
45 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 47 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
46 pixels.get()); | 48 pixels.get()); |
47 glGenerateMipmap(GL_TEXTURE_2D); | 49 glGenerateMipmap(GL_TEXTURE_2D); |
48 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 50 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
49 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 51 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
50 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 52 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
51 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 53 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
52 glBindFramebuffer(GL_FRAMEBUFFER, fbo); | 54 glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
53 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 55 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 EXPECT_STREQ( | 135 EXPECT_STREQ( |
134 "Chromium", | 136 "Chromium", |
135 reinterpret_cast<const char*>(glGetString(GL_RENDERER))); | 137 reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |
136 EXPECT_STREQ( | 138 EXPECT_STREQ( |
137 "Chromium", | 139 "Chromium", |
138 reinterpret_cast<const char*>(glGetString(GL_VENDOR))); | 140 reinterpret_cast<const char*>(glGetString(GL_VENDOR))); |
139 } | 141 } |
140 | 142 |
141 } // namespace gpu | 143 } // namespace gpu |
142 | 144 |
OLD | NEW |