| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 |
| 9 #include "gpu/command_buffer/client/gles2_lib.h" |
| 10 #include "gpu/command_buffer/service/image_factory.h" |
| 11 #include "gpu/command_buffer/tests/gl_manager.h" |
| 12 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 13 #include "gpu/command_buffer/tests/texture_image_factory.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gl/gl_context.h" |
| 16 #include "ui/gl/gl_image.h" |
| 17 |
| 18 namespace gpu { |
| 19 |
| 20 class GLNativeGMBTest : public testing::Test { |
| 21 protected: |
| 22 void SetUp() override { |
| 23 gl_.Initialize(GLManager::Options()); |
| 24 image_factory_.SetRequiredTextureType(GL_TEXTURE_RECTANGLE_ARB); |
| 25 } |
| 26 |
| 27 void TearDown() override { |
| 28 gl_.Destroy(); |
| 29 } |
| 30 |
| 31 GLManager gl_; |
| 32 TextureImageFactory image_factory_; |
| 33 }; |
| 34 |
| 35 TEST_F(GLNativeGMBTest, TestNativeGMBBackbufferWithDifferentConfigurations) { |
| 36 if (!GLTestHelper::HasExtension("GL_ARB_texture_rectangle")) { |
| 37 LOG(INFO) << "GL_ARB_texture_rectangle not supported. Skipping test..."; |
| 38 return; |
| 39 } |
| 40 |
| 41 for (int has_alpha = 0; has_alpha <= 1; ++has_alpha) { |
| 42 for (int msaa = 0; msaa <= 1; ++msaa) { |
| 43 GLManager::Options options; |
| 44 options.image_factory = &image_factory_; |
| 45 options.multisampled = msaa == 1; |
| 46 options.backbuffer_alpha = has_alpha == 1; |
| 47 options.enable_arb_texture_rectangle = true; |
| 48 |
| 49 GLManager gl; |
| 50 gl.Initialize(options); |
| 51 gl.MakeCurrent(); |
| 52 |
| 53 glResizeCHROMIUM(10, 10, 1, true); |
| 54 glClearColor(0.0f, 0.25f, 0.5f, 0.7f); |
| 55 glClear(GL_COLOR_BUFFER_BIT); |
| 56 |
| 57 uint8_t pixel[4]; |
| 58 memset(pixel, 0, 4); |
| 59 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel); |
| 60 EXPECT_NEAR(0u, pixel[0], 2); |
| 61 EXPECT_NEAR(64u, pixel[1], 2); |
| 62 EXPECT_NEAR(127u, pixel[2], 2); |
| 63 uint8_t alpha = has_alpha ? 178 : 255; |
| 64 EXPECT_NEAR(alpha, pixel[3], 2); |
| 65 |
| 66 ::gles2::GetGLContext()->SwapBuffers(); |
| 67 glClearColor(0.1f, 0.2f, 0.3f, 0.4f); |
| 68 glClear(GL_COLOR_BUFFER_BIT); |
| 69 memset(pixel, 0, 4); |
| 70 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel); |
| 71 EXPECT_NEAR(25u, pixel[0], 2); |
| 72 EXPECT_NEAR(51u, pixel[1], 2); |
| 73 EXPECT_NEAR(76u, pixel[2], 2); |
| 74 uint8_t alpha2 = has_alpha ? 102 : 255; |
| 75 EXPECT_NEAR(alpha2, pixel[3], 2); |
| 76 |
| 77 gl.Destroy(); |
| 78 } |
| 79 } |
| 80 } |
| 81 |
| 82 } // namespace gpu |
| OLD | NEW |