Home | History | Annotate | Download | only in null
      1 
      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 
      9 #include "NullGLTestContext.h"
     10 #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 
     17 namespace {
     18 class NullGLContext : public sk_gpu_test::GLTestContext {
     19 public:
     20     NullGLContext(bool enableNVPR) {
     21         this->init(sk_sp<const GrGLInterface>(GrGLCreateNullInterface(enableNVPR)));
     22     }
     23     ~NullGLContext() override { this->teardown(); }
     24 
     25 private:
     26     void onPlatformMakeCurrent() const override {}
     27     std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
     28     void onPlatformSwapBuffers() const override {}
     29     GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
     30 };
     31 
     32 }  // anonymous namespace
     33 
     34 namespace sk_gpu_test {
     35 GLTestContext* CreateNullGLTestContext(bool enableNVPR, GLTestContext* shareContext) {
     36     if (shareContext) {
     37         return nullptr;
     38     }
     39     GLTestContext* ctx = new NullGLContext(enableNVPR);
     40     if (ctx->isValid()) {
     41         return ctx;
     42     }
     43     delete ctx;
     44     return nullptr;
     45 }
     46 }  // namespace sk_gpu_test
     47 
     48