blob: 9e7279b501a2c82201183131199c4965d826ff4a [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:
svaisanenb988ecf2016-04-20 00:36:53 -070020 NullGLContext(bool enableNVPR) { this->init(GrGLCreateNullInterface(enableNVPR)); }
bsalomon3724e572016-03-30 18:56:19 -070021 ~NullGLContext() override { this->teardown(); }
22
svaisanenb988ecf2016-04-20 00:36:53 -070023private:
Mike Kleinfc6c37b2016-09-27 09:34:10 -040024 void onPlatformMakeCurrent() const override {}
Brian Salomon55ad7742017-11-17 09:25:23 -050025 std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
bsalomon3724e572016-03-30 18:56:19 -070026 void onPlatformSwapBuffers() const override {}
27 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
28};
bsalomon2f538e92016-04-01 09:04:35 -070029
bsalomon3724e572016-03-30 18:56:19 -070030} // anonymous namespace
31
32namespace sk_gpu_test {
Brian Osman60c774d2017-02-21 16:58:08 -050033GLTestContext* CreateNullGLTestContext(bool enableNVPR, GLTestContext* shareContext) {
34 if (shareContext) {
35 return nullptr;
36 }
svaisanenb988ecf2016-04-20 00:36:53 -070037 GLTestContext* ctx = new NullGLContext(enableNVPR);
bsalomon3724e572016-03-30 18:56:19 -070038 if (ctx->isValid()) {
39 return ctx;
40 }
41 delete ctx;
42 return nullptr;
43}
44} // namespace sk_gpu_test
45