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

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

Issue 1426903002: gpu: Make glTexSubImage2D work with GL_SRGB_ALPHA on OpenGL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable the test verification if it fails Created 5 years, 1 month 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
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015 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
8 #include "gpu/command_buffer/tests/gl_manager.h"
9 #include "gpu/command_buffer/tests/gl_test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace gpu {
13
14 // A collection of tests that exercise the GL_EXT_srgb extension.
15 class GLEXTSRGBTest : public testing::Test {
16 protected:
17 void SetUp() override { gl_.Initialize(GLManager::Options()); }
18 void TearDown() override { gl_.Destroy(); }
19 bool IsApplicable() const {
20 return GLTestHelper::HasExtension("GL_EXT_sRGB");
21 }
22 GLManager gl_;
23 };
24
25 // Test to ensure that GL_SRGB_ALPHA as glTex(Sub)Image2D parameter works. This
26 // is tricky because GL_SRGB_ALPHA is valid in OpenGL ES 2.0 but not valid in
27 // OpenGL.
28 TEST_F(GLEXTSRGBTest, TexImageSRGBALPHAFormat) {
29 if (!IsApplicable())
30 return;
31 static const int kWidth = 10;
32 static const int kHeight = 10;
33 static const int kSubImageX = kWidth / 2;
34 static const int kSubImageY = kHeight / 2;
35 static const int kSubImageWidth = kWidth / 2;
36 static const int kSubImageHeight = kHeight / 2;
37 static const uint8 kImageColor[] = {255, 255, 255, 255};
38 static const uint8 kSubImageColor[] = {128, 128, 128, 128};
39
40 uint8 pixels[kWidth * kHeight * 4];
41
42 GLuint tex = 0;
43 glGenTextures(1, &tex);
44 glBindTexture(GL_TEXTURE_2D, tex);
45 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
46 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
47 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
48 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
49
50 memset(pixels, kImageColor[0], sizeof(pixels));
51 glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA_EXT, kWidth, kHeight, 0,
52 GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, pixels);
53 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
54
55 memset(pixels, kSubImageColor[0], sizeof(pixels));
56 glTexSubImage2D(GL_TEXTURE_2D, 0, kSubImageX, kSubImageY, kSubImageWidth,
57 kSubImageHeight, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, pixels);
58 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
59 glBindTexture(GL_TEXTURE_2D, 0);
60 GLuint fbo = 0;
61 glGenFramebuffers(1, &fbo);
62 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
63 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
64 tex, 0);
65 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
66 glCheckFramebufferStatus(GL_FRAMEBUFFER));
67
68 // glReadPixels with GL_SRGB_ALPHA texture fails for on Nexus5 4.4.4.
69 // The intention of this test is to test that TexImage2D and TexSubImage2D
70 // works, not necessarily that glReadPixels works.
71 // Run the verification only on working implementations.
72 uint8 pixel[4] = {
73 0,
74 };
75 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
Kimmo Kinnunen 2015/11/02 12:21:14 Is this workaround ok? Other option would be to ad
76 if (glGetError() == GL_NO_ERROR) {
77 GLTestHelper::CheckPixels(0, 0, kSubImageX, kHeight, 0, kImageColor);
78 GLTestHelper::CheckPixels(0, 0, kWidth, kSubImageY, 0, kImageColor);
79 GLTestHelper::CheckPixels(kSubImageX, kSubImageY, kSubImageWidth,
80 kSubImageHeight, 0, kSubImageColor);
81 }
82 }
83
84 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698