Skip to content

Commit 0570581

Browse files
chinmaygardednfield
authored andcommitted
Add support for typed commands.
1 parent 9ce9a81 commit 0570581

15 files changed

+167
-10
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ TEST_F(AiksTest, CanRenderClips) {
104104
canvas.ClipPath(
105105
PathBuilder{}.AddRect(Rect::MakeXYWH(0, 0, 100, 100)).CreatePath());
106106
canvas.DrawPath(PathBuilder{}.AddCircle({100, 100}, 50).CreatePath(), paint);
107-
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
107+
// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
108108
}
109109

110110
} // namespace testing

impeller/aiks/canvas.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ void Canvas::SaveLayer(const Paint& paint, std::optional<Rect> bounds) {
7777
}
7878

7979
void Canvas::ClipPath(Path path) {
80-
passes_.push_back({});
80+
Entity entity;
81+
entity.SetTransformation(GetCurrentTransformation());
82+
entity.SetPath(std::move(path));
83+
entity.SetContents(std::make_shared<ClipContents>());
84+
GetCurrentPass().PushEntity(std::move(entity));
8185
}
8286

8387
void Canvas::DrawShadow(Path path, Color color, Scalar elevation) {}

impeller/aiks/canvas_pass.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ const std::vector<Entity>& CanvasPass::GetPassEntities() const {
1818
return ops_;
1919
}
2020

21+
void CanvasPass::SetPostProcessingEntity(Entity entity) {
22+
post_processing_entity_ = std::move(entity);
23+
}
24+
25+
const Entity& CanvasPass::GetPostProcessingEntity() const {
26+
return post_processing_entity_;
27+
}
28+
2129
} // namespace impeller

impeller/aiks/canvas_pass.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
#pragma once
66

7-
#include <vector>
7+
#include <memory>
88

99
#include "flutter/fml/macros.h"
10+
#include "impeller/entity/contents.h"
1011
#include "impeller/entity/entity.h"
1112

1213
namespace impeller {
@@ -21,8 +22,13 @@ class CanvasPass {
2122

2223
const std::vector<Entity>& GetPassEntities() const;
2324

25+
void SetPostProcessingEntity(Entity entity);
26+
27+
const Entity& GetPostProcessingEntity() const;
28+
2429
private:
2530
std::vector<Entity> ops_;
31+
Entity post_processing_entity_;
2632
};
2733

2834
} // namespace impeller

impeller/aiks/picture_renderer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ bool PictureRenderer::IsValid() const {
2323
}
2424

2525
bool PictureRenderer::Render(const Surface& surface,
26-
RenderPass& onscreen_pass,
26+
RenderPass& parent_pass,
2727
const Picture& picture) {
2828
if (!IsValid()) {
2929
return false;
3030
}
3131

3232
for (const auto& pass : picture.passes) {
33-
if (!entity_renderer_.RenderEntities(surface, onscreen_pass,
33+
if (!entity_renderer_.RenderEntities(surface, parent_pass,
3434
pass.GetPassEntities())) {
3535
return false;
3636
}

impeller/aiks/picture_renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PictureRenderer {
2323
bool IsValid() const;
2424

2525
[[nodiscard]] bool Render(const Surface& surface,
26-
RenderPass& onscreen_pass,
26+
RenderPass& parent_pass,
2727
const Picture& picture);
2828

2929
private:

impeller/entity/contents.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,19 @@ Scalar SolidStrokeContents::GetStrokeSize() const {
354354
return stroke_size_;
355355
}
356356

357+
/*******************************************************************************
358+
******* ClipContents
359+
******************************************************************************/
360+
361+
ClipContents::ClipContents() = default;
362+
363+
ClipContents::~ClipContents() = default;
364+
365+
bool ClipContents::Render(const ContentRenderer& renderer,
366+
const Entity& entity,
367+
const Surface& surface,
368+
RenderPass& pass) const {
369+
return true;
370+
}
371+
357372
} // namespace impeller

impeller/entity/contents.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,20 @@ class SolidStrokeContents final : public Contents {
139139
FML_DISALLOW_COPY_AND_ASSIGN(SolidStrokeContents);
140140
};
141141

142+
class ClipContents final : public Contents {
143+
public:
144+
ClipContents();
145+
146+
~ClipContents();
147+
148+
// |Contents|
149+
bool Render(const ContentRenderer& renderer,
150+
const Entity& entity,
151+
const Surface& surface,
152+
RenderPass& pass) const override;
153+
154+
private:
155+
FML_DISALLOW_COPY_AND_ASSIGN(ClipContents);
156+
};
157+
142158
} // namespace impeller

impeller/entity/entity_renderer.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ bool EntityRenderer::IsValid() const {
3030
}
3131

3232
bool EntityRenderer::RenderEntities(const Surface& surface,
33-
RenderPass& onscreen_pass,
33+
RenderPass& parent_pass,
3434
const std::vector<Entity>& entities) {
3535
if (!IsValid()) {
3636
return false;
3737
}
3838

3939
for (const auto& entity : entities) {
4040
if (auto contents = entity.GetContents()) {
41-
if (!contents->Render(*content_renderer_, entity, surface,
42-
onscreen_pass)) {
41+
if (!contents->Render(*content_renderer_, entity, surface, parent_pass)) {
4342
return false;
4443
}
4544
}

impeller/entity/entity_renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class EntityRenderer {
2424
bool IsValid() const;
2525

2626
[[nodiscard]] bool RenderEntities(const Surface& surface,
27-
RenderPass& onscreen_pass,
27+
RenderPass& parent_pass,
2828
const std::vector<Entity>& entities);
2929

3030
private:

0 commit comments

Comments
 (0)