Flutter Engine
shell_test_platform_view_gl.cc
Go to the documentation of this file.
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 #include "flutter/shell/common/shell_test_platform_view_gl.h"
6 
7 #include "flutter/shell/gpu/gpu_surface_gl.h"
8 
9 namespace flutter {
10 namespace testing {
11 
13  PlatformView::Delegate& delegate,
14  TaskRunners task_runners,
15  std::shared_ptr<ShellTestVsyncClock> vsync_clock,
16  CreateVsyncWaiter create_vsync_waiter,
17  std::shared_ptr<ShellTestExternalViewEmbedder>
18  shell_test_external_view_embedder)
19  : ShellTestPlatformView(delegate, std::move(task_runners)),
20  gl_surface_(SkISize::Make(800, 600)),
21  create_vsync_waiter_(std::move(create_vsync_waiter)),
22  vsync_clock_(vsync_clock),
23  shell_test_external_view_embedder_(shell_test_external_view_embedder) {}
24 
26 
27 std::unique_ptr<VsyncWaiter> ShellTestPlatformViewGL::CreateVSyncWaiter() {
28  return create_vsync_waiter_();
29 }
30 
32  vsync_clock_->SimulateVSync();
33 }
34 
35 // |PlatformView|
36 std::unique_ptr<Surface> ShellTestPlatformViewGL::CreateRenderingSurface() {
37  return std::make_unique<GPUSurfaceGL>(this, true);
38 }
39 
40 // |PlatformView|
41 PointerDataDispatcherMaker ShellTestPlatformViewGL::GetDispatcherMaker() {
42  return [](DefaultPointerDataDispatcher::Delegate& delegate) {
43  return std::make_unique<SmoothPointerDataDispatcher>(delegate);
44  };
45 }
46 
47 // |GPUSurfaceGLDelegate|
48 std::unique_ptr<GLContextResult>
49 ShellTestPlatformViewGL::GLContextMakeCurrent() {
50  return std::make_unique<GLContextDefaultResult>(gl_surface_.MakeCurrent());
51 }
52 
53 // |GPUSurfaceGLDelegate|
54 bool ShellTestPlatformViewGL::GLContextClearCurrent() {
55  return gl_surface_.ClearCurrent();
56 }
57 
58 // |GPUSurfaceGLDelegate|
59 bool ShellTestPlatformViewGL::GLContextPresent(uint32_t fbo_id) {
60  return gl_surface_.Present();
61 }
62 
63 // |GPUSurfaceGLDelegate|
64 intptr_t ShellTestPlatformViewGL::GLContextFBO(GLFrameInfo frame_info) const {
65  return gl_surface_.GetFramebuffer(frame_info.width, frame_info.height);
66 }
67 
68 // |GPUSurfaceGLDelegate|
70 ShellTestPlatformViewGL::GetGLProcResolver() const {
71  return [surface = &gl_surface_](const char* name) -> void* {
72  return surface->GetProcAddress(name);
73  };
74 }
75 
76 // |GPUSurfaceGLDelegate|
77 ExternalViewEmbedder* ShellTestPlatformViewGL::GetExternalViewEmbedder() {
78  return shell_test_external_view_embedder_.get();
79 }
80 
81 } // namespace testing
82 } // namespace flutter
Definition: ref_ptr.h:252
The interface for Engine to implement.
uint32_t GetFramebuffer(uint32_t width, uint32_t height) const
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
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)
std::function< void *(const char *)> GLProcResolver
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
const char * name
Definition: fuchsia.cc:50
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Definition: platform_view.h:51