|
1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ |
|
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 #include "mozilla/RefPtr.h" |
|
7 |
|
8 #ifdef USE_SKIA_GPU |
|
9 |
|
10 #include "GLContext.h" |
|
11 #include "skia/GrGLInterface.h" |
|
12 #include "skia/GrContext.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace gl { |
|
16 |
|
17 class SkiaGLGlue : public GenericAtomicRefCounted |
|
18 { |
|
19 public: |
|
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue) |
|
21 SkiaGLGlue(GLContext* context); |
|
22 GLContext* GetGLContext() const { return mGLContext.get(); } |
|
23 GrContext* GetGrContext() const { return mGrContext.get(); } |
|
24 |
|
25 protected: |
|
26 virtual ~SkiaGLGlue() { |
|
27 /* |
|
28 * These members have inter-dependencies, but do not keep each other alive, so |
|
29 * destruction order is very important here: mGrContext uses mGrGLInterface, and |
|
30 * through it, uses mGLContext |
|
31 */ |
|
32 mGrContext = nullptr; |
|
33 mGrGLInterface = nullptr; |
|
34 mGLContext = nullptr; |
|
35 } |
|
36 |
|
37 private: |
|
38 RefPtr<GLContext> mGLContext; |
|
39 SkRefPtr<GrGLInterface> mGrGLInterface; |
|
40 SkRefPtr<GrContext> mGrContext; |
|
41 }; |
|
42 |
|
43 } |
|
44 } |
|
45 |
|
46 #else |
|
47 |
|
48 class GrContext; |
|
49 |
|
50 namespace mozilla { |
|
51 namespace gl { |
|
52 |
|
53 class GLContext; |
|
54 |
|
55 class SkiaGLGlue : public GenericAtomicRefCounted |
|
56 { |
|
57 public: |
|
58 SkiaGLGlue(GLContext* context); |
|
59 GLContext* GetGLContext() const { return nullptr; } |
|
60 GrContext* GetGrContext() const { return nullptr; } |
|
61 }; |
|
62 } |
|
63 } |
|
64 |
|
65 #endif |