Flutter Engine
The Flutter Engine
embedder_test_context_metal.h
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#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_METAL_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_METAL_H_
7
8#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
9#include "flutter/testing/test_metal_context.h"
10#include "flutter/testing/test_metal_surface.h"
11
12namespace flutter {
13namespace testing {
14
16 public:
18 std::function<bool(int64_t texture_id,
19 size_t w,
20 size_t h,
22
25
27
28 explicit EmbedderTestContextMetal(std::string assets_path = "");
29
31
32 // |EmbedderTestContext|
34
35 // |EmbedderTestContext|
36 size_t GetSurfacePresentCount() const override;
37
38 // |EmbedderTestContext|
39 void SetupCompositor() override;
40
42 TestExternalTextureCallback external_texture_frame_callback);
43
44 // Override the default handling for Present.
45 void SetPresentCallback(PresentCallback present_callback);
46
47 bool Present(int64_t texture_id);
48
50 size_t w,
51 size_t h,
53
55
57
58 // Override the default handling for GetNextDrawable.
59 void SetNextDrawableCallback(NextDrawableCallback next_drawable_callback);
60
62
63 private:
64 // This allows the builder to access the hooks.
66
67 TestExternalTextureCallback external_texture_frame_callback_ = nullptr;
68 SkISize surface_size_ = SkISize::MakeEmpty();
69 std::unique_ptr<TestMetalContext> metal_context_;
70 std::unique_ptr<TestMetalSurface> metal_surface_;
71 size_t present_count_ = 0;
72 PresentCallback present_callback_ = nullptr;
73 NextDrawableCallback next_drawable_callback_ = nullptr;
74
75 void SetupSurface(SkISize surface_size) override;
76
78};
79
80} // namespace testing
81} // namespace flutter
82
83#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_CONTEXT_METAL_H_
Creates a MTLTexture backed SkSurface and context that can be used to render to in unit-tests.
std::function< bool(int64_t texture_id, size_t w, size_t h, FlutterMetalExternalTexture *output)> TestExternalTextureCallback
std::function< FlutterMetalTexture(const FlutterFrameInfo *frame_info)> NextDrawableCallback
std::function< bool(int64_t texture_id)> PresentCallback
void SetNextDrawableCallback(NextDrawableCallback next_drawable_callback)
void SetPresentCallback(PresentCallback present_callback)
void SetExternalTextureCallback(TestExternalTextureCallback external_texture_frame_callback)
FlutterMetalTexture GetNextDrawable(const FlutterFrameInfo *frame_info)
EmbedderTestContextType GetContextType() const override
bool PopulateExternalTexture(int64_t texture_id, size_t w, size_t h, FlutterMetalExternalTexture *output)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
Dart_NativeFunction function
Definition: fuchsia.cc:51
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
Definition: switches.h:59
SkScalar w
Definition: SkSize.h:16
static constexpr SkISize MakeEmpty()
Definition: SkSize.h:22
int64_t texture_id