1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #ifndef FLUTTER_TESTING_TEST_GL_SURFACE_H_ |
6 | #define FLUTTER_TESTING_TEST_GL_SURFACE_H_ |
7 | |
8 | #include <cstdint> |
9 | |
10 | #include "flutter/fml/macros.h" |
11 | #include "third_party/skia/include/gpu/GrDirectContext.h" |
12 | |
13 | namespace flutter { |
14 | namespace testing { |
15 | |
16 | class TestGLSurface { |
17 | public: |
18 | TestGLSurface(SkISize surface_size); |
19 | |
20 | ~TestGLSurface(); |
21 | |
22 | const SkISize& GetSurfaceSize() const; |
23 | |
24 | bool MakeCurrent(); |
25 | |
26 | bool ClearCurrent(); |
27 | |
28 | bool Present(); |
29 | |
30 | uint32_t GetFramebuffer() const; |
31 | |
32 | bool MakeResourceCurrent(); |
33 | |
34 | void* GetProcAddress(const char* name) const; |
35 | |
36 | sk_sp<SkSurface> GetOnscreenSurface(); |
37 | |
38 | sk_sp<GrDirectContext> GetGrContext(); |
39 | |
40 | sk_sp<GrDirectContext> CreateGrContext(); |
41 | |
42 | sk_sp<SkImage> GetRasterSurfaceSnapshot(); |
43 | |
44 | private: |
45 | // Importing the EGL.h pulls in platform headers which are problematic |
46 | // (especially X11 which #defineds types like Bool). Any TUs importing |
47 | // this header then become susceptible to failures because of platform |
48 | // specific craziness. Don't expose EGL internals via this header. |
49 | using EGLDisplay = void*; |
50 | using EGLContext = void*; |
51 | using EGLSurface = void*; |
52 | |
53 | const SkISize surface_size_; |
54 | EGLDisplay display_; |
55 | EGLContext onscreen_context_; |
56 | EGLContext offscreen_context_; |
57 | EGLSurface onscreen_surface_; |
58 | EGLSurface offscreen_surface_; |
59 | sk_sp<GrDirectContext> context_; |
60 | |
61 | FML_DISALLOW_COPY_AND_ASSIGN(TestGLSurface); |
62 | }; |
63 | |
64 | } // namespace testing |
65 | } // namespace flutter |
66 | |
67 | #endif // FLUTTER_TESTING_TEST_GL_SURFACE_H_ |
68 | |