forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtest_gl_surface.h
102 lines (65 loc) · 2.35 KB
/
test_gl_surface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_TESTING_TEST_GL_SURFACE_H_
#define FLUTTER_TESTING_TEST_GL_SURFACE_H_
#include <cstdint>
#include "flutter/fml/macros.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
namespace flutter {
namespace testing {
struct TestEGLContext {
explicit TestEGLContext();
~TestEGLContext();
using EGLDisplay = void*;
using EGLContext = void*;
using EGLConfig = void*;
EGLDisplay display;
EGLContext onscreen_context;
EGLContext offscreen_context;
// EGLConfig is technically a property of the surfaces, no the context,
// but it's not that well separated in EGL (e.g. when
// EGL_KHR_no_config_context is not supported), so we just store it here.
EGLConfig config;
};
class TestGLOnscreenOnlySurface {
public:
explicit TestGLOnscreenOnlySurface(SkISize surface_size);
explicit TestGLOnscreenOnlySurface(std::shared_ptr<TestEGLContext> context,
SkISize size);
~TestGLOnscreenOnlySurface();
const SkISize& GetSurfaceSize() const;
bool MakeCurrent();
bool ClearCurrent();
bool Present();
uint32_t GetFramebuffer(uint32_t width, uint32_t height) const;
void* GetProcAddress(const char* name) const;
sk_sp<SkSurface> GetOnscreenSurface();
sk_sp<GrDirectContext> GetGrContext();
sk_sp<GrDirectContext> CreateGrContext();
sk_sp<SkImage> GetRasterSurfaceSnapshot();
uint32_t GetWindowFBOId() const;
protected:
using EGLSurface = void*;
const SkISize surface_size_;
std::shared_ptr<TestEGLContext> egl_context_;
EGLSurface onscreen_surface_;
sk_sp<GrDirectContext> skia_context_;
FML_DISALLOW_COPY_AND_ASSIGN(TestGLOnscreenOnlySurface);
};
class TestGLSurface : public TestGLOnscreenOnlySurface {
public:
explicit TestGLSurface(SkISize surface_size);
explicit TestGLSurface(std::shared_ptr<TestEGLContext> egl_context,
SkISize surface_size);
~TestGLSurface();
bool MakeResourceCurrent();
private:
using EGLSurface = void*;
EGLSurface offscreen_surface_;
FML_DISALLOW_COPY_AND_ASSIGN(TestGLSurface);
};
} // namespace testing
} // namespace flutter
#endif // FLUTTER_TESTING_TEST_GL_SURFACE_H_