forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell_test_platform_view_gl.cc
88 lines (71 loc) · 2.7 KB
/
shell_test_platform_view_gl.cc
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
// 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.
#include "flutter/shell/common/shell_test_platform_view_gl.h"
#include "flutter/shell/gpu/gpu_surface_gl.h"
namespace flutter {
namespace testing {
ShellTestPlatformViewGL::ShellTestPlatformViewGL(
PlatformView::Delegate& delegate,
TaskRunners task_runners,
std::shared_ptr<ShellTestVsyncClock> vsync_clock,
CreateVsyncWaiter create_vsync_waiter,
std::shared_ptr<ShellTestExternalViewEmbedder>
shell_test_external_view_embedder)
: ShellTestPlatformView(delegate, std::move(task_runners)),
gl_surface_(SkISize::Make(800, 600)),
create_vsync_waiter_(std::move(create_vsync_waiter)),
vsync_clock_(vsync_clock),
shell_test_external_view_embedder_(shell_test_external_view_embedder) {}
ShellTestPlatformViewGL::~ShellTestPlatformViewGL() = default;
std::unique_ptr<VsyncWaiter> ShellTestPlatformViewGL::CreateVSyncWaiter() {
return create_vsync_waiter_();
}
void ShellTestPlatformViewGL::SimulateVSync() {
vsync_clock_->SimulateVSync();
}
// |PlatformView|
std::unique_ptr<Surface> ShellTestPlatformViewGL::CreateRenderingSurface() {
return std::make_unique<GPUSurfaceGL>(this, true);
}
// |PlatformView|
std::shared_ptr<ExternalViewEmbedder>
ShellTestPlatformViewGL::CreateExternalViewEmbedder() {
return shell_test_external_view_embedder_;
}
// |PlatformView|
PointerDataDispatcherMaker ShellTestPlatformViewGL::GetDispatcherMaker() {
return [](DefaultPointerDataDispatcher::Delegate& delegate) {
return std::make_unique<SmoothPointerDataDispatcher>(delegate);
};
}
// |GPUSurfaceGLDelegate|
std::unique_ptr<GLContextResult>
ShellTestPlatformViewGL::GLContextMakeCurrent() {
return std::make_unique<GLContextDefaultResult>(gl_surface_.MakeCurrent());
}
// |GPUSurfaceGLDelegate|
bool ShellTestPlatformViewGL::GLContextClearCurrent() {
return gl_surface_.ClearCurrent();
}
// |GPUSurfaceGLDelegate|
bool ShellTestPlatformViewGL::GLContextPresent(uint32_t fbo_id) {
return gl_surface_.Present();
}
// |GPUSurfaceGLDelegate|
intptr_t ShellTestPlatformViewGL::GLContextFBO(GLFrameInfo frame_info) const {
return gl_surface_.GetFramebuffer(frame_info.width, frame_info.height);
}
// |GPUSurfaceGLDelegate|
GPUSurfaceGLDelegate::GLProcResolver
ShellTestPlatformViewGL::GetGLProcResolver() const {
return [surface = &gl_surface_](const char* name) -> void* {
return surface->GetProcAddress(name);
};
}
// |GPUSurfaceGLDelegate|
ExternalViewEmbedder* ShellTestPlatformViewGL::GetExternalViewEmbedder() {
return shell_test_external_view_embedder_.get();
}
} // namespace testing
} // namespace flutter