• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "GLSnapshotTesting.h"
16 #include "OpenGLTestContext.h"
17 
18 #include <gtest/gtest.h>
19 
20 namespace gfxstream {
21 namespace gl {
22 namespace {
23 
24 struct GlSampleCoverage {
25     GLclampf value;
26     GLboolean invert;
27 };
28 
29 // Sample coverage settings to attempt
30 static const GlSampleCoverage kGLES2TestSampleCoverages[] = {{0.3, true},
31                                                              {0, false}};
32 
33 class SnapshotGlSampleCoverageTest
34     : public SnapshotSetValueTest<GlSampleCoverage>,
35       public ::testing::WithParamInterface<GlSampleCoverage> {
stateCheck(GlSampleCoverage expected)36     void stateCheck(GlSampleCoverage expected) {
37         EXPECT_TRUE(compareGlobalGlFloat(gl, GL_SAMPLE_COVERAGE_VALUE,
38                                          expected.value));
39         EXPECT_TRUE(compareGlobalGlBoolean(gl, GL_SAMPLE_COVERAGE_INVERT,
40                                            expected.invert));
41     }
stateChange()42     void stateChange() {
43         gl->glSampleCoverage(GetParam().value, GetParam().invert);
44     }
45 };
46 
TEST_P(SnapshotGlSampleCoverageTest,SetSampleCoverage)47 TEST_P(SnapshotGlSampleCoverageTest, SetSampleCoverage) {
48     GlSampleCoverage defaultCoverage = {1.0f, false};
49     setExpectedValues(defaultCoverage, GetParam());
50     doCheckedSnapshot();
51 }
52 
53 INSTANTIATE_TEST_SUITE_P(GLES2SnapshotMultisampling,
54                          SnapshotGlSampleCoverageTest,
55                          ::testing::ValuesIn(kGLES2TestSampleCoverages));
56 
57 }  // namespace
58 }  // namespace gl
59 }  // namespace gfxstream
60