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 
31 // |ShellTestPlatformView|
33  vsync_clock_->SimulateVSync();
34 }
35 
36 // |PlatformView|
37 std::unique_ptr<Surface> ShellTestPlatformViewGL::CreateRenderingSurface() {
38  return std::make_unique<GPUSurfaceGL>(this, true);
39 }
40 
41 // |PlatformView|
42 std::shared_ptr<ExternalViewEmbedder>
43 ShellTestPlatformViewGL::CreateExternalViewEmbedder() {
44  return shell_test_external_view_embedder_;
45 }
46 
47 // |PlatformView|
48 PointerDataDispatcherMaker ShellTestPlatformViewGL::GetDispatcherMaker() {
49  return [](DefaultPointerDataDispatcher::Delegate& delegate) {
50  return std::make_unique<SmoothPointerDataDispatcher>(delegate);
51  };
52 }
53 
54 // |GPUSurfaceGLDelegate|
55 std::unique_ptr<GLContextResult>
56 ShellTestPlatformViewGL::GLContextMakeCurrent() {
57  return std::make_unique<GLContextDefaultResult>(gl_surface_.MakeCurrent());
58 }
59 
60 // |GPUSurfaceGLDelegate|
61 bool ShellTestPlatformViewGL::GLContextClearCurrent() {
62  return gl_surface_.ClearCurrent();
63 }
64 
65 // |GPUSurfaceGLDelegate|
66 bool ShellTestPlatformViewGL::GLContextPresent(uint32_t fbo_id) {
67  return gl_surface_.Present();
68 }
69 
70 // |GPUSurfaceGLDelegate|
71 intptr_t ShellTestPlatformViewGL::GLContextFBO(GLFrameInfo frame_info) const {
72  return gl_surface_.GetFramebuffer(frame_info.width, frame_info.height);
73 }
74 
75 // |GPUSurfaceGLDelegate|
77 ShellTestPlatformViewGL::GetGLProcResolver() const {
78  return [surface = &gl_surface_](const char* name) -> void* {
79  return surface->GetProcAddress(name);
80  };
81 }
82 
83 } // namespace testing
84 } // 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:54