aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GLInterfaceValidationTest.cpp
blob: b890b44e5f733dc3c950e6bf70a6964716fb4e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "Test.h"

// This is a GPU-backend specific test
#if SK_SUPPORT_GPU

#include "GrContextFactory.h"

DEF_GPUTEST(GLInterfaceValidation, reporter, /*factory*/) {
    GrContextFactory testFactory;

    // Test that if we do not have NV_path_rendering -related GL extensions,
    // GrContextFactory::get(.., kEnableNVPR_GLContextOptions) always returns nullptr.
    for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
        GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
        GrContextFactory::ContextInfo* context =
                testFactory.getContextInfo(glCtxType, kNone_GrGLStandard,
                                           GrContextFactory::kNone_GLContextOptions);
        if (!context) {
            continue;
        }

        SkGLContext* glContext = context->fGLContext;
        REPORTER_ASSERT(reporter, glContext->gl()->validate());

        if (!(glContext->gl()->hasExtension("GL_NV_path_rendering") ||
              glContext->gl()->hasExtension("GL_CHROMIUM_path_rendering"))) {
                REPORTER_ASSERT(reporter,
                                nullptr == testFactory.getContextInfo(
                                    glCtxType,
                                    kNone_GrGLStandard,
                                    GrContextFactory::kEnableNVPR_GLContextOptions));
        }
    }

}

#endif