Skip to content

Commit 3b1dfc4

Browse files
chinmaygardednfield
authored andcommitted
Add an OpenGL ES stub and parameterize all playgrounds on rendering backend. (flutter#141)
As we add more rendering backends, adding a new enum value to a single macro `INSTANTIATE_PLAYGROUND_SUITE` in `playground.h` will create a new test variant in any suite that uses playgrounds. The invocations will look like the following: ``` [ RUN ] Play/TypographerTest.CanCreateGlyphAtlas/Metal [ OK ] Play/TypographerTest.CanCreateGlyphAtlas/Metal (210 ms) [ RUN ] Play/TypographerTest.CanCreateGlyphAtlas/OpenGLES [ OK ] Play/TypographerTest.CanCreateGlyphAtlas/OpenGLES (xxx ms) ``` If you want to test just one backend, you may add a filter like so `--gtest_filter="*/Metal"` Right now, I have not added a the OpenGLES variant to the default test suite instantiation since there are so many failures (that is just a stub ATM). But, if the need arises to skip specific tests based on the backend in use (we won't support instancing in OpenGLES for example), the backend for the playground may be queried before deciding to GTEST_SKIP the invocation. One additional change in the patch that will be reworked soon is the Metal specificity of the source set generated after reflection. This will be made agnostic in the coming few patches. Right now, these headers are in the `mtl` folder.
1 parent 8b881c6 commit 3b1dfc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1204
-240
lines changed

impeller/aiks/aiks_unittests.cc

+30-29
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ namespace impeller {
1919
namespace testing {
2020

2121
using AiksTest = AiksPlayground;
22+
INSTANTIATE_PLAYGROUND_SUITE(AiksTest);
2223

23-
TEST_F(AiksTest, CanvasCTMCanBeUpdated) {
24+
TEST_P(AiksTest, CanvasCTMCanBeUpdated) {
2425
Canvas canvas;
2526
Matrix identity;
2627
ASSERT_MATRIX_NEAR(canvas.GetCurrentTransformation(), identity);
@@ -29,7 +30,7 @@ TEST_F(AiksTest, CanvasCTMCanBeUpdated) {
2930
Matrix::MakeTranslation({100.0, 100.0, 0.0}));
3031
}
3132

32-
TEST_F(AiksTest, CanvasCanPushPopCTM) {
33+
TEST_P(AiksTest, CanvasCanPushPopCTM) {
3334
Canvas canvas;
3435
ASSERT_EQ(canvas.GetSaveCount(), 1u);
3536
ASSERT_EQ(canvas.Restore(), false);
@@ -45,7 +46,7 @@ TEST_F(AiksTest, CanvasCanPushPopCTM) {
4546
Matrix::MakeTranslation({100.0, 100.0, 0.0}));
4647
}
4748

48-
TEST_F(AiksTest, CanRenderColoredRect) {
49+
TEST_P(AiksTest, CanRenderColoredRect) {
4950
Canvas canvas;
5051
Paint paint;
5152
paint.color = Color::Red();
@@ -56,7 +57,7 @@ TEST_F(AiksTest, CanRenderColoredRect) {
5657
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
5758
}
5859

59-
TEST_F(AiksTest, CanRenderImage) {
60+
TEST_P(AiksTest, CanRenderImage) {
6061
Canvas canvas;
6162
Paint paint;
6263
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
@@ -65,7 +66,7 @@ TEST_F(AiksTest, CanRenderImage) {
6566
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
6667
}
6768

68-
TEST_F(AiksTest, CanRenderImageRect) {
69+
TEST_P(AiksTest, CanRenderImageRect) {
6970
Canvas canvas;
7071
Paint paint;
7172
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
@@ -81,7 +82,7 @@ TEST_F(AiksTest, CanRenderImageRect) {
8182
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
8283
}
8384

84-
TEST_F(AiksTest, CanRenderStrokes) {
85+
TEST_P(AiksTest, CanRenderStrokes) {
8586
Canvas canvas;
8687
Paint paint;
8788
paint.color = Color::Red();
@@ -92,7 +93,7 @@ TEST_F(AiksTest, CanRenderStrokes) {
9293
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
9394
}
9495

95-
TEST_F(AiksTest, CanRenderCurvedStrokes) {
96+
TEST_P(AiksTest, CanRenderCurvedStrokes) {
9697
Canvas canvas;
9798
Paint paint;
9899
paint.color = Color::Red();
@@ -102,7 +103,7 @@ TEST_F(AiksTest, CanRenderCurvedStrokes) {
102103
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
103104
}
104105

105-
TEST_F(AiksTest, CanRenderClips) {
106+
TEST_P(AiksTest, CanRenderClips) {
106107
Canvas canvas;
107108
Paint paint;
108109
paint.color = Color::Fuchsia();
@@ -112,7 +113,7 @@ TEST_F(AiksTest, CanRenderClips) {
112113
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
113114
}
114115

115-
TEST_F(AiksTest, CanRenderNestedClips) {
116+
TEST_P(AiksTest, CanRenderNestedClips) {
116117
Canvas canvas;
117118
Paint paint;
118119
paint.color = Color::Fuchsia();
@@ -125,7 +126,7 @@ TEST_F(AiksTest, CanRenderNestedClips) {
125126
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
126127
}
127128

128-
TEST_F(AiksTest, CanRenderDifferenceClips) {
129+
TEST_P(AiksTest, CanRenderDifferenceClips) {
129130
Paint paint;
130131
Canvas canvas;
131132
canvas.Translate({400, 400});
@@ -162,7 +163,7 @@ TEST_F(AiksTest, CanRenderDifferenceClips) {
162163
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
163164
}
164165

165-
TEST_F(AiksTest, ClipsUseCurrentTransform) {
166+
TEST_P(AiksTest, ClipsUseCurrentTransform) {
166167
std::array<Color, 5> colors = {Color::White(), Color::Black(),
167168
Color::SkyBlue(), Color::Red(),
168169
Color::Yellow()};
@@ -180,7 +181,7 @@ TEST_F(AiksTest, ClipsUseCurrentTransform) {
180181
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
181182
}
182183

183-
TEST_F(AiksTest, CanSaveLayerStandalone) {
184+
TEST_P(AiksTest, CanSaveLayerStandalone) {
184185
Canvas canvas;
185186

186187
Paint red;
@@ -198,7 +199,7 @@ TEST_F(AiksTest, CanSaveLayerStandalone) {
198199
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
199200
}
200201

201-
TEST_F(AiksTest, CanRenderGroupOpacity) {
202+
TEST_P(AiksTest, CanRenderGroupOpacity) {
202203
Canvas canvas;
203204

204205
Paint red;
@@ -222,7 +223,7 @@ TEST_F(AiksTest, CanRenderGroupOpacity) {
222223
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
223224
}
224225

225-
TEST_F(AiksTest, CanPerformFullScreenMSAA) {
226+
TEST_P(AiksTest, CanPerformFullScreenMSAA) {
226227
Canvas canvas;
227228

228229
Paint red;
@@ -233,7 +234,7 @@ TEST_F(AiksTest, CanPerformFullScreenMSAA) {
233234
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
234235
}
235236

236-
TEST_F(AiksTest, CanPerformSkew) {
237+
TEST_P(AiksTest, CanPerformSkew) {
237238
Canvas canvas;
238239

239240
Paint red;
@@ -245,7 +246,7 @@ TEST_F(AiksTest, CanPerformSkew) {
245246
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
246247
}
247248

248-
TEST_F(AiksTest, CanPerformSaveLayerWithBounds) {
249+
TEST_P(AiksTest, CanPerformSaveLayerWithBounds) {
249250
Canvas canvas;
250251

251252
Paint red;
@@ -271,7 +272,7 @@ TEST_F(AiksTest, CanPerformSaveLayerWithBounds) {
271272
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
272273
}
273274

274-
TEST_F(AiksTest,
275+
TEST_P(AiksTest,
275276
CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
276277
Canvas canvas;
277278

@@ -298,7 +299,7 @@ TEST_F(AiksTest,
298299
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
299300
}
300301

301-
TEST_F(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
302+
TEST_P(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
302303
Canvas canvas;
303304

304305
Paint paint;
@@ -318,7 +319,7 @@ TEST_F(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
318319
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
319320
}
320321

321-
TEST_F(AiksTest, CanRenderDifferencePaths) {
322+
TEST_P(AiksTest, CanRenderDifferencePaths) {
322323
Canvas canvas;
323324

324325
Paint paint;
@@ -393,23 +394,23 @@ bool RenderTextInCanvas(std::shared_ptr<Context> context,
393394
return true;
394395
}
395396

396-
TEST_F(AiksTest, CanRenderTextFrame) {
397+
TEST_P(AiksTest, CanRenderTextFrame) {
397398
Canvas canvas;
398399
ASSERT_TRUE(RenderTextInCanvas(
399400
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
400401
"Roboto-Regular.ttf"));
401402
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
402403
}
403404

404-
TEST_F(AiksTest, CanRenderItalicizedText) {
405+
TEST_P(AiksTest, CanRenderItalicizedText) {
405406
Canvas canvas;
406407
ASSERT_TRUE(RenderTextInCanvas(
407408
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
408409
"HomemadeApple.ttf"));
409410
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
410411
}
411412

412-
TEST_F(AiksTest, CanRenderEmojiTextFrame) {
413+
TEST_P(AiksTest, CanRenderEmojiTextFrame) {
413414
Canvas canvas;
414415
ASSERT_TRUE(RenderTextInCanvas(
415416
GetContext(), canvas,
@@ -418,7 +419,7 @@ TEST_F(AiksTest, CanRenderEmojiTextFrame) {
418419
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
419420
}
420421

421-
TEST_F(AiksTest, CanRenderTextInSaveLayer) {
422+
TEST_P(AiksTest, CanRenderTextInSaveLayer) {
422423
Canvas canvas;
423424
canvas.DrawPaint({.color = Color::White()});
424425
canvas.Translate({100, 100});
@@ -439,15 +440,15 @@ TEST_F(AiksTest, CanRenderTextInSaveLayer) {
439440
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
440441
}
441442

442-
TEST_F(AiksTest, CanDrawPaint) {
443+
TEST_P(AiksTest, CanDrawPaint) {
443444
Paint paint;
444445
paint.color = Color::MediumTurquoise();
445446
Canvas canvas;
446447
canvas.DrawPaint(paint);
447448
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
448449
}
449450

450-
TEST_F(AiksTest, PaintBlendModeIsRespected) {
451+
TEST_P(AiksTest, PaintBlendModeIsRespected) {
451452
Paint paint;
452453
Canvas canvas;
453454
// Default is kSourceOver.
@@ -466,7 +467,7 @@ TEST_F(AiksTest, PaintBlendModeIsRespected) {
466467
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
467468
}
468469

469-
TEST_F(AiksTest, TransformMultipliesCorrectly) {
470+
TEST_P(AiksTest, TransformMultipliesCorrectly) {
470471
Canvas canvas;
471472
ASSERT_MATRIX_NEAR(canvas.GetCurrentTransformation(), Matrix());
472473

@@ -505,7 +506,7 @@ TEST_F(AiksTest, TransformMultipliesCorrectly) {
505506
// clang-format on
506507
}
507508

508-
TEST_F(AiksTest, SolidStrokesRenderCorrectly) {
509+
TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
509510
// Compare with https://fiddle.skia.org/c/027392122bec8ac2b5d5de00a4b9bbe2
510511
bool first_frame = true;
511512
auto callback = [&](AiksContext& renderer, RenderPass& pass) {
@@ -578,7 +579,7 @@ TEST_F(AiksTest, SolidStrokesRenderCorrectly) {
578579
ASSERT_TRUE(OpenPlaygroundHere(callback));
579580
}
580581

581-
TEST_F(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
582+
TEST_P(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
582583
auto callback = [](AiksContext& renderer, RenderPass& pass) {
583584
Canvas canvas;
584585
Paint alpha;
@@ -610,7 +611,7 @@ TEST_F(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
610611
ASSERT_TRUE(OpenPlaygroundHere(callback));
611612
}
612613

613-
TEST_F(AiksTest, DrawRectStrokesRenderCorrectly) {
614+
TEST_P(AiksTest, DrawRectStrokesRenderCorrectly) {
614615
Canvas canvas;
615616
Paint paint;
616617
paint.color = Color::Red();

impeller/base/config.h

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#pragma once
66

7+
#include <cstdlib>
8+
9+
#include "flutter/fml/logging.h"
10+
711
#if defined(__GNUC__) || defined(__clang__)
812
#define IMPELLER_COMPILER_CLANG 1
913
#else // defined(__GNUC__) || defined(__clang__)
@@ -16,3 +20,18 @@
1620
#else // IMPELLER_COMPILER_CLANG
1721
#define IMPELLER_PRINTF_FORMAT(format_number, args_number)
1822
#endif // IMPELLER_COMPILER_CLANG
23+
24+
#define IMPELLER_UNIMPLEMENTED \
25+
impeller::ImpellerUnimplemented(__FUNCTION__, __FILE__, __LINE__);
26+
27+
namespace impeller {
28+
29+
[[noreturn]] inline void ImpellerUnimplemented(const char* method,
30+
const char* file,
31+
int line) {
32+
FML_CHECK(false) << "Unimplemented: " << method << " in " << file << ":"
33+
<< line;
34+
std::abort();
35+
}
36+
37+
} // namespace impeller

impeller/display_list/display_list_unittests.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,32 @@ namespace impeller {
1818
namespace testing {
1919

2020
using DisplayListTest = DisplayListPlayground;
21+
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);
2122

22-
TEST_F(DisplayListTest, CanDrawRect) {
23+
TEST_P(DisplayListTest, CanDrawRect) {
2324
flutter::DisplayListBuilder builder;
2425
builder.setColor(SK_ColorBLUE);
2526
builder.drawRect(SkRect::MakeXYWH(10, 10, 100, 100));
2627
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
2728
}
2829

29-
TEST_F(DisplayListTest, CanDrawTextBlob) {
30+
TEST_P(DisplayListTest, CanDrawTextBlob) {
3031
flutter::DisplayListBuilder builder;
3132
builder.setColor(SK_ColorBLUE);
3233
builder.drawTextBlob(SkTextBlob::MakeFromString("Hello", CreateTestFont()),
3334
100, 100);
3435
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
3536
}
3637

37-
TEST_F(DisplayListTest, CanDrawImage) {
38+
TEST_P(DisplayListTest, CanDrawImage) {
3839
auto texture = CreateTextureForFixture("embarcadero.jpg");
3940
flutter::DisplayListBuilder builder;
4041
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
4142
SkSamplingOptions{}, true);
4243
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
4344
}
4445

45-
TEST_F(DisplayListTest, CanDrawCapsAndJoins) {
46+
TEST_P(DisplayListTest, CanDrawCapsAndJoins) {
4647
flutter::DisplayListBuilder builder;
4748

4849
builder.setStyle(SkPaint::Style::kStroke_Style);
@@ -87,7 +88,7 @@ TEST_F(DisplayListTest, CanDrawCapsAndJoins) {
8788
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
8889
}
8990

90-
TEST_F(DisplayListTest, CanDrawArc) {
91+
TEST_P(DisplayListTest, CanDrawArc) {
9192
bool first_frame = true;
9293
auto callback = [&]() {
9394
if (first_frame) {
@@ -127,7 +128,7 @@ TEST_F(DisplayListTest, CanDrawArc) {
127128
ASSERT_TRUE(OpenPlaygroundHere(callback));
128129
}
129130

130-
TEST_F(DisplayListTest, StrokedPathsDrawCorrectly) {
131+
TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
131132
flutter::DisplayListBuilder builder;
132133
builder.setColor(SK_ColorRED);
133134
builder.setStyle(SkPaint::Style::kStroke_Style);

impeller/entity/contents/content_context.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
#include "flutter/fml/macros.h"
1212
#include "fml/logging.h"
1313
#include "impeller/base/validation.h"
14-
#include "impeller/entity/border_mask_blur.frag.h"
15-
#include "impeller/entity/border_mask_blur.vert.h"
1614
#include "impeller/entity/entity.h"
17-
#include "impeller/entity/gaussian_blur.frag.h"
18-
#include "impeller/entity/gaussian_blur.vert.h"
19-
#include "impeller/entity/glyph_atlas.frag.h"
20-
#include "impeller/entity/glyph_atlas.vert.h"
21-
#include "impeller/entity/gradient_fill.frag.h"
22-
#include "impeller/entity/gradient_fill.vert.h"
23-
#include "impeller/entity/solid_fill.frag.h"
24-
#include "impeller/entity/solid_fill.vert.h"
25-
#include "impeller/entity/solid_stroke.frag.h"
26-
#include "impeller/entity/solid_stroke.vert.h"
27-
#include "impeller/entity/texture_blend.frag.h"
28-
#include "impeller/entity/texture_blend.vert.h"
29-
#include "impeller/entity/texture_blend_screen.frag.h"
30-
#include "impeller/entity/texture_blend_screen.vert.h"
31-
#include "impeller/entity/texture_fill.frag.h"
32-
#include "impeller/entity/texture_fill.vert.h"
15+
#include "impeller/entity/mtl/border_mask_blur.frag.h"
16+
#include "impeller/entity/mtl/border_mask_blur.vert.h"
17+
#include "impeller/entity/mtl/gaussian_blur.frag.h"
18+
#include "impeller/entity/mtl/gaussian_blur.vert.h"
19+
#include "impeller/entity/mtl/glyph_atlas.frag.h"
20+
#include "impeller/entity/mtl/glyph_atlas.vert.h"
21+
#include "impeller/entity/mtl/gradient_fill.frag.h"
22+
#include "impeller/entity/mtl/gradient_fill.vert.h"
23+
#include "impeller/entity/mtl/solid_fill.frag.h"
24+
#include "impeller/entity/mtl/solid_fill.vert.h"
25+
#include "impeller/entity/mtl/solid_stroke.frag.h"
26+
#include "impeller/entity/mtl/solid_stroke.vert.h"
27+
#include "impeller/entity/mtl/texture_blend.frag.h"
28+
#include "impeller/entity/mtl/texture_blend.vert.h"
29+
#include "impeller/entity/mtl/texture_blend_screen.frag.h"
30+
#include "impeller/entity/mtl/texture_blend_screen.vert.h"
31+
#include "impeller/entity/mtl/texture_fill.frag.h"
32+
#include "impeller/entity/mtl/texture_fill.vert.h"
3333
#include "impeller/renderer/formats.h"
3434

3535
namespace impeller {

0 commit comments

Comments
 (0)