aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu/gl/null/NullGLTestContext.cpp
blob: de33a40e087464d7c682dd8da889072fa2cbcbd4 (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
45
46
47

/*
 * 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 "NullGLTestContext.h"
#include "gl/GrGLTestInterface.h"
#include "gl/GrGLDefines.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLTypes.h"
#include "SkMutex.h"
#include "SkTDArray.h"

namespace {
class NullGLContext : public sk_gpu_test::GLTestContext {
public:
    NullGLContext(bool enableNVPR) {
        this->init(sk_sp<const GrGLInterface>(GrGLCreateNullInterface(enableNVPR)));
    }
    ~NullGLContext() override { this->teardown(); }

private:
    void onPlatformMakeCurrent() const override {}
    std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
    void onPlatformSwapBuffers() const override {}
    GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
};

}  // anonymous namespace

namespace sk_gpu_test {
GLTestContext* CreateNullGLTestContext(bool enableNVPR, GLTestContext* shareContext) {
    if (shareContext) {
        return nullptr;
    }
    GLTestContext* ctx = new NullGLContext(enableNVPR);
    if (ctx->isValid()) {
        return ctx;
    }
    delete ctx;
    return nullptr;
}
}  // namespace sk_gpu_test