| 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 #pragma once
6
7 #include <memory>
8
9 #include "flutter/fml/macros.h"
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
16 #if FML_OS_MACOSX
17 #include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
18 #endif
19
20 namespace impeller {
21
22 class GoldenPlaygroundTest
23 : public ::testing::TestWithParam<PlaygroundBackend> {
24 public:
25 using AiksPlaygroundCallback =
26 std::function<std::optional<Picture>(AiksContext& renderer)>;
27
28 GoldenPlaygroundTest();
29
30 ~GoldenPlaygroundTest() override;
31
32 void SetUp();
33
34 void TearDown();
35
36 PlaygroundBackend GetBackend() const;
37
38 void SetTypographerContext(
39 std::shared_ptr<TypographerContext> typographer_context);
40
41 bool OpenPlaygroundHere(Picture picture);
42
43 bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
44
45 std::shared_ptr<Texture> CreateTextureForFixture(
46 const char* fixture_name,
47 bool enable_mipmapping = false) const;
48
49 std::shared_ptr<RuntimeStage> OpenAssetAsRuntimeStage(
50 const char* asset_name) const;
51
52 std::shared_ptr<Context> GetContext() const;
53
54 Point GetContentScale() const;
55
56 Scalar GetSecondsElapsed() const;
57
58 ISize GetWindowSize() const;
59
60 private:
61 #if FML_OS_MACOSX
62 // This must be placed first so that the autorelease pool is not destroyed
63 // until the GoldenPlaygroundTestImpl has been destructed.
64 fml::ScopedNSAutoreleasePool autorelease_pool_;
65 #endif
66
67 std::shared_ptr<TypographerContext> typographer_context_;
68
69 struct GoldenPlaygroundTestImpl;
70 // This is only a shared_ptr so it can work with a forward declared type.
71 std::shared_ptr<GoldenPlaygroundTestImpl> pimpl_;
72
73 FML_DISALLOW_COPY_AND_ASSIGN(GoldenPlaygroundTest);
74 };
75
76 } // namespace impeller
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:26
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::AiksContext
Definition: aiks_context.h:20
aiks_context.h
playground.h
impeller::PlaygroundBackend
PlaygroundBackend
Definition: playground.h:25
impeller::GoldenPlaygroundTest::OpenPlaygroundHere
bool OpenPlaygroundHere(Picture picture)
Definition: golden_playground_test_mac.cc:140
typographer_context.h
impeller::GoldenPlaygroundTest::GetContext
std::shared_ptr< Context > GetContext() const
Definition: golden_playground_test_mac.cc:180
impeller::GoldenPlaygroundTest::GoldenPlaygroundTestImpl
Definition: golden_playground_test_mac.cc:87
impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest
~GoldenPlaygroundTest() override
impeller::GoldenPlaygroundTest::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: golden_playground_test_mac.cc:99
impeller::Picture
Definition: picture.h:19
impeller::TSize< int64_t >
impeller::GoldenPlaygroundTest::GoldenPlaygroundTest
GoldenPlaygroundTest()
Definition: golden_playground_test_mac.cc:93
impeller::GoldenPlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: golden_playground_test_mac.cc:136
impeller::GoldenPlaygroundTest::SetUp
void SetUp()
Definition: golden_playground_test_mac.cc:108
impeller::GoldenPlaygroundTest
Definition: golden_playground_test.h:22
impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage
std::shared_ptr< RuntimeStage > OpenAssetAsRuntimeStage(const char *asset_name) const
Definition: golden_playground_test_mac.cc:167
impeller::GoldenPlaygroundTest::CreateTextureForFixture
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
Definition: golden_playground_test_mac.cc:154
impeller::GoldenPlaygroundTest::GetSecondsElapsed
Scalar GetSecondsElapsed() const
Definition: golden_playground_test_mac.cc:188
impeller::GoldenPlaygroundTest::TearDown
void TearDown()
Definition: golden_playground_test_mac.cc:104
impeller::TPoint< Scalar >
render_target.h
impeller
Definition: aiks_context.cc:10
impeller::GoldenPlaygroundTest::GetWindowSize
ISize GetWindowSize() const
Definition: golden_playground_test_mac.cc:192