1 | // LAF OS Library |
2 | // Copyright (C) 2022 Igara Studio S.A. |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifndef OS_SKIA_SKIA_GL_INCLUDED |
8 | #define OS_SKIA_SKIA_GL_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "base/disable_copying.h" |
12 | #include "gfx/size.h" |
13 | |
14 | #if SK_SUPPORT_GPU |
15 | #include "include/core/SkColorSpace.h" |
16 | #include "include/core/SkRefCnt.h" |
17 | #include "include/core/SkSurface.h" |
18 | #include "include/gpu/GrDirectContext.h" |
19 | #include "include/gpu/gl/GrGLInterface.h" |
20 | #endif |
21 | |
22 | namespace os { |
23 | |
24 | #if SK_SUPPORT_GPU |
25 | |
26 | class SkiaGL { |
27 | public: |
28 | SkiaGL(); |
29 | |
30 | bool hasCtx() const { return m_grCtx != nullptr; } |
31 | GrDirectContext* grCtx() const { return m_grCtx.get(); }; |
32 | const GrGLInterface* glInterfaces() const { return m_glInterfaces.get(); }; |
33 | |
34 | bool attachGL(); |
35 | void detachGL(); |
36 | |
37 | bool createRenderTarget(const gfx::Size& size, |
38 | const int scale, |
39 | sk_sp<SkColorSpace> colorSpace); |
40 | |
41 | sk_sp<SkSurface> backbufferSurface() const { return m_backbufferSurface; } |
42 | sk_sp<SkSurface> surface() const { return m_surface; } |
43 | |
44 | private: |
45 | sk_sp<const GrGLInterface> m_glInterfaces; |
46 | sk_sp<GrDirectContext> m_grCtx; |
47 | sk_sp<SkSurface> m_backbufferSurface; |
48 | sk_sp<SkSurface> m_surface; |
49 | |
50 | DISABLE_COPYING(SkiaGL); |
51 | }; |
52 | |
53 | #else // !SK_SUPPORT_GPU |
54 | |
55 | class SkiaGL { }; |
56 | |
57 | #endif |
58 | |
59 | } // namespace os |
60 | |
61 | #endif |
62 | |