Add an OpenGL ES stub and parameterize all playgrounds on rendering backend. (flutter/engine#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.
This commit is contained in:
@@ -19,8 +19,9 @@ namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using AiksTest = AiksPlayground;
|
||||
INSTANTIATE_PLAYGROUND_SUITE(AiksTest);
|
||||
|
||||
TEST_F(AiksTest, CanvasCTMCanBeUpdated) {
|
||||
TEST_P(AiksTest, CanvasCTMCanBeUpdated) {
|
||||
Canvas canvas;
|
||||
Matrix identity;
|
||||
ASSERT_MATRIX_NEAR(canvas.GetCurrentTransformation(), identity);
|
||||
@@ -29,7 +30,7 @@ TEST_F(AiksTest, CanvasCTMCanBeUpdated) {
|
||||
Matrix::MakeTranslation({100.0, 100.0, 0.0}));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanvasCanPushPopCTM) {
|
||||
TEST_P(AiksTest, CanvasCanPushPopCTM) {
|
||||
Canvas canvas;
|
||||
ASSERT_EQ(canvas.GetSaveCount(), 1u);
|
||||
ASSERT_EQ(canvas.Restore(), false);
|
||||
@@ -45,7 +46,7 @@ TEST_F(AiksTest, CanvasCanPushPopCTM) {
|
||||
Matrix::MakeTranslation({100.0, 100.0, 0.0}));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderColoredRect) {
|
||||
TEST_P(AiksTest, CanRenderColoredRect) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
@@ -56,7 +57,7 @@ TEST_F(AiksTest, CanRenderColoredRect) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderImage) {
|
||||
TEST_P(AiksTest, CanRenderImage) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
|
||||
@@ -65,7 +66,7 @@ TEST_F(AiksTest, CanRenderImage) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderImageRect) {
|
||||
TEST_P(AiksTest, CanRenderImageRect) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
|
||||
@@ -81,7 +82,7 @@ TEST_F(AiksTest, CanRenderImageRect) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderStrokes) {
|
||||
TEST_P(AiksTest, CanRenderStrokes) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
@@ -92,7 +93,7 @@ TEST_F(AiksTest, CanRenderStrokes) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderCurvedStrokes) {
|
||||
TEST_P(AiksTest, CanRenderCurvedStrokes) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
@@ -102,7 +103,7 @@ TEST_F(AiksTest, CanRenderCurvedStrokes) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderClips) {
|
||||
TEST_P(AiksTest, CanRenderClips) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Fuchsia();
|
||||
@@ -112,7 +113,7 @@ TEST_F(AiksTest, CanRenderClips) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderNestedClips) {
|
||||
TEST_P(AiksTest, CanRenderNestedClips) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Fuchsia();
|
||||
@@ -125,7 +126,7 @@ TEST_F(AiksTest, CanRenderNestedClips) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderDifferenceClips) {
|
||||
TEST_P(AiksTest, CanRenderDifferenceClips) {
|
||||
Paint paint;
|
||||
Canvas canvas;
|
||||
canvas.Translate({400, 400});
|
||||
@@ -162,7 +163,7 @@ TEST_F(AiksTest, CanRenderDifferenceClips) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, ClipsUseCurrentTransform) {
|
||||
TEST_P(AiksTest, ClipsUseCurrentTransform) {
|
||||
std::array<Color, 5> colors = {Color::White(), Color::Black(),
|
||||
Color::SkyBlue(), Color::Red(),
|
||||
Color::Yellow()};
|
||||
@@ -180,7 +181,7 @@ TEST_F(AiksTest, ClipsUseCurrentTransform) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanSaveLayerStandalone) {
|
||||
TEST_P(AiksTest, CanSaveLayerStandalone) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint red;
|
||||
@@ -198,7 +199,7 @@ TEST_F(AiksTest, CanSaveLayerStandalone) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderGroupOpacity) {
|
||||
TEST_P(AiksTest, CanRenderGroupOpacity) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint red;
|
||||
@@ -222,7 +223,7 @@ TEST_F(AiksTest, CanRenderGroupOpacity) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanPerformFullScreenMSAA) {
|
||||
TEST_P(AiksTest, CanPerformFullScreenMSAA) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint red;
|
||||
@@ -233,7 +234,7 @@ TEST_F(AiksTest, CanPerformFullScreenMSAA) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanPerformSkew) {
|
||||
TEST_P(AiksTest, CanPerformSkew) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint red;
|
||||
@@ -245,7 +246,7 @@ TEST_F(AiksTest, CanPerformSkew) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanPerformSaveLayerWithBounds) {
|
||||
TEST_P(AiksTest, CanPerformSaveLayerWithBounds) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint red;
|
||||
@@ -271,7 +272,7 @@ TEST_F(AiksTest, CanPerformSaveLayerWithBounds) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest,
|
||||
TEST_P(AiksTest,
|
||||
CanPerformSaveLayerWithBoundsAndLargerIntermediateIsNotAllocated) {
|
||||
Canvas canvas;
|
||||
|
||||
@@ -298,7 +299,7 @@ TEST_F(AiksTest,
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
|
||||
TEST_P(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint paint;
|
||||
@@ -318,7 +319,7 @@ TEST_F(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderDifferencePaths) {
|
||||
TEST_P(AiksTest, CanRenderDifferencePaths) {
|
||||
Canvas canvas;
|
||||
|
||||
Paint paint;
|
||||
@@ -393,7 +394,7 @@ bool RenderTextInCanvas(std::shared_ptr<Context> context,
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderTextFrame) {
|
||||
TEST_P(AiksTest, CanRenderTextFrame) {
|
||||
Canvas canvas;
|
||||
ASSERT_TRUE(RenderTextInCanvas(
|
||||
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
|
||||
@@ -401,7 +402,7 @@ TEST_F(AiksTest, CanRenderTextFrame) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderItalicizedText) {
|
||||
TEST_P(AiksTest, CanRenderItalicizedText) {
|
||||
Canvas canvas;
|
||||
ASSERT_TRUE(RenderTextInCanvas(
|
||||
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
|
||||
@@ -409,7 +410,7 @@ TEST_F(AiksTest, CanRenderItalicizedText) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderEmojiTextFrame) {
|
||||
TEST_P(AiksTest, CanRenderEmojiTextFrame) {
|
||||
Canvas canvas;
|
||||
ASSERT_TRUE(RenderTextInCanvas(
|
||||
GetContext(), canvas,
|
||||
@@ -418,7 +419,7 @@ TEST_F(AiksTest, CanRenderEmojiTextFrame) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanRenderTextInSaveLayer) {
|
||||
TEST_P(AiksTest, CanRenderTextInSaveLayer) {
|
||||
Canvas canvas;
|
||||
canvas.DrawPaint({.color = Color::White()});
|
||||
canvas.Translate({100, 100});
|
||||
@@ -439,7 +440,7 @@ TEST_F(AiksTest, CanRenderTextInSaveLayer) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CanDrawPaint) {
|
||||
TEST_P(AiksTest, CanDrawPaint) {
|
||||
Paint paint;
|
||||
paint.color = Color::MediumTurquoise();
|
||||
Canvas canvas;
|
||||
@@ -447,7 +448,7 @@ TEST_F(AiksTest, CanDrawPaint) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, PaintBlendModeIsRespected) {
|
||||
TEST_P(AiksTest, PaintBlendModeIsRespected) {
|
||||
Paint paint;
|
||||
Canvas canvas;
|
||||
// Default is kSourceOver.
|
||||
@@ -466,7 +467,7 @@ TEST_F(AiksTest, PaintBlendModeIsRespected) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, TransformMultipliesCorrectly) {
|
||||
TEST_P(AiksTest, TransformMultipliesCorrectly) {
|
||||
Canvas canvas;
|
||||
ASSERT_MATRIX_NEAR(canvas.GetCurrentTransformation(), Matrix());
|
||||
|
||||
@@ -505,7 +506,7 @@ TEST_F(AiksTest, TransformMultipliesCorrectly) {
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, SolidStrokesRenderCorrectly) {
|
||||
TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
|
||||
// Compare with https://fiddle.skia.org/c/027392122bec8ac2b5d5de00a4b9bbe2
|
||||
bool first_frame = true;
|
||||
auto callback = [&](AiksContext& renderer, RenderPass& pass) {
|
||||
@@ -578,7 +579,7 @@ TEST_F(AiksTest, SolidStrokesRenderCorrectly) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
|
||||
TEST_P(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
|
||||
auto callback = [](AiksContext& renderer, RenderPass& pass) {
|
||||
Canvas canvas;
|
||||
Paint alpha;
|
||||
@@ -610,7 +611,7 @@ TEST_F(AiksTest, CoverageOriginShouldBeAccountedForInSubpasses) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(AiksTest, DrawRectStrokesRenderCorrectly) {
|
||||
TEST_P(AiksTest, DrawRectStrokesRenderCorrectly) {
|
||||
Canvas canvas;
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define IMPELLER_COMPILER_CLANG 1
|
||||
#else // defined(__GNUC__) || defined(__clang__)
|
||||
@@ -16,3 +20,18 @@
|
||||
#else // IMPELLER_COMPILER_CLANG
|
||||
#define IMPELLER_PRINTF_FORMAT(format_number, args_number)
|
||||
#endif // IMPELLER_COMPILER_CLANG
|
||||
|
||||
#define IMPELLER_UNIMPLEMENTED \
|
||||
impeller::ImpellerUnimplemented(__FUNCTION__, __FILE__, __LINE__);
|
||||
|
||||
namespace impeller {
|
||||
|
||||
[[noreturn]] inline void ImpellerUnimplemented(const char* method,
|
||||
const char* file,
|
||||
int line) {
|
||||
FML_CHECK(false) << "Unimplemented: " << method << " in " << file << ":"
|
||||
<< line;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -18,15 +18,16 @@ namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using DisplayListTest = DisplayListPlayground;
|
||||
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);
|
||||
|
||||
TEST_F(DisplayListTest, CanDrawRect) {
|
||||
TEST_P(DisplayListTest, CanDrawRect) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.setColor(SK_ColorBLUE);
|
||||
builder.drawRect(SkRect::MakeXYWH(10, 10, 100, 100));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_F(DisplayListTest, CanDrawTextBlob) {
|
||||
TEST_P(DisplayListTest, CanDrawTextBlob) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.setColor(SK_ColorBLUE);
|
||||
builder.drawTextBlob(SkTextBlob::MakeFromString("Hello", CreateTestFont()),
|
||||
@@ -34,7 +35,7 @@ TEST_F(DisplayListTest, CanDrawTextBlob) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_F(DisplayListTest, CanDrawImage) {
|
||||
TEST_P(DisplayListTest, CanDrawImage) {
|
||||
auto texture = CreateTextureForFixture("embarcadero.jpg");
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.drawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
|
||||
@@ -42,7 +43,7 @@ TEST_F(DisplayListTest, CanDrawImage) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_F(DisplayListTest, CanDrawCapsAndJoins) {
|
||||
TEST_P(DisplayListTest, CanDrawCapsAndJoins) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
|
||||
builder.setStyle(SkPaint::Style::kStroke_Style);
|
||||
@@ -87,7 +88,7 @@ TEST_F(DisplayListTest, CanDrawCapsAndJoins) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_F(DisplayListTest, CanDrawArc) {
|
||||
TEST_P(DisplayListTest, CanDrawArc) {
|
||||
bool first_frame = true;
|
||||
auto callback = [&]() {
|
||||
if (first_frame) {
|
||||
@@ -127,7 +128,7 @@ TEST_F(DisplayListTest, CanDrawArc) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(DisplayListTest, StrokedPathsDrawCorrectly) {
|
||||
TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.setColor(SK_ColorRED);
|
||||
builder.setStyle(SkPaint::Style::kStroke_Style);
|
||||
|
||||
@@ -11,25 +11,25 @@
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "fml/logging.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/entity/border_mask_blur.frag.h"
|
||||
#include "impeller/entity/border_mask_blur.vert.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/gaussian_blur.frag.h"
|
||||
#include "impeller/entity/gaussian_blur.vert.h"
|
||||
#include "impeller/entity/glyph_atlas.frag.h"
|
||||
#include "impeller/entity/glyph_atlas.vert.h"
|
||||
#include "impeller/entity/gradient_fill.frag.h"
|
||||
#include "impeller/entity/gradient_fill.vert.h"
|
||||
#include "impeller/entity/solid_fill.frag.h"
|
||||
#include "impeller/entity/solid_fill.vert.h"
|
||||
#include "impeller/entity/solid_stroke.frag.h"
|
||||
#include "impeller/entity/solid_stroke.vert.h"
|
||||
#include "impeller/entity/texture_blend.frag.h"
|
||||
#include "impeller/entity/texture_blend.vert.h"
|
||||
#include "impeller/entity/texture_blend_screen.frag.h"
|
||||
#include "impeller/entity/texture_blend_screen.vert.h"
|
||||
#include "impeller/entity/texture_fill.frag.h"
|
||||
#include "impeller/entity/texture_fill.vert.h"
|
||||
#include "impeller/entity/mtl/border_mask_blur.frag.h"
|
||||
#include "impeller/entity/mtl/border_mask_blur.vert.h"
|
||||
#include "impeller/entity/mtl/gaussian_blur.frag.h"
|
||||
#include "impeller/entity/mtl/gaussian_blur.vert.h"
|
||||
#include "impeller/entity/mtl/glyph_atlas.frag.h"
|
||||
#include "impeller/entity/mtl/glyph_atlas.vert.h"
|
||||
#include "impeller/entity/mtl/gradient_fill.frag.h"
|
||||
#include "impeller/entity/mtl/gradient_fill.vert.h"
|
||||
#include "impeller/entity/mtl/solid_fill.frag.h"
|
||||
#include "impeller/entity/mtl/solid_fill.vert.h"
|
||||
#include "impeller/entity/mtl/solid_stroke.frag.h"
|
||||
#include "impeller/entity/mtl/solid_stroke.vert.h"
|
||||
#include "impeller/entity/mtl/texture_blend.frag.h"
|
||||
#include "impeller/entity/mtl/texture_blend.vert.h"
|
||||
#include "impeller/entity/mtl/texture_blend_screen.frag.h"
|
||||
#include "impeller/entity/mtl/texture_blend_screen.vert.h"
|
||||
#include "impeller/entity/mtl/texture_fill.frag.h"
|
||||
#include "impeller/entity/mtl/texture_fill.vert.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/entity/contents/contents.h"
|
||||
#include "impeller/entity/solid_stroke.vert.h"
|
||||
#include "impeller/entity/mtl/solid_stroke.vert.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
#include "impeller/geometry/path_component.h"
|
||||
#include "impeller/geometry/point.h"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/texture_fill.frag.h"
|
||||
#include "impeller/entity/texture_fill.vert.h"
|
||||
#include "impeller/entity/mtl/texture_fill.frag.h"
|
||||
#include "impeller/entity/mtl/texture_fill.vert.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/sampler_library.h"
|
||||
#include "impeller/tessellator/tessellator.h"
|
||||
|
||||
@@ -24,20 +24,21 @@ namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using EntityTest = EntityPlayground;
|
||||
INSTANTIATE_PLAYGROUND_SUITE(EntityTest);
|
||||
|
||||
TEST_F(EntityTest, CanCreateEntity) {
|
||||
TEST_P(EntityTest, CanCreateEntity) {
|
||||
Entity entity;
|
||||
ASSERT_TRUE(entity.GetTransformation().IsIdentity());
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, CanDrawRect) {
|
||||
TEST_P(EntityTest, CanDrawRect) {
|
||||
Entity entity;
|
||||
entity.SetPath(PathBuilder{}.AddRect({100, 100, 100, 100}).TakePath());
|
||||
entity.SetContents(SolidColorContents::Make(Color::Red()));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, ThreeStrokesInOnePath) {
|
||||
TEST_P(EntityTest, ThreeStrokesInOnePath) {
|
||||
Path path = PathBuilder{}
|
||||
.MoveTo({100, 100})
|
||||
.LineTo({100, 200})
|
||||
@@ -56,7 +57,7 @@ TEST_F(EntityTest, ThreeStrokesInOnePath) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, TriangleInsideASquare) {
|
||||
TEST_P(EntityTest, TriangleInsideASquare) {
|
||||
auto callback = [&](ContentContext& context, RenderPass& pass) {
|
||||
Point a = IMPELLER_PLAYGROUND_POINT(Point(10, 10), 20, Color::White());
|
||||
Point b = IMPELLER_PLAYGROUND_POINT(Point(210, 10), 20, Color::White());
|
||||
@@ -89,7 +90,7 @@ TEST_F(EntityTest, TriangleInsideASquare) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, StrokeCapAndJoinTest) {
|
||||
TEST_P(EntityTest, StrokeCapAndJoinTest) {
|
||||
const Point padding(300, 250);
|
||||
const Point margin(140, 180);
|
||||
|
||||
@@ -224,7 +225,7 @@ TEST_F(EntityTest, StrokeCapAndJoinTest) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, CubicCurveTest) {
|
||||
TEST_P(EntityTest, CubicCurveTest) {
|
||||
// Compare with https://fiddle.skia.org/c/b3625f26122c9de7afe7794fcf25ead3
|
||||
Path path =
|
||||
PathBuilder{}
|
||||
@@ -246,7 +247,7 @@ TEST_F(EntityTest, CubicCurveTest) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, CubicCurveAndOverlapTest) {
|
||||
TEST_P(EntityTest, CubicCurveAndOverlapTest) {
|
||||
// Compare with https://fiddle.skia.org/c/7a05a3e186c65a8dfb732f68020aae06
|
||||
Path path =
|
||||
PathBuilder{}
|
||||
@@ -474,7 +475,7 @@ TEST_F(EntityTest, CubicCurveAndOverlapTest) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, SolidStrokeContentsSetStrokeCapsAndJoins) {
|
||||
TEST_P(EntityTest, SolidStrokeContentsSetStrokeCapsAndJoins) {
|
||||
{
|
||||
SolidStrokeContents stroke;
|
||||
// Defaults.
|
||||
@@ -495,7 +496,7 @@ TEST_F(EntityTest, SolidStrokeContentsSetStrokeCapsAndJoins) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, SolidStrokeContentsSetMiter) {
|
||||
TEST_P(EntityTest, SolidStrokeContentsSetMiter) {
|
||||
SolidStrokeContents contents;
|
||||
ASSERT_FLOAT_EQ(contents.GetStrokeMiter(), 4);
|
||||
|
||||
@@ -506,7 +507,7 @@ TEST_F(EntityTest, SolidStrokeContentsSetMiter) {
|
||||
ASSERT_FLOAT_EQ(contents.GetStrokeMiter(), 8);
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, BlendingModeOptions) {
|
||||
TEST_P(EntityTest, BlendingModeOptions) {
|
||||
std::vector<const char*> blend_mode_names;
|
||||
std::vector<Entity::BlendMode> blend_mode_values;
|
||||
{
|
||||
@@ -637,7 +638,7 @@ TEST_F(EntityTest, BlendingModeOptions) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, BezierCircleScaled) {
|
||||
TEST_P(EntityTest, BezierCircleScaled) {
|
||||
Entity entity;
|
||||
auto path = PathBuilder{}
|
||||
.MoveTo({97.325, 34.818})
|
||||
@@ -662,7 +663,7 @@ TEST_F(EntityTest, BezierCircleScaled) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, Filters) {
|
||||
TEST_P(EntityTest, Filters) {
|
||||
auto bridge = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto boston = CreateTextureForFixture("boston.jpg");
|
||||
auto kalimba = CreateTextureForFixture("kalimba.jpg");
|
||||
@@ -688,7 +689,7 @@ TEST_F(EntityTest, Filters) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, GaussianBlurFilter) {
|
||||
TEST_P(EntityTest, GaussianBlurFilter) {
|
||||
auto bridge = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto boston = CreateTextureForFixture("boston.jpg");
|
||||
auto kalimba = CreateTextureForFixture("kalimba.jpg");
|
||||
@@ -792,14 +793,14 @@ TEST_F(EntityTest, GaussianBlurFilter) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, SetBlendMode) {
|
||||
TEST_P(EntityTest, SetBlendMode) {
|
||||
Entity entity;
|
||||
ASSERT_EQ(entity.GetBlendMode(), Entity::BlendMode::kSourceOver);
|
||||
entity.SetBlendMode(Entity::BlendMode::kClear);
|
||||
ASSERT_EQ(entity.GetBlendMode(), Entity::BlendMode::kClear);
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, ContentsGetBoundsForEmptyPathReturnsNullopt) {
|
||||
TEST_P(EntityTest, ContentsGetBoundsForEmptyPathReturnsNullopt) {
|
||||
Entity entity;
|
||||
entity.SetContents(std::make_shared<SolidColorContents>());
|
||||
entity.SetPath({});
|
||||
@@ -807,7 +808,7 @@ TEST_F(EntityTest, ContentsGetBoundsForEmptyPathReturnsNullopt) {
|
||||
ASSERT_FALSE(entity.GetPathCoverage().has_value());
|
||||
}
|
||||
|
||||
TEST_F(EntityTest, SolidStrokeCoverageIsCorrect) {
|
||||
TEST_P(EntityTest, SolidStrokeCoverageIsCorrect) {
|
||||
{
|
||||
Entity entity;
|
||||
auto contents = std::make_unique<SolidStrokeContents>();
|
||||
|
||||
@@ -9,12 +9,28 @@ impeller_component("playground") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"playground.cc",
|
||||
"playground.h",
|
||||
"playground.mm",
|
||||
"playground_impl.cc",
|
||||
"playground_impl.h",
|
||||
"widgets.cc",
|
||||
"widgets.h",
|
||||
]
|
||||
|
||||
if (impeller_enable_metal) {
|
||||
sources += [
|
||||
"backend/metal/playground_impl_mtl.h",
|
||||
"backend/metal/playground_impl_mtl.mm",
|
||||
]
|
||||
}
|
||||
|
||||
if (impeller_enable_opengles) {
|
||||
sources += [
|
||||
"backend/gles/playground_impl_gles.cc",
|
||||
"backend/gles/playground_impl_gles.h",
|
||||
]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
"../entity:entity_shaders",
|
||||
"../fixtures:shader_fixtures",
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/playground/backend/gles/playground_impl_gles.h"
|
||||
#include "impeller/renderer/backend/gles/context_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
PlaygroundImplGLES::PlaygroundImplGLES() = default;
|
||||
|
||||
PlaygroundImplGLES::~PlaygroundImplGLES() = default;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
std::shared_ptr<Context> PlaygroundImplGLES::CreateContext() const {
|
||||
return std::make_shared<ContextGLES>();
|
||||
}
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool PlaygroundImplGLES::SetupWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool PlaygroundImplGLES::TeardownWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// |PlaygroundImpl|
|
||||
std::unique_ptr<Surface> PlaygroundImplGLES::AcquireSurfaceFrame(
|
||||
std::shared_ptr<Context> context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/playground/playground_impl.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PlaygroundImplGLES final : public PlaygroundImpl {
|
||||
public:
|
||||
PlaygroundImplGLES();
|
||||
|
||||
~PlaygroundImplGLES();
|
||||
|
||||
private:
|
||||
// |PlaygroundImpl|
|
||||
std::shared_ptr<Context> CreateContext() const override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool SetupWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool TeardownWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
std::unique_ptr<Surface> AcquireSurfaceFrame(
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PlaygroundImplGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/playground/playground_impl.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PlaygroundImplMTL final : public PlaygroundImpl {
|
||||
public:
|
||||
PlaygroundImplMTL();
|
||||
|
||||
~PlaygroundImplMTL();
|
||||
|
||||
private:
|
||||
struct Data;
|
||||
|
||||
WindowHandle handle_ = nullptr;
|
||||
// To ensure that ObjC stuff doesn't leak into C++ TUs.
|
||||
std::unique_ptr<Data> data_;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
std::shared_ptr<Context> CreateContext() const override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool SetupWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
bool TeardownWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
// |PlaygroundImpl|
|
||||
std::unique_ptr<Surface> AcquireSurfaceFrame(
|
||||
std::shared_ptr<Context> context) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PlaygroundImplMTL);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/playground/backend/metal/playground_impl_mtl.h"
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#import "third_party/glfw/include/GLFW/glfw3.h"
|
||||
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#import "third_party/glfw/include/GLFW/glfw3native.h"
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "impeller/entity/mtl/entity_shaders.h"
|
||||
#include "impeller/fixtures/mtl/shader_fixtures.h"
|
||||
#include "impeller/playground/imgui/mtl/imgui_shaders.h"
|
||||
#include "impeller/renderer/backend/metal/context_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/formats_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/surface_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/texture_mtl.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
struct PlaygroundImplMTL::Data {
|
||||
CAMetalLayer* metal_layer = nil;
|
||||
};
|
||||
|
||||
static std::vector<std::shared_ptr<fml::Mapping>>
|
||||
ShaderLibraryMappingsForPlayground() {
|
||||
return {
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
|
||||
impeller_entity_shaders_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_shader_fixtures_data,
|
||||
impeller_shader_fixtures_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_imgui_shaders_data,
|
||||
impeller_imgui_shaders_length),
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
PlaygroundImplMTL::PlaygroundImplMTL() : data_(std::make_unique<Data>()) {}
|
||||
|
||||
PlaygroundImplMTL::~PlaygroundImplMTL() = default;
|
||||
|
||||
std::shared_ptr<Context> PlaygroundImplMTL::CreateContext() const {
|
||||
return ContextMTL::Create(ShaderLibraryMappingsForPlayground(),
|
||||
"Playground Library");
|
||||
}
|
||||
|
||||
bool PlaygroundImplMTL::SetupWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) {
|
||||
if (handle_ != nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
handle_ = handle;
|
||||
|
||||
NSWindow* cocoa_window =
|
||||
::glfwGetCocoaWindow(reinterpret_cast<GLFWwindow*>(handle_));
|
||||
data_->metal_layer = [CAMetalLayer layer];
|
||||
data_->metal_layer.device = ContextMTL::Cast(*context).GetMTLDevice();
|
||||
// This pixel format is one of the documented supported formats.
|
||||
data_->metal_layer.pixelFormat = ToMTLPixelFormat(PixelFormat::kDefaultColor);
|
||||
cocoa_window.contentView.layer = data_->metal_layer;
|
||||
cocoa_window.contentView.wantsLayer = YES;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlaygroundImplMTL::TeardownWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) {
|
||||
if (handle_ != handle) {
|
||||
return false;
|
||||
}
|
||||
handle_ = nullptr;
|
||||
data_->metal_layer = nil;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Surface> PlaygroundImplMTL::AcquireSurfaceFrame(
|
||||
std::shared_ptr<Context> context) {
|
||||
if (!data_->metal_layer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto layer_size = data_->metal_layer.bounds.size;
|
||||
const auto layer_scale = data_->metal_layer.contentsScale;
|
||||
data_->metal_layer.drawableSize = CGSizeMake(layer_size.width * layer_scale,
|
||||
layer_size.height * layer_scale);
|
||||
return SurfaceMTL::WrapCurrentMetalLayerDrawable(context, data_->metal_layer);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "imgui_raster.frag.h"
|
||||
#include "imgui_raster.vert.h"
|
||||
#include "impeller/playground/imgui/mtl/imgui_raster.frag.h"
|
||||
#include "impeller/playground/imgui/mtl/imgui_raster.vert.h"
|
||||
#include "third_party/imgui/imgui.h"
|
||||
|
||||
#include "impeller/geometry/matrix.h"
|
||||
|
||||
@@ -4,20 +4,17 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#import "third_party/glfw/include/GLFW/glfw3.h"
|
||||
|
||||
#include "flutter/fml/paths.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/entity/entity_shaders.h"
|
||||
#include "impeller/fixtures/shader_fixtures.h"
|
||||
#include "impeller/image/compressed_image.h"
|
||||
#include "impeller/playground/imgui/imgui_impl_impeller.h"
|
||||
#include "impeller/playground/imgui/imgui_shaders.h"
|
||||
#include "impeller/playground/playground.h"
|
||||
#include "impeller/playground/playground_impl.h"
|
||||
#include "impeller/renderer/allocator.h"
|
||||
#include "impeller/renderer/backend/metal/context_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/formats_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/surface_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/texture_mtl.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
@@ -25,37 +22,35 @@
|
||||
#include "third_party/imgui/backends/imgui_impl_glfw.h"
|
||||
#include "third_party/imgui/imgui.h"
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#import "third_party/glfw/include/GLFW/glfw3.h"
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#import "third_party/glfw/include/GLFW/glfw3native.h"
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
|
||||
namespace impeller {
|
||||
|
||||
static std::vector<std::shared_ptr<fml::Mapping>>
|
||||
ShaderLibraryMappingsForPlayground() {
|
||||
return {
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
|
||||
impeller_entity_shaders_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_shader_fixtures_data,
|
||||
impeller_shader_fixtures_length),
|
||||
std::make_shared<fml::NonOwnedMapping>(impeller_imgui_shaders_data,
|
||||
impeller_imgui_shaders_length),
|
||||
|
||||
};
|
||||
std::string PlaygroundBackendToString(PlaygroundBackend backend) {
|
||||
switch (backend) {
|
||||
case PlaygroundBackend::kMetal:
|
||||
return "Metal";
|
||||
case PlaygroundBackend::kOpenGLES:
|
||||
return "OpenGLES";
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
Playground::Playground()
|
||||
: renderer_(ContextMTL::Create(ShaderLibraryMappingsForPlayground(),
|
||||
"Playground Library")) {}
|
||||
: impl_(PlaygroundImpl::Create(GetParam())),
|
||||
renderer_(impl_->CreateContext()),
|
||||
is_valid_(Playground::is_enabled() && renderer_.IsValid()) {}
|
||||
|
||||
Playground::~Playground() = default;
|
||||
|
||||
bool Playground::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
PlaygroundBackend Playground::GetBackend() const {
|
||||
return GetParam();
|
||||
}
|
||||
|
||||
std::shared_ptr<Context> Playground::GetContext() const {
|
||||
return renderer_.IsValid() ? renderer_.GetContext() : nullptr;
|
||||
return IsValid() ? renderer_.GetContext() : nullptr;
|
||||
}
|
||||
|
||||
static void PlaygroundKeyCallback(GLFWwindow* window,
|
||||
@@ -92,6 +87,10 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!render_callback) {
|
||||
return true;
|
||||
}
|
||||
@@ -169,13 +168,9 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
fml::ScopedCleanupClosure shutdown_imgui_impeller(
|
||||
[]() { ImGui_ImplImpeller_Shutdown(); });
|
||||
|
||||
NSWindow* cocoa_window = ::glfwGetCocoaWindow(window);
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
layer.device = ContextMTL::Cast(*renderer_.GetContext()).GetMTLDevice();
|
||||
// This pixel format is one of the documented supported formats.
|
||||
layer.pixelFormat = ToMTLPixelFormat(PixelFormat::kDefaultColor);
|
||||
cocoa_window.contentView.layer = layer;
|
||||
cocoa_window.contentView.wantsLayer = YES;
|
||||
if (!impl_->SetupWindow(window, renderer_.GetContext())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
::glfwWaitEventsTimeout(1.0 / 30.0);
|
||||
@@ -186,11 +181,6 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
const auto layer_size = layer.bounds.size;
|
||||
const auto layer_scale = layer.contentsScale;
|
||||
layer.drawableSize = CGSizeMake(layer_size.width * layer_scale,
|
||||
layer_size.height * layer_scale);
|
||||
|
||||
Renderer::RenderCallback wrapped_callback = [render_callback](auto& pass) {
|
||||
pass.SetLabel("Playground Main Render Pass");
|
||||
|
||||
@@ -201,19 +191,26 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
return result;
|
||||
};
|
||||
|
||||
if (!renderer_.Render(SurfaceMTL::WrapCurrentMetalLayerDrawable(
|
||||
renderer_.GetContext(), layer),
|
||||
if (!renderer_.Render(impl_->AcquireSurfaceFrame(renderer_.GetContext()),
|
||||
wrapped_callback)) {
|
||||
VALIDATION_LOG << "Could not render into the surface.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!impl_->TeardownWindow(window, renderer_.GetContext())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> Playground::CreateTextureForFixture(
|
||||
const char* fixture_name) const {
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto compressed_image = CompressedImage::Create(
|
||||
flutter::testing::OpenFixtureAsMapping(fixture_name));
|
||||
if (!compressed_image) {
|
||||
@@ -13,7 +13,16 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class Playground : public ::testing::Test {
|
||||
class PlaygroundImpl;
|
||||
|
||||
enum class PlaygroundBackend {
|
||||
kMetal,
|
||||
kOpenGLES,
|
||||
};
|
||||
|
||||
std::string PlaygroundBackendToString(PlaygroundBackend backend);
|
||||
|
||||
class Playground : public ::testing::TestWithParam<PlaygroundBackend> {
|
||||
public:
|
||||
Playground();
|
||||
|
||||
@@ -21,6 +30,10 @@ class Playground : public ::testing::Test {
|
||||
|
||||
static constexpr bool is_enabled() { return is_enabled_; }
|
||||
|
||||
PlaygroundBackend GetBackend() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
Point GetCursorPosition() const;
|
||||
|
||||
ISize GetWindowSize() const;
|
||||
@@ -39,9 +52,11 @@ class Playground : public ::testing::Test {
|
||||
static const bool is_enabled_ = false;
|
||||
#endif // IMPELLER_ENABLE_PLAYGROUND
|
||||
|
||||
std::unique_ptr<PlaygroundImpl> impl_;
|
||||
Renderer renderer_;
|
||||
Point cursor_position_;
|
||||
ISize window_size_ = ISize{1024, 768};
|
||||
bool is_valid_ = false;
|
||||
|
||||
void SetCursorPosition(Point pos);
|
||||
|
||||
@@ -50,4 +65,11 @@ class Playground : public ::testing::Test {
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Playground);
|
||||
};
|
||||
|
||||
#define INSTANTIATE_PLAYGROUND_SUITE(playground) \
|
||||
INSTANTIATE_TEST_SUITE_P( \
|
||||
Play, playground, ::testing::Values(PlaygroundBackend::kMetal), \
|
||||
[](const ::testing::TestParamInfo<Playground::ParamType>& info) { \
|
||||
return PlaygroundBackendToString(info.param); \
|
||||
});
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
27
engine/src/flutter/impeller/playground/playground_impl.cc
Normal file
27
engine/src/flutter/impeller/playground/playground_impl.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/playground/playground_impl.h"
|
||||
|
||||
#include "impeller/playground/backend/gles/playground_impl_gles.h"
|
||||
#include "impeller/playground/backend/metal/playground_impl_mtl.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
|
||||
PlaygroundBackend backend) {
|
||||
switch (backend) {
|
||||
case PlaygroundBackend::kMetal:
|
||||
return std::make_unique<PlaygroundImplMTL>();
|
||||
case PlaygroundBackend::kOpenGLES:
|
||||
return std::make_unique<PlaygroundImplGLES>();
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
PlaygroundImpl::PlaygroundImpl() = default;
|
||||
|
||||
PlaygroundImpl::~PlaygroundImpl() = default;
|
||||
|
||||
} // namespace impeller
|
||||
42
engine/src/flutter/impeller/playground/playground_impl.h
Normal file
42
engine/src/flutter/impeller/playground/playground_impl.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/playground/playground.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/surface.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PlaygroundImpl {
|
||||
public:
|
||||
static std::unique_ptr<PlaygroundImpl> Create(PlaygroundBackend backend);
|
||||
|
||||
virtual ~PlaygroundImpl();
|
||||
|
||||
virtual std::shared_ptr<Context> CreateContext() const = 0;
|
||||
|
||||
using WindowHandle = void*;
|
||||
|
||||
virtual bool SetupWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) = 0;
|
||||
|
||||
virtual bool TeardownWindow(WindowHandle handle,
|
||||
std::shared_ptr<Context> context) = 0;
|
||||
|
||||
virtual std::unique_ptr<Surface> AcquireSurfaceFrame(
|
||||
std::shared_ptr<Context> context) = 0;
|
||||
|
||||
protected:
|
||||
PlaygroundImpl();
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PlaygroundImpl);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -5,101 +5,142 @@
|
||||
import("//flutter/impeller/tools/impeller.gni")
|
||||
|
||||
impeller_component("renderer") {
|
||||
metal_backend_sources = [
|
||||
"backend/metal/allocator_mtl.h",
|
||||
"backend/metal/allocator_mtl.mm",
|
||||
"backend/metal/command_buffer_mtl.h",
|
||||
"backend/metal/command_buffer_mtl.mm",
|
||||
"backend/metal/context_mtl.h",
|
||||
"backend/metal/context_mtl.mm",
|
||||
"backend/metal/device_buffer_mtl.h",
|
||||
"backend/metal/device_buffer_mtl.mm",
|
||||
"backend/metal/formats_mtl.h",
|
||||
"backend/metal/formats_mtl.mm",
|
||||
"backend/metal/pipeline_library_mtl.h",
|
||||
"backend/metal/pipeline_library_mtl.mm",
|
||||
"backend/metal/pipeline_mtl.h",
|
||||
"backend/metal/pipeline_mtl.mm",
|
||||
"backend/metal/render_pass_mtl.h",
|
||||
"backend/metal/render_pass_mtl.mm",
|
||||
"backend/metal/sampler_library_mtl.h",
|
||||
"backend/metal/sampler_library_mtl.mm",
|
||||
"backend/metal/sampler_mtl.h",
|
||||
"backend/metal/sampler_mtl.mm",
|
||||
"backend/metal/shader_function_mtl.h",
|
||||
"backend/metal/shader_function_mtl.mm",
|
||||
"backend/metal/shader_library_mtl.h",
|
||||
"backend/metal/shader_library_mtl.mm",
|
||||
"backend/metal/surface_mtl.h",
|
||||
"backend/metal/surface_mtl.mm",
|
||||
"backend/metal/texture_mtl.h",
|
||||
"backend/metal/texture_mtl.mm",
|
||||
"backend/metal/vertex_descriptor_mtl.h",
|
||||
"backend/metal/vertex_descriptor_mtl.mm",
|
||||
sources = [
|
||||
"allocator.cc",
|
||||
"allocator.h",
|
||||
"buffer.cc",
|
||||
"buffer.h",
|
||||
"buffer_view.cc",
|
||||
"buffer_view.h",
|
||||
"command.cc",
|
||||
"command.h",
|
||||
"command_buffer.cc",
|
||||
"command_buffer.h",
|
||||
"context.cc",
|
||||
"context.h",
|
||||
"device_buffer.cc",
|
||||
"device_buffer.h",
|
||||
"formats.cc",
|
||||
"formats.h",
|
||||
"host_buffer.cc",
|
||||
"host_buffer.h",
|
||||
"pipeline.cc",
|
||||
"pipeline.h",
|
||||
"pipeline_builder.cc",
|
||||
"pipeline_builder.h",
|
||||
"pipeline_descriptor.cc",
|
||||
"pipeline_descriptor.h",
|
||||
"pipeline_library.cc",
|
||||
"pipeline_library.h",
|
||||
"platform.cc",
|
||||
"platform.h",
|
||||
"range.cc",
|
||||
"range.h",
|
||||
"render_pass.cc",
|
||||
"render_pass.h",
|
||||
"render_target.cc",
|
||||
"render_target.h",
|
||||
"renderer.cc",
|
||||
"renderer.h",
|
||||
"sampler.cc",
|
||||
"sampler.h",
|
||||
"sampler_descriptor.cc",
|
||||
"sampler_descriptor.h",
|
||||
"sampler_library.cc",
|
||||
"sampler_library.h",
|
||||
"shader_function.cc",
|
||||
"shader_function.h",
|
||||
"shader_library.cc",
|
||||
"shader_library.h",
|
||||
"shader_types.cc",
|
||||
"shader_types.h",
|
||||
"surface.cc",
|
||||
"surface.h",
|
||||
"texture.cc",
|
||||
"texture.h",
|
||||
"texture_descriptor.cc",
|
||||
"texture_descriptor.h",
|
||||
"vertex_buffer.cc",
|
||||
"vertex_buffer.h",
|
||||
"vertex_buffer_builder.cc",
|
||||
"vertex_buffer_builder.h",
|
||||
"vertex_descriptor.cc",
|
||||
"vertex_descriptor.h",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"allocator.h",
|
||||
"allocator.cc",
|
||||
"buffer.h",
|
||||
"buffer.cc",
|
||||
"buffer_view.h",
|
||||
"buffer_view.cc",
|
||||
"command.h",
|
||||
"command.cc",
|
||||
"command_buffer.h",
|
||||
"command_buffer.cc",
|
||||
"context.h",
|
||||
"context.cc",
|
||||
"device_buffer.h",
|
||||
"device_buffer.cc",
|
||||
"formats.cc",
|
||||
"formats.h",
|
||||
"host_buffer.h",
|
||||
"host_buffer.cc",
|
||||
"pipeline.h",
|
||||
"pipeline.cc",
|
||||
"pipeline_builder.h",
|
||||
"pipeline_builder.cc",
|
||||
"pipeline_descriptor.h",
|
||||
"pipeline_descriptor.cc",
|
||||
"pipeline_library.h",
|
||||
"pipeline_library.cc",
|
||||
"platform.h",
|
||||
"platform.cc",
|
||||
"range.cc",
|
||||
"range.h",
|
||||
"render_pass.h",
|
||||
"render_pass.cc",
|
||||
"render_target.h",
|
||||
"render_target.cc",
|
||||
"renderer.h",
|
||||
"renderer.cc",
|
||||
"sampler.h",
|
||||
"sampler.cc",
|
||||
"sampler_descriptor.h",
|
||||
"sampler_descriptor.cc",
|
||||
"sampler_library.h",
|
||||
"sampler_library.cc",
|
||||
"shader_function.h",
|
||||
"shader_function.cc",
|
||||
"shader_library.h",
|
||||
"shader_library.cc",
|
||||
"shader_types.cc",
|
||||
"shader_types.h",
|
||||
"surface.h",
|
||||
"surface.cc",
|
||||
"texture.h",
|
||||
"texture.cc",
|
||||
"texture_descriptor.h",
|
||||
"texture_descriptor.cc",
|
||||
"vertex_buffer.h",
|
||||
"vertex_buffer.cc",
|
||||
"vertex_buffer_builder.h",
|
||||
"vertex_buffer_builder.cc",
|
||||
"vertex_descriptor.h",
|
||||
"vertex_descriptor.cc",
|
||||
] + metal_backend_sources
|
||||
if (impeller_enable_metal) {
|
||||
sources += [
|
||||
"backend/metal/allocator_mtl.h",
|
||||
"backend/metal/allocator_mtl.mm",
|
||||
"backend/metal/command_buffer_mtl.h",
|
||||
"backend/metal/command_buffer_mtl.mm",
|
||||
"backend/metal/context_mtl.h",
|
||||
"backend/metal/context_mtl.mm",
|
||||
"backend/metal/device_buffer_mtl.h",
|
||||
"backend/metal/device_buffer_mtl.mm",
|
||||
"backend/metal/formats_mtl.h",
|
||||
"backend/metal/formats_mtl.mm",
|
||||
"backend/metal/pipeline_library_mtl.h",
|
||||
"backend/metal/pipeline_library_mtl.mm",
|
||||
"backend/metal/pipeline_mtl.h",
|
||||
"backend/metal/pipeline_mtl.mm",
|
||||
"backend/metal/render_pass_mtl.h",
|
||||
"backend/metal/render_pass_mtl.mm",
|
||||
"backend/metal/sampler_library_mtl.h",
|
||||
"backend/metal/sampler_library_mtl.mm",
|
||||
"backend/metal/sampler_mtl.h",
|
||||
"backend/metal/sampler_mtl.mm",
|
||||
"backend/metal/shader_function_mtl.h",
|
||||
"backend/metal/shader_function_mtl.mm",
|
||||
"backend/metal/shader_library_mtl.h",
|
||||
"backend/metal/shader_library_mtl.mm",
|
||||
"backend/metal/surface_mtl.h",
|
||||
"backend/metal/surface_mtl.mm",
|
||||
"backend/metal/texture_mtl.h",
|
||||
"backend/metal/texture_mtl.mm",
|
||||
"backend/metal/vertex_descriptor_mtl.h",
|
||||
"backend/metal/vertex_descriptor_mtl.mm",
|
||||
]
|
||||
}
|
||||
|
||||
if (impeller_enable_opengles) {
|
||||
sources += [
|
||||
"backend/gles/allocator_gles.cc",
|
||||
"backend/gles/allocator_gles.h",
|
||||
"backend/gles/command_buffer_gles.cc",
|
||||
"backend/gles/command_buffer_gles.h",
|
||||
"backend/gles/context_gles.cc",
|
||||
"backend/gles/context_gles.h",
|
||||
"backend/gles/device_buffer_gles.cc",
|
||||
"backend/gles/device_buffer_gles.h",
|
||||
"backend/gles/formats_gles.cc",
|
||||
"backend/gles/formats_gles.h",
|
||||
"backend/gles/pipeline_gles.cc",
|
||||
"backend/gles/pipeline_gles.h",
|
||||
"backend/gles/pipeline_library_gles.cc",
|
||||
"backend/gles/pipeline_library_gles.h",
|
||||
"backend/gles/proc_table_gles.cc",
|
||||
"backend/gles/proc_table_gles.h",
|
||||
"backend/gles/reactor_gles.cc",
|
||||
"backend/gles/reactor_gles.h",
|
||||
"backend/gles/render_pass_gles.cc",
|
||||
"backend/gles/render_pass_gles.h",
|
||||
"backend/gles/sampler_gles.cc",
|
||||
"backend/gles/sampler_gles.h",
|
||||
"backend/gles/sampler_library_gles.cc",
|
||||
"backend/gles/sampler_library_gles.h",
|
||||
"backend/gles/shader_function_gles.cc",
|
||||
"backend/gles/shader_function_gles.h",
|
||||
"backend/gles/shader_library_gles.cc",
|
||||
"backend/gles/shader_library_gles.h",
|
||||
"backend/gles/surface_gles.cc",
|
||||
"backend/gles/surface_gles.h",
|
||||
"backend/gles/texture_gles.cc",
|
||||
"backend/gles/texture_gles.h",
|
||||
"backend/gles/vertex_descriptor_gles.cc",
|
||||
"backend/gles/vertex_descriptor_gles.h",
|
||||
]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
"../base",
|
||||
@@ -109,8 +150,11 @@ impeller_component("renderer") {
|
||||
]
|
||||
|
||||
deps = [ "//flutter/fml" ]
|
||||
frameworks = []
|
||||
|
||||
frameworks = [ "Metal.framework" ]
|
||||
if (impeller_enable_metal) {
|
||||
frameworks = [ "Metal.framework" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("renderer_unittests") {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/allocator_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/allocator.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class AllocatorGLES final : public Allocator {
|
||||
public:
|
||||
// |Allocator|
|
||||
~AllocatorGLES() override;
|
||||
|
||||
private:
|
||||
friend class ContextGLES;
|
||||
|
||||
AllocatorGLES();
|
||||
|
||||
// |Allocator|
|
||||
bool IsValid() const;
|
||||
|
||||
// |Allocator|
|
||||
std::shared_ptr<DeviceBuffer> CreateBuffer(StorageMode mode,
|
||||
size_t length) override;
|
||||
|
||||
// |Allocator|
|
||||
std::shared_ptr<Texture> CreateTexture(
|
||||
StorageMode mode,
|
||||
const TextureDescriptor& desc) override;
|
||||
|
||||
// |Allocator|
|
||||
std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(const uint8_t* buffer,
|
||||
size_t length) override;
|
||||
|
||||
// |Allocator|
|
||||
std::shared_ptr<DeviceBuffer> CreateBufferWithCopy(
|
||||
const fml::Mapping& mapping) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(AllocatorGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/command_buffer_gles.h"
|
||||
|
||||
#include "impeller/base/config.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
CommandBufferGLES::CommandBufferGLES() = default;
|
||||
|
||||
CommandBufferGLES::~CommandBufferGLES() = default;
|
||||
|
||||
// |CommandBuffer|
|
||||
void CommandBufferGLES::SetLabel(const std::string& label) const {}
|
||||
|
||||
// |CommandBuffer|
|
||||
bool CommandBufferGLES::IsValid() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
// |CommandBuffer|
|
||||
bool CommandBufferGLES::SubmitCommands(CompletionCallback callback) {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
// |CommandBuffer|
|
||||
void CommandBufferGLES::ReserveSpotInQueue() {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<RenderPass> CommandBufferGLES::CreateRenderPass(
|
||||
RenderTarget target) const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/command_buffer.h"
|
||||
#include "impeller/renderer/render_target.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class CommandBufferGLES final : public CommandBuffer {
|
||||
public:
|
||||
// |CommandBuffer|
|
||||
~CommandBufferGLES() override;
|
||||
|
||||
private:
|
||||
friend class ContextGLES;
|
||||
|
||||
CommandBufferGLES();
|
||||
|
||||
// |CommandBuffer|
|
||||
void SetLabel(const std::string& label) const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
bool IsValid() const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
bool SubmitCommands(CompletionCallback callback) override;
|
||||
|
||||
// |CommandBuffer|
|
||||
void ReserveSpotInQueue() override;
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<RenderPass> CreateRenderPass(
|
||||
RenderTarget target) const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBufferGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/context_gles.h"
|
||||
|
||||
#include "impeller/base/config.h"
|
||||
#include "impeller/base/validation.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ContextGLES::ContextGLES() {
|
||||
auto reactor = std::make_shared<ReactorGLES>();
|
||||
if (!reactor->IsValid()) {
|
||||
VALIDATION_LOG << "Could not create valid reactor.";
|
||||
return;
|
||||
}
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
ContextGLES::~ContextGLES() = default;
|
||||
|
||||
bool ContextGLES::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
std::shared_ptr<Allocator> ContextGLES::GetPermanentsAllocator() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return permanents_allocator_;
|
||||
}
|
||||
|
||||
std::shared_ptr<Allocator> ContextGLES::GetTransientsAllocator() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return transients_allocator_;
|
||||
}
|
||||
|
||||
std::shared_ptr<ShaderLibrary> ContextGLES::GetShaderLibrary() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return shader_library_;
|
||||
}
|
||||
|
||||
std::shared_ptr<SamplerLibrary> ContextGLES::GetSamplerLibrary() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return sampler_library_;
|
||||
}
|
||||
|
||||
std::shared_ptr<PipelineLibrary> ContextGLES::GetPipelineLibrary() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return pipeline_library_;
|
||||
}
|
||||
|
||||
std::shared_ptr<CommandBuffer> ContextGLES::CreateRenderCommandBuffer() const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return std::shared_ptr<CommandBufferGLES>(new CommandBufferGLES());
|
||||
}
|
||||
|
||||
std::shared_ptr<CommandBuffer> ContextGLES::CreateTransferCommandBuffer()
|
||||
const {
|
||||
IMPELLER_UNIMPLEMENTED;
|
||||
return std::shared_ptr<CommandBufferGLES>(new CommandBufferGLES());
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/base/backend_cast.h"
|
||||
#include "impeller/renderer/backend/gles/allocator_gles.h"
|
||||
#include "impeller/renderer/backend/gles/command_buffer_gles.h"
|
||||
#include "impeller/renderer/backend/gles/pipeline_library_gles.h"
|
||||
#include "impeller/renderer/backend/gles/reactor_gles.h"
|
||||
#include "impeller/renderer/backend/gles/shader_library_gles.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ContextGLES final : public Context,
|
||||
public BackendCast<ContextGLES, Context> {
|
||||
public:
|
||||
ContextGLES();
|
||||
|
||||
// |Context|
|
||||
~ContextGLES() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ReactorGLES> reactor_;
|
||||
std::shared_ptr<ShaderLibraryGLES> shader_library_;
|
||||
std::shared_ptr<PipelineLibraryGLES> pipeline_library_;
|
||||
std::shared_ptr<SamplerLibrary> sampler_library_;
|
||||
std::shared_ptr<AllocatorGLES> permanents_allocator_;
|
||||
std::shared_ptr<AllocatorGLES> transients_allocator_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
// |Context|
|
||||
bool IsValid() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<Allocator> GetPermanentsAllocator() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<Allocator> GetTransientsAllocator() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<ShaderLibrary> GetShaderLibrary() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<SamplerLibrary> GetSamplerLibrary() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<PipelineLibrary> GetPipelineLibrary() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<CommandBuffer> CreateRenderCommandBuffer() const override;
|
||||
|
||||
// |Context|
|
||||
std::shared_ptr<CommandBuffer> CreateTransferCommandBuffer() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ContextGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/device_buffer_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/formats_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/pipeline_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/pipeline_library_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/pipeline_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ContextGLES;
|
||||
|
||||
class PipelineLibraryGLES final : public PipelineLibrary {
|
||||
public:
|
||||
// |PipelineLibrary|
|
||||
~PipelineLibraryGLES() override;
|
||||
|
||||
private:
|
||||
friend ContextGLES;
|
||||
|
||||
PipelineLibraryGLES();
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineLibraryGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/proc_table_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ProcTableGLES::ProcTableGLES() : is_valid_(true) {}
|
||||
|
||||
ProcTableGLES::~ProcTableGLES() = default;
|
||||
|
||||
bool ProcTableGLES::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ProcTableGLES {
|
||||
public:
|
||||
ProcTableGLES();
|
||||
|
||||
~ProcTableGLES();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
bool is_valid_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ProcTableGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/reactor_gles.h"
|
||||
|
||||
#include "impeller/base/validation.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ReactorGLES::ReactorGLES() {
|
||||
proc_table_ = std::make_unique<ProcTableGLES>();
|
||||
|
||||
if (!proc_table_->IsValid()) {
|
||||
VALIDATION_LOG << "Could not create valid proc table.";
|
||||
return;
|
||||
}
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
ReactorGLES::~ReactorGLES() = default;
|
||||
|
||||
bool ReactorGLES::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/backend/gles/proc_table_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ReactorGLES {
|
||||
public:
|
||||
ReactorGLES();
|
||||
|
||||
~ReactorGLES();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ProcTableGLES> proc_table_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ReactorGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/render_pass_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/sampler_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/sampler_library_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/shader_function_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/shader_library_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/shader_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ShaderLibraryGLES final : public ShaderLibrary {
|
||||
public:
|
||||
ShaderLibraryGLES();
|
||||
|
||||
// |ShaderLibrary|
|
||||
~ShaderLibraryGLES() override;
|
||||
|
||||
// |ShaderLibrary|
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
friend class ContextGLES;
|
||||
|
||||
// |ShaderLibrary|
|
||||
std::shared_ptr<const ShaderFunction> GetFunction(
|
||||
const std::string_view& name,
|
||||
ShaderStage stage) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ShaderLibraryGLES);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/surface_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/texture_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/gles/vertex_descriptor_gles.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -19,7 +19,7 @@ Renderer::Renderer(std::shared_ptr<Context> context,
|
||||
: frames_in_flight_sema_(std::make_shared<fml::Semaphore>(
|
||||
std::max<std::size_t>(1u, max_frames_in_flight))),
|
||||
context_(std::move(context)) {
|
||||
if (!context_->IsValid()) {
|
||||
if (!context_ || !context_->IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
#include "flutter/fml/time/time_point.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/fixtures/box_fade.frag.h"
|
||||
#include "impeller/fixtures/box_fade.vert.h"
|
||||
#include "impeller/fixtures/instanced_draw.frag.h"
|
||||
#include "impeller/fixtures/instanced_draw.vert.h"
|
||||
#include "impeller/fixtures/test_texture.frag.h"
|
||||
#include "impeller/fixtures/test_texture.vert.h"
|
||||
#include "impeller/fixtures/mtl/box_fade.frag.h"
|
||||
#include "impeller/fixtures/mtl/box_fade.vert.h"
|
||||
#include "impeller/fixtures/mtl/instanced_draw.frag.h"
|
||||
#include "impeller/fixtures/mtl/instanced_draw.vert.h"
|
||||
#include "impeller/fixtures/mtl/test_texture.frag.h"
|
||||
#include "impeller/fixtures/mtl/test_texture.vert.h"
|
||||
#include "impeller/geometry/path_builder.h"
|
||||
#include "impeller/image/compressed_image.h"
|
||||
#include "impeller/image/decompressed_image.h"
|
||||
@@ -30,8 +30,9 @@ namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using RendererTest = Playground;
|
||||
INSTANTIATE_PLAYGROUND_SUITE(RendererTest);
|
||||
|
||||
TEST_F(RendererTest, CanCreateBoxPrimitive) {
|
||||
TEST_P(RendererTest, CanCreateBoxPrimitive) {
|
||||
using VS = BoxFadeVertexShader;
|
||||
using FS = BoxFadeFragmentShader;
|
||||
auto context = GetContext();
|
||||
@@ -96,7 +97,7 @@ TEST_F(RendererTest, CanCreateBoxPrimitive) {
|
||||
OpenPlaygroundHere(callback);
|
||||
}
|
||||
|
||||
TEST_F(RendererTest, CanRenderMultiplePrimitives) {
|
||||
TEST_P(RendererTest, CanRenderMultiplePrimitives) {
|
||||
using VS = BoxFadeVertexShader;
|
||||
using FS = BoxFadeFragmentShader;
|
||||
auto context = GetContext();
|
||||
@@ -168,7 +169,7 @@ TEST_F(RendererTest, CanRenderMultiplePrimitives) {
|
||||
OpenPlaygroundHere(callback);
|
||||
}
|
||||
|
||||
TEST_F(RendererTest, CanRenderToTexture) {
|
||||
TEST_P(RendererTest, CanRenderToTexture) {
|
||||
using VS = BoxFadeVertexShader;
|
||||
using FS = BoxFadeFragmentShader;
|
||||
auto context = GetContext();
|
||||
@@ -272,7 +273,7 @@ TEST_F(RendererTest, CanRenderToTexture) {
|
||||
ASSERT_TRUE(r2t_pass->EncodeCommands(*context->GetTransientsAllocator()));
|
||||
}
|
||||
|
||||
TEST_F(RendererTest, CanRenderInstanced) {
|
||||
TEST_P(RendererTest, CanRenderInstanced) {
|
||||
using VS = InstancedDrawVertexShader;
|
||||
using FS = InstancedDrawFragmentShader;
|
||||
|
||||
@@ -290,6 +291,7 @@ TEST_F(RendererTest, CanRenderInstanced) {
|
||||
builder.AppendVertex(data);
|
||||
}));
|
||||
|
||||
ASSERT_NE(GetContext(), nullptr);
|
||||
auto pipeline =
|
||||
GetContext()
|
||||
->GetPipelineLibrary()
|
||||
|
||||
@@ -12,11 +12,21 @@ declare_args() {
|
||||
# Whether Impeller is supported on the platform.
|
||||
impeller_supports_platform = true
|
||||
|
||||
# Whether Impeller supports rendering on the platform.
|
||||
impeller_supports_rendering = is_mac || is_ios
|
||||
# Whether the Metal backend is enabled.
|
||||
impeller_enable_metal = is_mac || is_ios
|
||||
|
||||
# Whether the OpenGLES backend is enabled.
|
||||
impeller_enable_opengles = is_mac
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# Whether Impeller shaders are supported on the platform.
|
||||
impeller_shaders_supports_platform = is_mac || is_ios
|
||||
impeller_shaders_supports_platform =
|
||||
impeller_enable_metal || impeller_enable_opengles
|
||||
|
||||
# Whether Impeller supports rendering on the platform.
|
||||
impeller_supports_rendering =
|
||||
impeller_enable_metal || impeller_enable_opengles
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -106,7 +116,7 @@ template("metal_library") {
|
||||
|
||||
script = "//flutter/impeller/tools/build_metal_library.py"
|
||||
|
||||
depfile = "$target_gen_dir/shader_deps/$metal_library_name.depfile"
|
||||
depfile = "$target_gen_dir/mtl/$metal_library_name.depfile"
|
||||
|
||||
args = [
|
||||
"--output",
|
||||
@@ -151,17 +161,19 @@ template("impeller_shaders_real") {
|
||||
assert(defined(invoker.name), "Name of the shader library must be specified.")
|
||||
|
||||
base_target_name = target_name
|
||||
impellerc_target_name = "impellerc_$target_name"
|
||||
impellerc_target_name = "impellerc_mtl_$target_name"
|
||||
compiled_action_foreach(impellerc_target_name) {
|
||||
tool = "//flutter/impeller/compiler:impellerc"
|
||||
|
||||
sources = invoker.shaders
|
||||
|
||||
metal_intermediate = "$target_gen_dir/{{source_file_part}}.metal"
|
||||
spirv_intermediate = "$target_gen_dir/{{source_file_part}}.spirv"
|
||||
reflection_json_intermediate = "$target_gen_dir/{{source_file_part}}.json"
|
||||
reflection_header_intermediate = "$target_gen_dir/{{source_file_part}}.h"
|
||||
reflection_cc_intermediate = "$target_gen_dir/{{source_file_part}}.mm"
|
||||
metal_intermediate = "$target_gen_dir/mtl/{{source_file_part}}.metal"
|
||||
spirv_intermediate = "$target_gen_dir/mtl/{{source_file_part}}.spirv"
|
||||
reflection_json_intermediate =
|
||||
"$target_gen_dir/mtl/{{source_file_part}}.json"
|
||||
reflection_header_intermediate =
|
||||
"$target_gen_dir/mtl/{{source_file_part}}.h"
|
||||
reflection_cc_intermediate = "$target_gen_dir/mtl/{{source_file_part}}.cc"
|
||||
|
||||
outputs = [
|
||||
metal_intermediate,
|
||||
@@ -169,7 +181,7 @@ template("impeller_shaders_real") {
|
||||
reflection_cc_intermediate,
|
||||
]
|
||||
|
||||
depfile_path = "$target_gen_dir/{{source_file_part}}.d"
|
||||
depfile_path = "$target_gen_dir/mtl/{{source_file_part}}.d"
|
||||
|
||||
metal_intermediate_path = rebase_path(metal_intermediate, root_build_dir)
|
||||
spirv_intermediate_path = rebase_path(spirv_intermediate, root_build_dir)
|
||||
@@ -223,6 +235,14 @@ template("impeller_shaders_real") {
|
||||
target_gen_dir,
|
||||
impeller_root_gen_dir,
|
||||
]
|
||||
|
||||
if (impeller_enable_metal) {
|
||||
include_dirs += [ "$impeller_root_gen_dir/mtl" ]
|
||||
}
|
||||
|
||||
if (impeller_enable_opengles) {
|
||||
include_dirs += [ "$impeller_root_gen_dir/gles" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set(shader_glue_target_name) {
|
||||
@@ -248,8 +268,8 @@ template("impeller_shaders_real") {
|
||||
metal_library_files = get_target_outputs(":$metal_library_target_name")
|
||||
metal_library_file = metal_library_files[0]
|
||||
inputs = [ metal_library_file ]
|
||||
output_header = "$target_gen_dir/$base_target_name.h"
|
||||
output_source = "$target_gen_dir/$base_target_name.c"
|
||||
output_header = "$target_gen_dir/mtl/$base_target_name.h"
|
||||
output_source = "$target_gen_dir/mtl/$base_target_name.c"
|
||||
outputs = [
|
||||
output_header,
|
||||
output_source,
|
||||
|
||||
@@ -12,8 +12,9 @@ namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using TypographerTest = Playground;
|
||||
INSTANTIATE_PLAYGROUND_SUITE(TypographerTest);
|
||||
|
||||
TEST_F(TypographerTest, CanConvertTextBlob) {
|
||||
TEST_P(TypographerTest, CanConvertTextBlob) {
|
||||
SkFont font;
|
||||
auto blob = SkTextBlob::MakeFromString(
|
||||
"the quick brown fox jumped over the lazy dog.", font);
|
||||
@@ -26,12 +27,12 @@ TEST_F(TypographerTest, CanConvertTextBlob) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TypographerTest, CanCreateRenderContext) {
|
||||
TEST_P(TypographerTest, CanCreateRenderContext) {
|
||||
auto context = TextRenderContext::Create(GetContext());
|
||||
ASSERT_TRUE(context && context->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(TypographerTest, CanCreateGlyphAtlas) {
|
||||
TEST_P(TypographerTest, CanCreateGlyphAtlas) {
|
||||
auto context = TextRenderContext::Create(GetContext());
|
||||
ASSERT_TRUE(context && context->IsValid());
|
||||
SkFont sk_font;
|
||||
|
||||
Reference in New Issue
Block a user