1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef SKIA_GL_GLUE_H_
7 #define SKIA_GL_GLUE_H_
8 
9 #ifdef USE_SKIA_GPU
10 
11 #include "skia/include/core/SkRefCnt.h"
12 #include "mozilla/RefPtr.h"
13 
14 struct GrGLInterface;
15 class GrContext;
16 
17 namespace mozilla {
18 namespace gl {
19 
20 class GLContext;
21 
22 class SkiaGLGlue : public GenericAtomicRefCounted {
23  public:
24   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue, override)
25 
26   explicit SkiaGLGlue(GLContext* context);
GetGLContext()27   GLContext* GetGLContext() const { return mGLContext.get(); }
GetGrContext()28   GrContext* GetGrContext() const { return mGrContext.get(); }
29 
30  protected:
31   virtual ~SkiaGLGlue();
32 
33  private:
34   RefPtr<GLContext> mGLContext;
35   sk_sp<GrGLInterface> mGrGLInterface;
36   sk_sp<GrContext> mGrContext;
37 };
38 
39 }  // namespace gl
40 }  // namespace mozilla
41 
42 #else  // USE_SKIA_GPU
43 
44 class GrContext;
45 
46 namespace mozilla {
47 namespace gl {
48 
49 class GLContext;
50 
51 class SkiaGLGlue : public GenericAtomicRefCounted {
52  public:
53   SkiaGLGlue(GLContext* context);
GetGLContext()54   GLContext* GetGLContext() const { return nullptr; }
GetGrContext()55   GrContext* GetGrContext() const { return nullptr; }
56 };
57 
58 }  // namespace gl
59 }  // namespace mozilla
60 
61 #endif  // USE_SKIA_GPU
62 
63 #endif  // SKIA_GL_GLUE_H_
64