Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
golden_playground_test.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_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
6#define FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
7
8#include <memory>
9
18#include "third_party/abseil-cpp/absl/status/statusor.h"
19#include "third_party/imgui/imgui.h"
20
21#if FML_OS_MACOSX
23#endif
24
25namespace impeller {
26
28 : public ::testing::TestWithParam<PlaygroundBackend> {
29 public:
31 std::function<std::optional<Picture>(AiksContext& renderer)>;
32
33 using AiksDlPlaygroundCallback = std::function<sk_sp<flutter::DisplayList>()>;
34
36
38
39 void SetUp();
40
41 void TearDown();
42
44
46 std::shared_ptr<TypographerContext> typographer_context);
47
48 bool OpenPlaygroundHere(Picture picture);
49
51
53
54 bool OpenPlaygroundHere(const sk_sp<flutter::DisplayList>& list);
55
56 std::unique_ptr<testing::Screenshot> MakeScreenshot(
57 const sk_sp<flutter::DisplayList>& list);
58
59 static bool SaveScreenshot(std::unique_ptr<testing::Screenshot> screenshot,
60 const std::string& postfix = "");
61
62 static bool ImGuiBegin(const char* name,
63 bool* p_open,
64 ImGuiWindowFlags flags);
65
66 std::shared_ptr<Texture> CreateTextureForFixture(
67 const char* fixture_name,
68 bool enable_mipmapping = false) const;
69
70 sk_sp<flutter::DlImage> CreateDlImageForFixture(
71 const char* fixture_name,
72 bool enable_mipmapping = false) const;
73
74 absl::StatusOr<RuntimeStage::Map> OpenAssetAsRuntimeStage(
75 const char* asset_name) const;
76
77 std::shared_ptr<Context> GetContext() const;
78
79 std::shared_ptr<Context> MakeContext() const;
80
81 Point GetContentScale() const;
82
84
85 ISize GetWindowSize() const;
86
87 [[nodiscard]] fml::Status SetCapabilities(
88 const std::shared_ptr<Capabilities>& capabilities);
89
90 /// Returns true if `OpenPlaygroundHere` will actually render anything.
91 bool WillRenderSomething() const { return true; }
92
93 protected:
94 void SetWindowSize(ISize size);
95
96 private:
97#if FML_OS_MACOSX
98 // This must be placed first so that the autorelease pool is not destroyed
99 // until the GoldenPlaygroundTestImpl has been destructed.
100 fml::ScopedNSAutoreleasePool autorelease_pool_;
101#endif
102
103 std::shared_ptr<TypographerContext> typographer_context_;
104
105 struct GoldenPlaygroundTestImpl;
106 // This is only a shared_ptr so it can work with a forward declared type.
107 std::shared_ptr<GoldenPlaygroundTestImpl> pimpl_;
108
110
111 GoldenPlaygroundTest& operator=(const GoldenPlaygroundTest&) = delete;
112};
113
114} // namespace impeller
115
116#endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
bool OpenPlaygroundHere(AiksPlaygroundCallback callback)
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
sk_sp< flutter::DlImage > CreateDlImageForFixture(const char *fixture_name, bool enable_mipmapping=false) const
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities)
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
std::shared_ptr< Context > MakeContext() const
static bool SaveScreenshot(std::unique_ptr< testing::Screenshot > screenshot, const std::string &postfix="")
std::unique_ptr< testing::Screenshot > MakeScreenshot(const sk_sp< flutter::DisplayList > &list)
bool OpenPlaygroundHere(Picture picture)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
std::function< sk_sp< flutter::DisplayList >()> AiksDlPlaygroundCallback
absl::StatusOr< RuntimeStage::Map > OpenAssetAsRuntimeStage(const char *asset_name) const
std::shared_ptr< Context > GetContext() const
bool WillRenderSomething() const
Returns true if OpenPlaygroundHere will actually render anything.
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
FlutterDesktopBinaryReply callback
const char * name
Definition fuchsia.cc:49
float Scalar
Definition scalar.h:19
PlaygroundBackend
Definition playground.h:27