blob: 56236a45a6662c1fb85f314addaa4d5eca322c85 [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:
bsalomon3724e572016-03-30 18:56:19 -070024 void onPlatformMakeCurrent() const override {};
25 void onPlatformSwapBuffers() const override {}
26 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
27};
bsalomon2f538e92016-04-01 09:04:35 -070028
bsalomon3724e572016-03-30 18:56:19 -070029} // anonymous namespace
30
31namespace sk_gpu_test {
svaisanenb988ecf2016-04-20 00:36:53 -070032GLTestContext* CreateNullGLTestContext(bool enableNVPR) {
33 GLTestContext* ctx = new NullGLContext(enableNVPR);
bsalomon3724e572016-03-30 18:56:19 -070034 if (ctx->isValid()) {
35 return ctx;
36 }
37 delete ctx;
38 return nullptr;
39}
40} // namespace sk_gpu_test
41