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 /// Renders `callback` into an offscreen render pass and saves the result as
57 /// a golden image. The render target is single-sampled, uses the context's
58 /// default color format, and has no depth or stencil attachment, so a
59 /// pipeline built from `PipelineBuilder<>::MakeDefaultPipelineDescriptor`
60 /// must be reduced to match by calling `SetSampleCount(kCount1)`,
61 /// `ClearStencilAttachments()`, and `ClearDepthAttachment()` on it. Calling
62 /// only `SetStencilAttachmentDescriptors(nullopt)` leaves the stencil pixel
63 /// format set and trips Metal's render pipeline validation.
65
66 std::unique_ptr<testing::Screenshot> MakeScreenshot(
67 const sk_sp<flutter::DisplayList>& list);
68
69 static bool SaveScreenshot(std::unique_ptr<testing::Screenshot> screenshot,
70 const std::string& postfix = "");
71
72 static bool ImGuiBegin(const char* name,
73 bool* p_open,
74 ImGuiWindowFlags flags);
75
76 std::shared_ptr<Texture> CreateTextureForFixture(
77 const char* fixture_name,
78 bool enable_mipmapping = false) const;
79
80 sk_sp<flutter::DlImage> CreateDlImageForFixture(
81 const char* fixture_name,
82 bool enable_mipmapping = false) const;
83
84 absl::StatusOr<RuntimeStage::Map> OpenAssetAsRuntimeStage(
85 const char* asset_name) const;
86
87 std::shared_ptr<Context> GetContext() const;
88
89 std::shared_ptr<Context> MakeContext() const;
90
91 Point GetContentScale() const;
92
94
95 ISize GetWindowSize() const;
96
97 IRect GetWindowBounds() const;
98
99 [[nodiscard]] fml::Status SetCapabilities(
100 const std::shared_ptr<Capabilities>& capabilities);
101
102 /// Returns true if `OpenPlaygroundHere` will actually render anything.
103 bool WillRenderSomething() const { return true; }
104
106
107 bool IsGoldenTest() { return true; }
108
109 protected:
110 void SetWindowSize(ISize size);
111
112 private:
113#if FML_OS_MACOSX
114 // This must be placed first so that the autorelease pool is not destroyed
115 // until the GoldenPlaygroundTestImpl has been destructed.
116 fml::ScopedNSAutoreleasePool autorelease_pool_;
117#endif
118
119 std::shared_ptr<TypographerContext> typographer_context_;
120
121 struct GoldenPlaygroundTestImpl;
122 // This is only a shared_ptr so it can work with a forward declared type.
123 std::shared_ptr<GoldenPlaygroundTestImpl> pimpl_;
124
126
127 GoldenPlaygroundTest& operator=(const GoldenPlaygroundTest&) = delete;
128};
129
130} // namespace impeller
131
132#endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
bool OpenPlaygroundHere(AiksPlaygroundCallback callback)
RuntimeStageBackend GetRuntimeStageBackend() const
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
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition playground.h:37
FlutterDesktopBinaryReply callback
const char * name
Definition fuchsia.cc:50
float Scalar
Definition scalar.h:19
PlaygroundBackend
Definition playground.h:26