Skip to content

Commit a10e25e

Browse files
authored
[DisplayList] Migrate from SkRSXform to Impeller RSTransform (#161652)
Fixes SkRSXform task in flutter/flutter#161456 Removes (nearly) all uses of Skia SkRSXform object from DisplayList and replaces it with a new Impeller RSTransform geometry object. There are remaining uses in: - Skia adapter code which needs to convert them back to SkRSXform when using the Skia backend - dl_rendering_tests which is waiting for a major conversion effort - ?Fuchsia? code has an SkCanvas spy adapter used in its embedder code (not DisplayList related) - web_ui/skwasm
1 parent 1580a3d commit a10e25e

Some content is hidden

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

42 files changed

+437
-177
lines changed

engine/src/flutter/ci/licenses_golden/excluded_files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
../../../flutter/impeller/geometry/path_unittests.cc
175175
../../../flutter/impeller/geometry/rect_unittests.cc
176176
../../../flutter/impeller/geometry/round_rect_unittests.cc
177+
../../../flutter/impeller/geometry/rstransform_unittests.cc
177178
../../../flutter/impeller/geometry/saturated_math_unittests.cc
178179
../../../flutter/impeller/geometry/size_unittests.cc
179180
../../../flutter/impeller/geometry/trig_unittests.cc

engine/src/flutter/ci/licenses_golden/licenses_flutter

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42513,6 +42513,8 @@ ORIGIN: ../../../flutter/impeller/geometry/round_rect.cc + ../../../flutter/LICE
4251342513
ORIGIN: ../../../flutter/impeller/geometry/round_rect.h + ../../../flutter/LICENSE
4251442514
ORIGIN: ../../../flutter/impeller/geometry/rounding_radii.cc + ../../../flutter/LICENSE
4251542515
ORIGIN: ../../../flutter/impeller/geometry/rounding_radii.h + ../../../flutter/LICENSE
42516+
ORIGIN: ../../../flutter/impeller/geometry/rstransform.cc + ../../../flutter/LICENSE
42517+
ORIGIN: ../../../flutter/impeller/geometry/rstransform.h + ../../../flutter/LICENSE
4251642518
ORIGIN: ../../../flutter/impeller/geometry/saturated_math.h + ../../../flutter/LICENSE
4251742519
ORIGIN: ../../../flutter/impeller/geometry/scalar.h + ../../../flutter/LICENSE
4251842520
ORIGIN: ../../../flutter/impeller/geometry/separated_vector.cc + ../../../flutter/LICENSE
@@ -45456,6 +45458,8 @@ FILE: ../../../flutter/impeller/geometry/round_rect.cc
4545645458
FILE: ../../../flutter/impeller/geometry/round_rect.h
4545745459
FILE: ../../../flutter/impeller/geometry/rounding_radii.cc
4545845460
FILE: ../../../flutter/impeller/geometry/rounding_radii.h
45461+
FILE: ../../../flutter/impeller/geometry/rstransform.cc
45462+
FILE: ../../../flutter/impeller/geometry/rstransform.h
4545945463
FILE: ../../../flutter/impeller/geometry/saturated_math.h
4546045464
FILE: ../../../flutter/impeller/geometry/scalar.h
4546145465
FILE: ../../../flutter/impeller/geometry/separated_vector.cc

engine/src/flutter/display_list/benchmarking/dl_complexity_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class ComplexityCalculatorHelper
158158
}
159159

