Transform clips by the entity's transform (flutter/engine#87)

This commit is contained in:
Brandon DeRosier
2022-03-17 10:23:03 -07:00
committed by Dan Field
parent 6454899a89
commit a1ff981559
2 changed files with 23 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <array>
#include "flutter/testing/testing.h"
#include "impeller/aiks/aiks_playground.h"
#include "impeller/aiks/canvas.h"
@@ -122,6 +123,26 @@ TEST_F(AiksTest, CanRenderNestedClips) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
TEST_F(AiksTest, ClipsUseCurrentTransform) {
std::array<Color, 5> colors = {Color::White(), Color::Black(),
Color::SkyBlue(), Color::Red(),
Color::Yellow()};
Canvas canvas;
Paint paint;
canvas.Translate(Vector3(300, 300));
for (int i = 0; i < 15; i++) {
canvas.Translate(-Vector3(300, 300));
canvas.Scale(Vector3(0.8, 0.8));
canvas.Translate(Vector3(300, 300));
paint.color = colors[i % colors.size()];
canvas.ClipPath(PathBuilder{}.AddCircle({0, 0}, 300).TakePath());
canvas.DrawRect(Rect(-300, -300, 600, 600), paint);
}
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
TEST_F(AiksTest, CanSaveLayerStandalone) {
Canvas canvas;

View File

@@ -35,7 +35,8 @@ bool ClipContents::Render(const ContentContext& renderer,
VS::FrameInfo info;
// The color really doesn't matter.
info.color = Color::SkyBlue();
info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize());
info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(info));