Home | History | Annotate | Download | only in mock
      1 
      2 /*
      3  * Copyright 2017 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 #ifndef GLTestContext_DEFINED
      9 #define GLTestContext_DEFINED
     10 
     11 #include "MockTestContext.h"
     12 
     13 #include "GrContext.h"
     14 
     15 namespace {
     16 
     17 class MockTestContext : public sk_gpu_test::TestContext {
     18 public:
     19     MockTestContext() {}
     20     ~MockTestContext() override {}
     21 
     22     virtual GrBackend backend() override { return kMock_GrBackend; }
     23     virtual GrBackendContext backendContext() override {
     24         return reinterpret_cast<GrBackendContext>(nullptr);
     25     }
     26     void testAbandon() override {}
     27     void submit() override {}
     28     void finish() override {}
     29 
     30     sk_sp<GrContext> makeGrContext(const GrContextOptions& options) override {
     31         return GrContext::MakeMock(nullptr, options);
     32     }
     33 
     34 protected:
     35     void teardown() override {}
     36     void onPlatformMakeCurrent() const override {}
     37     std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
     38     void onPlatformSwapBuffers() const override {}
     39 
     40 private:
     41     typedef sk_gpu_test::TestContext INHERITED;
     42 };
     43 
     44 } // anonymous namespace
     45 
     46 namespace sk_gpu_test {
     47 
     48 TestContext* CreateMockTestContext(TestContext*) { return new MockTestContext(); }
     49 
     50 }  // namespace sk_gpu_test
     51 #endif
     52