160160
void drawAtlas(const sk_sp<DlImage> atlas,
161-
const SkRSXform xform[],
161+
const DlRSTransform xform[],
162162
const DlRect tex[],
163163
const DlColor colors[],
164164
int count,

engine/src/flutter/display_list/benchmarking/dl_complexity_unittests.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ TEST(DisplayListComplexity, DrawAtlas) {
421421
bitmap.allocPixels(info, 0);
422422
auto image = SkImages::RasterFromBitmap(bitmap);
423423

424-
std::vector<SkRect> rects;
425-
std::vector<SkRSXform> xforms;
424+
std::vector<DlRect> rects;
425+
std::vector<DlRSTransform> xforms;
426426
for (int i = 0; i < 10; i++) {
427-
rects.push_back(SkRect::MakeXYWH(0, 0, 10, 10));
428-
xforms.push_back(SkRSXform::Make(1, 0, 0, 0));
427+
rects.push_back(DlRect::MakeXYWH(0, 0, 10, 10));
428+
xforms.push_back(DlRSTransform(1, 0, 0, 0));
429429
}
430430

431431
DisplayListBuilder builder;

engine/src/flutter/display_list/display_list_unittests.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,10 @@ TEST_F(DisplayListTest, SingleOpsMightSupportGroupOpacityBlendMode) {
12011201
kTestImage2, DlIRect::MakeLTRB(20, 20, 30, 30),
12021202
DlRect::MakeLTRB(0, 0, 20, 20), DlFilterMode::kLinear, nullptr);
12031203
, true);
1204-
static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
1204+
static DlRSTransform xforms[] = {
1205+
DlRSTransform::Make({0.0f, 0.0f}, 1.0f, DlDegrees(0)),
1206+
DlRSTransform::Make({0.0f, 0.0f}, 1.0f, DlDegrees(90)),
1207+
};
12051208
static DlRect texs[] = {
12061209
DlRect::MakeLTRB(10, 10, 20, 20),
12071210
DlRect::MakeLTRB(20, 20, 30, 30),
@@ -3502,7 +3505,10 @@ TEST_F(DisplayListTest, NopOperationsOmittedFromRecords) {
35023505
builder.DrawImageNine(kTestImage1, DlIRect::MakeLTRB(10, 10, 20, 20),
35033506
DlRect::MakeLTRB(10, 10, 100, 100),
35043507
DlFilterMode::kLinear, &paint);
3505-
SkRSXform xforms[] = {{1, 0, 10, 10}, {0, 1, 10, 10}};
3508+
DlRSTransform xforms[] = {
3509+
DlRSTransform::Make({10.0f, 10.0f}, 1.0f, DlDegrees(0)),
3510+
DlRSTransform::Make({10.0f, 10.0f}, 1.0f, DlDegrees(90)),
3511+
};
35063512
DlRect rects[] = {
35073513
DlRect::MakeLTRB(10, 10, 20, 20),
35083514
DlRect::MakeLTRB(10, 20, 30, 20),

engine/src/flutter/display_list/dl_builder.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ void DisplayListBuilder::DrawImageNine(const sk_sp<DlImage>& image,
14671467
}
14681468
}
14691469
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
1470-
const SkRSXform xform[],
1470+
const DlRSTransform xform[],
14711471
const DlRect tex[],
14721472
const DlColor colors[],
14731473
int count,
@@ -1482,19 +1482,20 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
14821482
if (result == OpResult::kNoEffect) {
14831483
return;
14841484
}
1485-
SkPoint quad[4];
1485+
DlQuad quad;
14861486
AccumulationRect accumulator;
14871487
for (int i = 0; i < count; i++) {
14881488
const DlRect& src = tex[i];
1489-
xform[i].toQuad(src.GetWidth(), src.GetHeight(), quad);
1489+
xform[i].GetQuad(src.GetWidth(), src.GetHeight(), quad);
14901490
for (int j = 0; j < 4; j++) {
1491-
accumulator.accumulate(ToDlPoint(quad[j]));
1491+
accumulator.accumulate(quad[j]);
14921492
}
14931493
}
14941494
if (accumulator.is_empty() ||
14951495
!AccumulateOpBounds(accumulator.GetBounds(), flags)) {
14961496
return;
14971497
}
1498+
14981499
// Accumulating the bounds might not trip the overlap condition if the
14991500
// whole atlas operation is separated from other rendering calls, but
15001501
// since each atlas op is treated as an independent operation, we have
@@ -1509,7 +1510,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
15091510
current_layer().layer_local_accumulator.record_overlapping_bounds();
15101511
}
15111512

1512-
int bytes = count * (sizeof(SkRSXform) + sizeof(SkRect));
1513+
int bytes = count * (sizeof(DlRSTransform) + sizeof(DlRect));
15131514
void* data_ptr;
15141515
if (colors != nullptr) {
15151516
bytes += count * sizeof(DlColor);
@@ -1541,7 +1542,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
15411542
is_ui_thread_safe_ = is_ui_thread_safe_ && atlas->isUIThreadSafe();
15421543
}
15431544
void DisplayListBuilder::DrawAtlas(const sk_sp<DlImage>& atlas,
1544-
const SkRSXform xform[],
1545+
const DlRSTransform xform[],
15451546
const DlRect tex[],
15461547
const DlColor colors[],
15471548
int count,

engine/src/flutter/display_list/dl_builder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class DisplayListBuilder final : public virtual DlCanvas,
209209
const DlPaint* paint = nullptr) override;
210210
// |DlCanvas|
211211
void DrawAtlas(const sk_sp<DlImage>& atlas,
212-
const SkRSXform xform[],
212+
const DlRSTransform xform[],
213213
const DlRect tex[],
214214
const DlColor colors[],
215215
int count,
@@ -471,7 +471,7 @@ class DisplayListBuilder final : public virtual DlCanvas,
471471
bool render_with_attributes) override;
472472
// |DlOpReceiver|
473473
void drawAtlas(const sk_sp<DlImage> atlas,
474-
const SkRSXform xform[],
474+
const DlRSTransform xform[],
475475
const DlRect tex[],
476476
const DlColor colors[],
477477
int count,

engine/src/flutter/display_list/dl_canvas.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "third_party/skia/include/core/SkMatrix.h"
1818
#include "third_party/skia/include/core/SkPath.h"
1919
#include "third_party/skia/include/core/SkRRect.h"
20-
#include "third_party/skia/include/core/SkRSXform.h"
2120
#include "third_party/skia/include/core/SkRect.h"
2221
#include "third_party/skia/include/core/SkTextBlob.h"
2322

@@ -189,7 +188,7 @@ class DlCanvas {
189188
DlFilterMode filter,
190189
const DlPaint* paint = nullptr) = 0;
191190
virtual void DrawAtlas(const sk_sp<DlImage>& atlas,
192-
const SkRSXform xform[],
191+
const DlRSTransform xform[],
193192
const DlRect tex[],
194193
const DlColor colors[],
195194
int count,
@@ -373,18 +372,6 @@ class DlCanvas {
373372
const DlPaint* paint = nullptr) {
374373
DrawImageNine(image, ToDlIRect(center), ToDlRect(dst), filter, paint);
375374
}
376-
void DrawAtlas(const sk_sp<DlImage>& atlas,
377-
const SkRSXform xform[],
378-
const SkRect tex[],
379-
const DlColor colors[],
380-
int count,
381-
DlBlendMode mode,
382-
DlImageSampling sampling,
383-
const SkRect* cullRect,
384-
const DlPaint* paint = nullptr) {
385-
DrawAtlas(atlas, xform, ToDlRects(tex), colors, count, mode, sampling,
386-
ToDlRect(cullRect), paint);
387-
}
388375
void DrawShadow(const SkPath& path,
389376
const DlColor color,
390377
const DlScalar elevation,

engine/src/flutter/display_list/dl_op_receiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class DlOpReceiver {
345345
DlFilterMode filter,
346346
bool render_with_attributes) = 0;
347347
virtual void drawAtlas(const sk_sp<DlImage> atlas,
348-
const SkRSXform xform[],
348+
const DlRSTransform xform[],
349349
const DlRect tex[],
350350
const DlColor colors[],
351351
int count,

engine/src/flutter/display_list/dl_op_records.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "flutter/impeller/geometry/path.h"
1717
#include "flutter/impeller/typographer/text_frame.h"
18-
#include "third_party/skia/include/core/SkRSXform.h"
1918

2019
namespace flutter {
2120

@@ -841,7 +840,7 @@ DEFINE_DRAW_IMAGE_NINE_OP(DrawImageNineWithAttr, true)
841840
// 4 byte header + 40 byte payload uses 44 bytes but is rounded up to 48 bytes
842841
// (4 bytes unused)
843842
// Each of these is then followed by a number of lists.
844-
// SkRSXform list is a multiple of 16 bytes so it is always packed well
843+
// DlRSTransform list is a multiple of 16 bytes so it is always packed well
845844
// DlRect list is also a multiple of 16 bytes so it also packs well
846845
// DlColor list only packs well if the count is even, otherwise there
847846
// can be 4 unusued bytes at the end.
@@ -876,7 +875,7 @@ struct DrawAtlasBaseOp : DrawOpBase {
876875
render_with_attributes == other->render_with_attributes &&
877876
sampling == other->sampling && atlas->Equals(other->atlas));
878877
if (ret) {
879-
size_t bytes = count * (sizeof(SkRSXform) + sizeof(DlRect));
878+
size_t bytes = count * (sizeof(DlRSTransform) + sizeof(DlRect));
880879
if (has_colors) {
881880
bytes += count * sizeof(DlColor);
882881
}
@@ -906,7 +905,8 @@ struct DrawAtlasOp final : DrawAtlasBaseOp {
906905
render_with_attributes) {}
907906

908907
void dispatch(DlOpReceiver& receiver) const {
909-
const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(this + 1);
908+
const DlRSTransform* xform =
909+
reinterpret_cast<const DlRSTransform*>(this + 1);
910910
const DlRect* tex = reinterpret_cast<const DlRect*>(xform + count);
911911
const DlColor* colors =
912912
has_colors ? reinterpret_cast<const DlColor*>(tex + count) : nullptr;
@@ -950,7 +950,8 @@ struct DrawAtlasCulledOp final : DrawAtlasBaseOp {
950950
const DlRect cull_rect;
951951

952952
void dispatch(DlOpReceiver& receiver) const {
953-
const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(this + 1);
953+
const DlRSTransform* xform =
954+
reinterpret_cast<const DlRSTransform*>(this + 1);
954955
const DlRect* tex = reinterpret_cast<const DlRect*>(xform + count);
955956
const DlColor* colors =
956957
has_colors ? reinterpret_cast<const DlColor*>(tex + count) : nullptr;

0 commit comments

Comments
 (0)