skia2/tools/gpu/gl/null/NullGLTestContext.cpp
Brian Osman 60c774db3e Support shared GL contexts in GrContextFactory
Mostly plumbing, plus some minimal testing to make sure that
the platform APIs don't explode. I plan to add testing of
SkCrossContextImageData using this, which should verify that
textures are actually shared.

Also found a factory and some related code in the
CommandBuffer test context that was totally unused.
BUG=skia:

Change-Id: I05bbc22c4d1ef946b702a5cc7f67788785219c62
Reviewed-on: https://skia-review.googlesource.com/8808
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-22 13:32:56 +00:00

45 lines
1.1 KiB
C++

/*
* 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(GrGLCreateNullInterface(enableNVPR)); }
~NullGLContext() override { this->teardown(); }
private:
void onPlatformMakeCurrent() const override {}
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