blob: de33a40e087464d7c682dd8da889072fa2cbcbd4 [file] [log] [blame]
bsalomon3724e572016-03-30 18:56:19 -07001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
bsalomon273c0f52016-03-31 10:59:06 -07009#include "NullGLTestContext.h"
bsalomon3724e572016-03-30 18:56:19 -070010#include "gl/GrGLTestInterface.h"
11#include "gl/GrGLDefines.h"
12#include "gl/GrGLInterface.h"
13#include "gl/GrGLTypes.h"
14#include "SkMutex.h"
15#include "SkTDArray.h"
16
17namespace {
bsalomon273c0f52016-03-31 10:59:06 -070018class NullGLContext : public sk_gpu_test::GLTestContext {
bsalomon3724e572016-03-30 18:56:19 -070019public:
Brian Salomon3d6801e2017-12-11 10:06:31 -050020 NullGLContext(bool enableNVPR) {
21 this->init(sk_sp<const GrGLInterface>(GrGLCreateNullInterface(enableNVPR)));
22 }
23 ~NullGLContext() override { this->teardown(); }
bsalomon3724e572016-03-30 18:56:19 -070024
svaisanenb988ecf2016-04-20 00:36:53 -070025private:
Mike Kleinfc6c37b2016-09-27 09:34:10 -040026 void onPlatformMakeCurrent() const override {}
Brian Salomon55ad7742017-11-17 09:25:23 -050027 std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
bsalomon3724e572016-03-30 18:56:19 -070028 void onPlatformSwapBuffers() const override {}
29 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
30};
bsalomon2f538e92016-04-01 09:04:35 -070031
bsalomon3724e572016-03-30 18:56:19 -070032} // anonymous namespace
33
34namespace sk_gpu_test {
Brian Osman60c774d2017-02-21 16:58:08 -050035GLTestContext* CreateNullGLTestContext(bool enableNVPR, GLTestContext* shareContext) {
36 if (shareContext) {
37 return nullptr;
38 }
svaisanenb988ecf2016-04-20 00:36:53 -070039 GLTestContext* ctx = new NullGLContext(enableNVPR);
bsalomon3724e572016-03-30 18:56:19 -070040 if (ctx->isValid()) {
41 return ctx;
42 }
43 delete ctx;
44 return nullptr;
45}
46} // namespace sk_gpu_test
47