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

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

Issue 2061743004: Implement native GMB backbuffers in the GLES2 Command Decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error on Windows. Created 4 years, 5 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 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/texture_image_factory.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_image.h"
16
17 namespace gpu {
18
19 class GLNativeGMBTest : public testing::Test {
20 protected:
21 void SetUp() override {}
22
23 void TearDown() override {}
24
25 TextureImageFactory image_factory_;
26 };
27
28 TEST_F(GLNativeGMBTest, TestNativeGMBBackbufferWithDifferentConfigurations) {
29 for (int has_alpha = 0; has_alpha <= 1; ++has_alpha) {
30 for (int msaa = 0; msaa <= 1; ++msaa) {
31 GLManager::Options options;
32 options.image_factory = &image_factory_;
33 options.multisampled = msaa == 1;
34 options.backbuffer_alpha = has_alpha == 1;
35
36 GLManager gl;
37 gl.Initialize(options);
38 gl.MakeCurrent();
39
40 glResizeCHROMIUM(10, 10, 1, true);
41 glClearColor(0.0f, 0.25f, 0.5f, 0.7f);
42 glClear(GL_COLOR_BUFFER_BIT);
43
44 uint8_t pixel[4];
45 memset(pixel, 0, 4);
46 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
47 EXPECT_NEAR(0u, pixel[0], 2);
48 EXPECT_NEAR(64u, pixel[1], 2);
49 EXPECT_NEAR(127u, pixel[2], 2);
50 uint8_t alpha = has_alpha ? 178 : 255;
51 EXPECT_NEAR(alpha, pixel[3], 2);
52
53 ::gles2::GetGLContext()->SwapBuffers();
54 glClearColor(0.1f, 0.2f, 0.3f, 0.4f);
55 glClear(GL_COLOR_BUFFER_BIT);
56 memset(pixel, 0, 4);
57 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
58 EXPECT_NEAR(25u, pixel[0], 2);
59 EXPECT_NEAR(51u, pixel[1], 2);
60 EXPECT_NEAR(76u, pixel[2], 2);
61 uint8_t alpha2 = has_alpha ? 102 : 255;
62 EXPECT_NEAR(alpha2, pixel[3], 2);
63
64 gl.Destroy();
65 }
66 }
67 }
68
69 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698