Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroengoogle committed Dec 5, 2023
2 parents 3fd978a + 647cf40 commit 67e4294
Show file tree
Hide file tree
Showing 74 changed files with 346 additions and 434 deletions.
16 changes: 8 additions & 8 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vars = {
'llvm_git': 'https://llvm.googlesource.com',
# OCMock is for testing only so there is no google clone
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
'skia_revision': '7901100ba2d984cb6c2e52e93533c9868d4e7913',
'skia_revision': '5f54e9f84cff8c42fd645ec53c1727857bdb12ab',

# WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY
# See `lib/web_ui/README.md` for how to roll CanvasKit to a new version.
Expand Down Expand Up @@ -59,7 +59,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': '21574eae3a693abda6b72933aad4bac5a2a59ca4',
'dart_revision': 'd8efef525ce1d71e7c7b192d187705c59f0095a0',

# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
Expand All @@ -73,7 +73,7 @@ vars = {
'dart_libprotobuf_rev': '24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb',
'dart_perfetto_rev': '13ce0c9e13b0940d2476cd0cff2301708a9a2e2b',
'dart_protobuf_gn_rev': 'ca669f79945418f6229e4fef89b666b2a88cbb10',
'dart_protobuf_rev': 'dcec2eda9db4e6728e900928aa2e46944ba4fa6f',
'dart_protobuf_rev': 'bb1977478458d070abbb4802ae73a1560233864d',
'dart_pub_rev': '1779628b386819675130f14326f1e8812901c48f',
'dart_root_certificates_rev': '692f6d6488af68e0121317a9c2c9eb393eb0ee50',
'dart_tools_rev': 'c63dcb5e93d4a222da0c52960bb6688030ddabc3',
Expand Down Expand Up @@ -680,7 +680,7 @@ deps = {
Var('chromium_git') + '/external/github.com/brendan-duncan/archive.git' + '@' + '9de7a0544457c6aba755ccb65abb41b0dc1db70d', # 3.1.2

'src/flutter/third_party/pkg/equatable':
Var('github_git') + '/felangel/equatable.git' + '@' + '2117551ff3054f8edb1a58f63ffe1832a8d25623', # 2.0.5
Var('flutter_git') + '/third_party/equatable.git' + '@' + '2117551ff3054f8edb1a58f63ffe1832a8d25623', # 2.0.5

'src/flutter/third_party/pkg/flutter_packages':
Var('flutter_git') + '/mirrors/packages' + '@' + '25454e63851fe7933f04d025606e68c1eac4fe0f', # various
Expand All @@ -704,16 +704,16 @@ deps = {
Var('dart_git') + '/external/github.com/google/vector_math.dart.git' + '@' + '0a5fd95449083d404df9768bc1b321b88a7d2eef', # 2.1.0

'src/flutter/third_party/imgui':
Var('github_git') + '/ocornut/imgui.git' + '@' + '3ea0fad204e994d669f79ed29dcaf61cd5cb571d',
Var('flutter_git') + '/third_party/imgui.git' + '@' + '3ea0fad204e994d669f79ed29dcaf61cd5cb571d',

'src/third_party/tinygltf':
Var('github_git') + '/syoyo/tinygltf.git' + '@' + '9bb5806df4055ac973b970ba5b3e27ce27d98148',
Var('flutter_git') + '/third_party/tinygltf.git' + '@' + '9bb5806df4055ac973b970ba5b3e27ce27d98148',

'src/third_party/json':
Var('github_git') + '/nlohmann/json.git' + '@' + '17d9eacd248f58b73f4d1be518ef649fe2295642',
Var('flutter_git') + '/third_party/json.git' + '@' + '17d9eacd248f58b73f4d1be518ef649fe2295642',

'src/third_party/stb':
Var('github_git') + '/nothings/stb.git' + '@' + '5736b15f7ea0ffb08dd38af21067c314d6a3aae9',
Var('flutter_git') + '/third_party/stb.git' + '@' + '5736b15f7ea0ffb08dd38af21067c314d6a3aae9',

'src/third_party/gradle': {
'packages': [
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: c17d2eb7a04e921c4bdced9ef3fba2fd
Signature: 7f38d0c92f4afee2bc0fc2ad84dfeb8a

====================================================================================================
LIBRARY: dart
Expand Down
8 changes: 3 additions & 5 deletions ci/licenses_golden/licenses_skia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: d495f5e3ffe4f301637eb9f5fae26750
Signature: 1834371d1b225b6b6d1017adbe931616

====================================================================================================
LIBRARY: etc1
Expand Down Expand Up @@ -1520,8 +1520,6 @@ ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkHRESULT.h + ../../../f
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkIStream.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkIStream.h + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkTScopedComPtr.h + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL.h + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.h + ../../../flutter/third_party/skia/LICENSE
TYPE: LicenseType.bsd
Expand Down Expand Up @@ -1703,8 +1701,6 @@ FILE: ../../../flutter/third_party/skia/src/utils/win/SkHRESULT.h
FILE: ../../../flutter/third_party/skia/src/utils/win/SkIStream.cpp
FILE: ../../../flutter/third_party/skia/src/utils/win/SkIStream.h
FILE: ../../../flutter/third_party/skia/src/utils/win/SkTScopedComPtr.h
FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL.h
FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp
FILE: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.cpp
FILE: ../../../flutter/third_party/skia/src/xps/SkXPSDevice.h
----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -9018,6 +9014,7 @@ ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/SlugImpl.h + ../../../flu
ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.h + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/SkTestCanvas.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp + ../../../flutter/third_party/skia/LICENSE
ORIGIN: ../../../flutter/third_party/skia/toolchain/android_trampolines/gen_trampolines/gen_trampolines.go + ../../../flutter/third_party/skia/LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/third_party/skia/fuzz/FuzzCubicRoots.cpp
Expand Down Expand Up @@ -9300,6 +9297,7 @@ FILE: ../../../flutter/third_party/skia/src/text/gpu/SlugImpl.h
FILE: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.cpp
FILE: ../../../flutter/third_party/skia/src/text/gpu/VertexFiller.h
FILE: ../../../flutter/third_party/skia/src/utils/SkTestCanvas.cpp
FILE: ../../../flutter/third_party/skia/src/utils/win/SkWGL_win.cpp
FILE: ../../../flutter/third_party/skia/toolchain/android_trampolines/gen_trampolines/gen_trampolines.go
----------------------------------------------------------------------------------------------------
Copyright 2023 Google LLC
Expand Down
12 changes: 7 additions & 5 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,7 @@ TEST_P(AiksTest, OpacityPeepHoleApplicationTest) {
Entity entity;
entity.SetContents(SolidColorContents::Make(
PathBuilder{}.AddRect(rect).TakePath(), Color::Red()));
entity_pass->AddEntity(entity);
entity_pass->AddEntity(std::move(entity));
paint.color = Color::Red().WithAlpha(0.5);

delegate = std::make_shared<OpacityPeepholePassDelegate>(paint);
Expand Down Expand Up @@ -3239,20 +3239,22 @@ TEST_P(AiksTest, OpaqueEntitiesGetCoercedToSource) {
Picture picture = canvas.EndRecordingAsPicture();

// Extract the SolidColorSource.
Entity entity;
// Entity entity;
std::vector<Entity> entity;
std::shared_ptr<SolidColorContents> contents;
picture.pass->IterateAllEntities([&e = entity, &contents](Entity& entity) {
picture.pass->IterateAllEntities([e = &entity, &contents](Entity& entity) {
if (ScalarNearlyEqual(entity.GetTransform().GetScale().x, 1.618f)) {
e = entity;
contents =
std::static_pointer_cast<SolidColorContents>(entity.GetContents());
e->emplace_back(entity.Clone());
return false;
}
return true;
});

ASSERT_TRUE(entity.size() >= 1);
ASSERT_TRUE(contents->IsOpaque());
ASSERT_EQ(entity.GetBlendMode(), BlendMode::kSource);
ASSERT_EQ(entity[0].GetBlendMode(), BlendMode::kSource);
}

TEST_P(AiksTest, CanRenderDestructiveSaveLayer) {
Expand Down
133 changes: 104 additions & 29 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "impeller/aiks/paint_pass_delegate.h"
#include "impeller/entity/contents/atlas_contents.h"
#include "impeller/entity/contents/clip_contents.h"
#include "impeller/entity/contents/color_source_contents.h"
#include "impeller/entity/contents/filters/filter_contents.h"
#include "impeller/entity/contents/solid_rrect_blur_contents.h"
#include "impeller/entity/contents/text_contents.h"
#include "impeller/entity/contents/texture_contents.h"
Expand All @@ -23,6 +25,80 @@

namespace impeller {

namespace {

static std::shared_ptr<Contents> CreateContentsForGeometryWithFilters(
const Paint& paint,
std::shared_ptr<Geometry> geometry) {
std::shared_ptr<ColorSourceContents> contents =
paint.color_source.GetContents(paint);

// Attempt to apply the color filter on the CPU first.
// Note: This is not just an optimization; some color sources rely on
// CPU-applied color filters to behave properly.
bool needs_color_filter = paint.HasColorFilter();
if (needs_color_filter) {
auto color_filter = paint.GetColorFilter();
if (contents->ApplyColorFilter(color_filter->GetCPUColorFilterProc())) {
needs_color_filter = false;
}
}

contents->SetGeometry(std::move(geometry));
if (paint.mask_blur_descriptor.has_value()) {
// If there's a mask blur and we need to apply the color filter on the GPU,
// we need to be careful to only apply the color filter to the source
// colors. CreateMaskBlur is able to handle this case.
return paint.mask_blur_descriptor->CreateMaskBlur(
contents, needs_color_filter ? paint.GetColorFilter() : nullptr);
}

std::shared_ptr<Contents> contents_copy = std::move(contents);
// Image input types will directly set their color filter,
// if any. See `TiledTextureContents.SetColorFilter`.
if (needs_color_filter &&
paint.color_source.GetType() != ColorSource::Type::kImage) {
std::shared_ptr<ColorFilter> color_filter = paint.GetColorFilter();
contents_copy = color_filter->WrapWithGPUColorFilter(
FilterInput::Make(std::move(contents_copy)),
ColorFilterContents::AbsorbOpacity::kYes);
}

if (paint.image_filter) {
std::shared_ptr<FilterContents> filter = paint.image_filter->WrapInput(
FilterInput::Make(std::move(contents_copy)));
filter->SetRenderingMode(Entity::RenderingMode::kDirect);
return filter;
}

return contents_copy;
}

static std::shared_ptr<Contents> CreatePathContentsWithFilters(
const Paint& paint,
Path path = {}) {
std::shared_ptr<Geometry> geometry;
switch (paint.style) {
case Paint::Style::kFill:
geometry = Geometry::MakeFillPath(std::move(path));
break;
case Paint::Style::kStroke:
geometry = Geometry::MakeStrokePath(std::move(path), paint.stroke_width,
paint.stroke_miter, paint.stroke_cap,
paint.stroke_join);
break;
}

return CreateContentsForGeometryWithFilters(paint, std::move(geometry));
}

static std::shared_ptr<Contents> CreateCoverContentsWithFilters(
const Paint& paint) {
return CreateContentsForGeometryWithFilters(paint, Geometry::MakeCover());
}

} // namespace

Canvas::Canvas() {
Initialize(std::nullopt);
}
Expand Down Expand Up @@ -176,20 +252,19 @@ void Canvas::DrawPath(Path path, const Paint& paint) {
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(
paint.WithFilters(paint.CreateContentsForEntity(std::move(path))));
entity.SetContents(CreatePathContentsWithFilters(paint, std::move(path)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawPaint(const Paint& paint) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.CreateContentsForEntity({}, true));
entity.SetContents(CreateCoverContentsWithFilters(paint));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
Expand Down Expand Up @@ -227,7 +302,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
entity.SetBlendMode(new_paint.blend_mode);
entity.SetContents(new_paint.WithFilters(std::move(contents)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));

return true;
}
Expand All @@ -237,10 +312,10 @@ void Canvas::DrawLine(const Point& p0, const Point& p1, const Paint& paint) {
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap))));
entity.SetContents(CreateContentsForGeometryWithFilters(
paint, Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawRect(Rect rect, const Paint& paint) {
Expand All @@ -257,10 +332,10 @@ void Canvas::DrawRect(Rect rect, const Paint& paint) {
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(
paint.CreateContentsForGeometry(Geometry::MakeRect(rect))));
entity.SetContents(
CreateContentsForGeometryWithFilters(paint, Geometry::MakeRect(rect)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) {
Expand All @@ -278,10 +353,10 @@ void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) {
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
Geometry::MakeFillPath(std::move(path)))));
entity.SetContents(CreateContentsForGeometryWithFilters(
paint, Geometry::MakeFillPath(std::move(path))));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
return;
}
DrawPath(std::move(path), paint);
Expand All @@ -304,9 +379,9 @@ void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) {
? Geometry::MakeStrokedCircle(center, radius, paint.stroke_width)
: Geometry::MakeCircle(center, radius);
entity.SetContents(
paint.WithFilters(paint.CreateContentsForGeometry(geometry)));
CreateContentsForGeometryWithFilters(paint, std::move(geometry)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::ClipPath(Path path, Entity::ClipOperation clip_op) {
Expand Down Expand Up @@ -401,7 +476,7 @@ void Canvas::ClipGeometry(const std::shared_ptr<Geometry>& geometry,
entity.SetContents(std::move(contents));
entity.SetClipDepth(GetClipDepth());

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));

++transform_stack_.back().clip_depth;
transform_stack_.back().contains_clips = true;
Expand Down Expand Up @@ -440,7 +515,7 @@ void Canvas::RestoreClip() {
entity.SetContents(std::make_shared<ClipRestoreContents>());
entity.SetClipDepth(GetClipDepth());

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawPoints(std::vector<Point> points,
Expand All @@ -455,11 +530,12 @@ void Canvas::DrawPoints(std::vector<Point> points,
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
entity.SetContents(CreateContentsForGeometryWithFilters(
paint,
Geometry::MakePointField(std::move(points), radius,
/*round=*/point_style == PointStyle::kRound))));
/*round=*/point_style == PointStyle::kRound)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawPicture(const Picture& picture) {
Expand Down Expand Up @@ -533,7 +609,7 @@ void Canvas::DrawImageRect(const std::shared_ptr<Image>& image,
entity.SetContents(paint.WithFilters(contents));
entity.SetTransform(GetCurrentTransform());

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

Picture Canvas::EndRecordingAsPicture() {
Expand Down Expand Up @@ -597,7 +673,7 @@ void Canvas::DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
entity.SetContents(
paint.WithFilters(paint.WithMaskBlur(std::move(text_contents), true)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

static bool UseColorSourceContents(
Expand Down Expand Up @@ -635,9 +711,8 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
// If there are no vertex color or texture coordinates. Or if there
// are vertex coordinates then only if the contents are an image.
if (UseColorSourceContents(vertices, paint)) {
auto contents = paint.CreateContentsForGeometry(vertices);
entity.SetContents(paint.WithFilters(std::move(contents)));
GetCurrentPass().AddEntity(entity);
entity.SetContents(CreateContentsForGeometryWithFilters(paint, vertices));
GetCurrentPass().AddEntity(std::move(entity));
return;
}

Expand Down Expand Up @@ -675,7 +750,7 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
contents->SetSourceContents(std::move(src_contents));
entity.SetContents(paint.WithFilters(std::move(contents)));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
Expand Down Expand Up @@ -706,7 +781,7 @@ void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(contents));

GetCurrentPass().AddEntity(entity);
GetCurrentPass().AddEntity(std::move(entity));
}

} // namespace impeller
Loading

0 comments on commit 67e4294

Please sign in to comment.