| Flutter Impeller |

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
10 #include "flutter/impeller/aiks/aiks_context.h"
11 #include "flutter/impeller/playground/playground.h"
12 #include "flutter/impeller/renderer/render_target.h"
13 #include "flutter/testing/testing.h"
14 #include "impeller/typographer/typographer_context.h"
15 #include "third_party/imgui/imgui.h"
16
17 #if FML_OS_MACOSX
18 #include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
19 #endif
20
21 namespace impeller {
22
23 class GoldenPlaygroundTest
24 : public ::testing::TestWithParam<PlaygroundBackend> {
25 public:
26 using AiksPlaygroundCallback =
27 std::function<std::optional<Picture>(AiksContext& renderer)>;
28
29 GoldenPlaygroundTest();
30
31 ~GoldenPlaygroundTest() override;
32
33 void SetUp();
34
35 void TearDown();
36
37 PlaygroundBackend GetBackend() const;
38
39 void SetTypographerContext(
40 std::shared_ptr<TypographerContext> typographer_context);
41
42 bool OpenPlaygroundHere(Picture picture);
43
44 bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
45
46 static bool ImGuiBegin(const char* name,
47 bool* p_open,
48 ImGuiWindowFlags flags);
49
50 std::shared_ptr<Texture> CreateTextureForFixture(
51 const char* fixture_name,
52 bool enable_mipmapping = false) const;
53
54 RuntimeStage::Map OpenAssetAsRuntimeStage(const char* asset_name) const;
55
56 std::shared_ptr<Context> GetContext() const;
57
58 std::shared_ptr<Context> MakeContext() const;
59
60 Point GetContentScale() const;
61
62 Scalar GetSecondsElapsed() const;
63
64 ISize GetWindowSize() const;
65
66 [[nodiscard]] fml::Status SetCapabilities(
67 const std::shared_ptr<Capabilities>& capabilities);
68
69 /// TODO(https://github.com/flutter/flutter/issues/139950): Remove this.
70 /// Returns true if `OpenPlaygroundHere` will actually render anything.
71 bool WillRenderSomething() const { return true; }
72
73 protected:
74 void SetWindowSize(ISize size);
75
76 private:
77 #if FML_OS_MACOSX
78 // This must be placed first so that the autorelease pool is not destroyed
79 // until the GoldenPlaygroundTestImpl has been destructed.
80 fml::ScopedNSAutoreleasePool autorelease_pool_;
81 #endif
82
83 std::shared_ptr<TypographerContext> typographer_context_;
84
85 struct GoldenPlaygroundTestImpl;
86 // This is only a shared_ptr so it can work with a forward declared type.
87 std::shared_ptr<GoldenPlaygroundTestImpl> pimpl_;
88
89 GoldenPlaygroundTest(const GoldenPlaygroundTest&) = delete;
90
91 GoldenPlaygroundTest& operator=(const GoldenPlaygroundTest&) = delete;
92 };
93
94 } // namespace impeller
95
96 #endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_PLAYGROUND_TEST_H_
impeller::GoldenPlaygroundTest::WillRenderSomething
bool WillRenderSomething() const
Definition: golden_playground_test.h:71
impeller::GoldenPlaygroundTest::ImGuiBegin
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
Definition: golden_playground_test_mac.cc:215
impeller::GoldenPlaygroundTest::GetContentScale
Point GetContentScale() const
Definition: golden_playground_test_mac.cc:267
impeller::GoldenPlaygroundTest::AiksPlaygroundCallback
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
Definition: golden_playground_test.h:27
impeller::GoldenPlaygroundTest::SetCapabilities
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities)
Definition: golden_playground_test_mac.cc:283
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::AiksContext
Definition: aiks_context.h:20
impeller::GoldenPlaygroundTest::MakeContext
std::shared_ptr< Context > MakeContext() const
Definition: golden_playground_test_mac.cc:248
aiks_context.h
playground.h
impeller::PlaygroundBackend
PlaygroundBackend
Definition: playground.h:29
impeller::GoldenPlaygroundTest::OpenPlaygroundHere
bool OpenPlaygroundHere(Picture picture)
Definition: golden_playground_test_mac.cc:188
typographer_context.h
impeller::GoldenPlaygroundTest::GetContext
std::shared_ptr< Context > GetContext() const
Definition: golden_playground_test_mac.cc:244
impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest
~GoldenPlaygroundTest() override
impeller::GoldenPlaygroundTest::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: golden_playground_test_mac.cc:122
impeller::Picture
Definition: picture.h:20
impeller::TSize< int64_t >
impeller::GoldenPlaygroundTest::GoldenPlaygroundTest
GoldenPlaygroundTest()
Definition: golden_playground_test_mac.cc:116
impeller::GoldenPlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: golden_playground_test_mac.cc:184
impeller::GoldenPlaygroundTest::SetWindowSize
void SetWindowSize(ISize size)
Definition: golden_playground_test_stub.cc:66
impeller::GoldenPlaygroundTest::SetUp
void SetUp()
Definition: golden_playground_test_mac.cc:131
impeller::GoldenPlaygroundTest
Definition: golden_playground_test.h:23
impeller::GoldenPlaygroundTest::CreateTextureForFixture
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
Definition: golden_playground_test_mac.cc:221
impeller::GoldenPlaygroundTest::GetSecondsElapsed
Scalar GetSecondsElapsed() const
Definition: golden_playground_test_mac.cc:271
impeller::GoldenPlaygroundTest::TearDown
void TearDown()
Definition: golden_playground_test_mac.cc:127
impeller::TPoint< Scalar >
render_target.h
impeller
Definition: aiks_blur_unittests.cc:20
impeller::GoldenPlaygroundTest::GetWindowSize
ISize GetWindowSize() const
Definition: golden_playground_test_mac.cc:275
impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage
RuntimeStage::Map OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: golden_playground_test_mac.cc:234
impeller::RuntimeStage::Map
std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > > Map
Definition: runtime_stage.h:23