| 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/fml/macros.h"
11 #include "flutter/impeller/aiks/aiks_context.h"
12 #include "flutter/impeller/playground/playground.h"
13 #include "flutter/impeller/renderer/render_target.h"
14 #include "flutter/testing/testing.h"
15 #include "impeller/typographer/typographer_context.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 // TODO(dnfield): Delete this once
40 // https://github.com/flutter/flutter/issues/122823 is fixed.
41 bool BackendSupportsFragmentProgram() const {
42 return GetBackend() != PlaygroundBackend::kVulkan;
43 }
44
45 void SetTypographerContext(
46 std::shared_ptr<TypographerContext> typographer_context);
47
48 bool OpenPlaygroundHere(Picture picture);
49
50 bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
51
52 std::shared_ptr<Texture> CreateTextureForFixture(
53 const char* fixture_name,
54 bool enable_mipmapping = false) const;
55
56 RuntimeStage::Map OpenAssetAsRuntimeStage(const char* asset_name) const;
57
58 std::shared_ptr<Context> GetContext() 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::GetContentScale
Point GetContentScale() const
Definition: golden_playground_test_mac.cc:184
impeller::GoldenPlaygroundTest::AiksPlaygroundCallback
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
Definition: golden_playground_test.h:27
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::GoldenPlaygroundTest::SetCapabilities
fml::Status SetCapabilities(const std::shared_ptr< Capabilities > &capabilities)
Definition: golden_playground_test_mac.cc:200
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::AiksContext
Definition: aiks_context.h:20
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:143
typographer_context.h
impeller::GoldenPlaygroundTest::GetContext
std::shared_ptr< Context > GetContext() const
Definition: golden_playground_test_mac.cc:180
impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest
~GoldenPlaygroundTest() override
impeller::GoldenPlaygroundTest::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: golden_playground_test_mac.cc:102
impeller::Picture
Definition: picture.h:20
impeller::TSize< int64_t >
impeller::GoldenPlaygroundTest::GoldenPlaygroundTest
GoldenPlaygroundTest()
Definition: golden_playground_test_mac.cc:96
impeller::GoldenPlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: golden_playground_test_mac.cc:139
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:111
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:157
impeller::GoldenPlaygroundTest::GetSecondsElapsed
Scalar GetSecondsElapsed() const
Definition: golden_playground_test_mac.cc:188
impeller::GoldenPlaygroundTest::TearDown
void TearDown()
Definition: golden_playground_test_mac.cc:107
impeller::TPoint
Definition: point.h:22
render_target.h
impeller::GoldenPlaygroundTest::BackendSupportsFragmentProgram
bool BackendSupportsFragmentProgram() const
Definition: golden_playground_test.h:41
impeller
Definition: aiks_context.cc:10
impeller::GoldenPlaygroundTest::GetWindowSize
ISize GetWindowSize() const
Definition: golden_playground_test_mac.cc:192
impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage
RuntimeStage::Map OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: golden_playground_test_mac.cc:170
impeller::RuntimeStage::Map
std::map< RuntimeStageBackend, std::shared_ptr< RuntimeStage > > Map
Definition: runtime_stage.h:22