Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 170 additions & 161 deletions display_list/display_list_unittests.cc

Large diffs are not rendered by default.

126 changes: 56 additions & 70 deletions display_list/dl_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ DisplayListBuilder::~DisplayListBuilder() {
}
}

SkISize DisplayListBuilder::GetBaseLayerSize() const {
return ToSkISize(DlIRect::RoundOut(original_cull_rect_).GetSize());
DlISize DisplayListBuilder::GetBaseLayerDimensions() const {
return DlIRect::RoundOut(original_cull_rect_).GetSize();
}

SkImageInfo DisplayListBuilder::GetImageInfo() const {
Expand Down Expand Up @@ -540,14 +540,14 @@ void DisplayListBuilder::saveLayer(const DlRect& bounds,
}
}
}
void DisplayListBuilder::SaveLayer(const SkRect* bounds,
void DisplayListBuilder::SaveLayer(std::optional<const DlRect>& bounds,
const DlPaint* paint,
const DlImageFilter* backdrop) {
SaveLayerOptions options;
DlRect temp_bounds;
if (bounds) {
if (bounds.has_value()) {
options = options.with_bounds_from_caller();
temp_bounds = ToDlRect(*bounds);
temp_bounds = *bounds;
} else {
FML_DCHECK(temp_bounds.IsEmpty());
}
Expand Down Expand Up @@ -867,7 +867,7 @@ void DisplayListBuilder::TransformFullPerspective(
myz == 0 &&
mzx == 0 && mzy == 0 && mzz == 1 && mzt == 0 &&
mwx == 0 && mwy == 0 && mwz == 0 && mwt == 1) {
Transform2DAffine(mxx, mxy, mxt,
transform2DAffine(mxx, mxy, mxt,
myx, myy, myt);
} else if (std::isfinite(mxx) && std::isfinite(mxy) &&
std::isfinite(mxz) && std::isfinite(mxt) &&
Expand Down Expand Up @@ -920,25 +920,18 @@ void DisplayListBuilder::TransformReset() {

global_state().setIdentity();
}
void DisplayListBuilder::Transform(const SkMatrix* matrix) {
if (matrix != nullptr) {
Transform(SkM44(*matrix));
}
}
void DisplayListBuilder::Transform(const SkM44* m44) {
if (m44 != nullptr) {
transformFullPerspective(
m44->rc(0, 0), m44->rc(0, 1), m44->rc(0, 2), m44->rc(0, 3),
m44->rc(1, 0), m44->rc(1, 1), m44->rc(1, 2), m44->rc(1, 3),
m44->rc(2, 0), m44->rc(2, 1), m44->rc(2, 2), m44->rc(2, 3),
m44->rc(3, 0), m44->rc(3, 1), m44->rc(3, 2), m44->rc(3, 3));
}
void DisplayListBuilder::Transform(const DlMatrix& matrix) {
TransformFullPerspective(
matrix.e[0][0], matrix.e[1][0], matrix.e[2][0], matrix.e[3][0],
matrix.e[0][1], matrix.e[1][1], matrix.e[2][1], matrix.e[3][1],
matrix.e[0][2], matrix.e[1][2], matrix.e[2][2], matrix.e[3][2],
matrix.e[0][3], matrix.e[1][3], matrix.e[2][3], matrix.e[3][3]);
}

void DisplayListBuilder::ClipRect(const SkRect& rect,
void DisplayListBuilder::ClipRect(const DlRect& rect,
ClipOp clip_op,
bool is_aa) {
if (!rect.isFinite()) {
if (!rect.IsFinite()) {
return;
}
if (current_info().is_nop) {
Expand All @@ -960,17 +953,17 @@ void DisplayListBuilder::ClipRect(const SkRect& rect,
checkForDeferredSave();
switch (clip_op) {
case ClipOp::kIntersect:
Push<ClipIntersectRectOp>(0, ToDlRect(rect), is_aa);
Push<ClipIntersectRectOp>(0, rect, is_aa);
break;
case ClipOp::kDifference:
Push<ClipDifferenceRectOp>(0, ToDlRect(rect), is_aa);
Push<ClipDifferenceRectOp>(0, rect, is_aa);
break;
}
}
void DisplayListBuilder::ClipOval(const SkRect& bounds,
void DisplayListBuilder::ClipOval(const DlRect& bounds,
ClipOp clip_op,
bool is_aa) {
if (!bounds.isFinite()) {
if (!bounds.IsFinite()) {
return;
}
if (current_info().is_nop) {
Expand All @@ -992,22 +985,22 @@ void DisplayListBuilder::ClipOval(const SkRect& bounds,
checkForDeferredSave();
switch (clip_op) {
case ClipOp::kIntersect:
Push<ClipIntersectOvalOp>(0, ToDlRect(bounds), is_aa);
Push<ClipIntersectOvalOp>(0, bounds, is_aa);
break;
case ClipOp::kDifference:
Push<ClipDifferenceOvalOp>(0, ToDlRect(bounds), is_aa);
Push<ClipDifferenceOvalOp>(0, bounds, is_aa);
break;
}
}
void DisplayListBuilder::ClipRRect(const SkRRect& rrect,
ClipOp clip_op,
bool is_aa) {
if (rrect.isRect()) {
ClipRect(rrect.rect(), clip_op, is_aa);
ClipRect(ToDlRect(rrect.rect()), clip_op, is_aa);
return;
}
if (rrect.isOval()) {
ClipOval(rrect.rect(), clip_op, is_aa);
ClipOval(ToDlRect(rrect.rect()), clip_op, is_aa);
return;
}
if (current_info().is_nop) {
Expand Down Expand Up @@ -1043,12 +1036,12 @@ void DisplayListBuilder::ClipPath(const DlPath& path,
return;
}
if (!path.IsInverseFillType()) {
SkRect rect;
if (path.IsSkRect(&rect)) {
DlRect rect;
if (path.IsRect(&rect)) {
ClipRect(rect, clip_op, is_aa);
return;
}
if (path.IsSkOval(&rect)) {
if (path.IsOval(&rect)) {
ClipOval(rect, clip_op, is_aa);
return;
}
Expand Down Expand Up @@ -1077,7 +1070,7 @@ void DisplayListBuilder::ClipPath(const DlPath& path,
}
}

bool DisplayListBuilder::QuickReject(const SkRect& bounds) const {
bool DisplayListBuilder::QuickReject(const DlRect& bounds) const {
return global_state().content_culled(bounds);
}

Expand Down Expand Up @@ -1113,11 +1106,11 @@ void DisplayListBuilder::drawLine(const DlPoint& p0, const DlPoint& p1) {
UpdateLayerResult(result);
}
}
void DisplayListBuilder::DrawLine(const SkPoint& p0,
const SkPoint& p1,
void DisplayListBuilder::DrawLine(const DlPoint& p0,
const DlPoint& p1,
const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawLineFlags);
drawLine(ToDlPoint(p0), ToDlPoint(p1));
drawLine(p0, p1);
}
void DisplayListBuilder::drawDashedLine(const DlPoint& p0,
const DlPoint& p1,
Expand Down Expand Up @@ -1152,9 +1145,9 @@ void DisplayListBuilder::drawRect(const DlRect& rect) {
UpdateLayerResult(result);
}
}
void DisplayListBuilder::DrawRect(const SkRect& rect, const DlPaint& paint) {
void DisplayListBuilder::DrawRect(const DlRect& rect, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawRectFlags);
drawRect(ToDlRect(rect));
drawRect(rect);
}
void DisplayListBuilder::drawOval(const DlRect& bounds) {
DisplayListAttributeFlags flags = kDrawOvalFlags;
Expand All @@ -1166,9 +1159,9 @@ void DisplayListBuilder::drawOval(const DlRect& bounds) {
UpdateLayerResult(result);
}
}
void DisplayListBuilder::DrawOval(const SkRect& bounds, const DlPaint& paint) {
void DisplayListBuilder::DrawOval(const DlRect& bounds, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawOvalFlags);
drawOval(ToDlRect(bounds));
drawOval(bounds);
}
void DisplayListBuilder::drawCircle(const DlPoint& center, DlScalar radius) {
DisplayListAttributeFlags flags = kDrawCircleFlags;
Expand All @@ -1183,11 +1176,11 @@ void DisplayListBuilder::drawCircle(const DlPoint& center, DlScalar radius) {
}
}
}
void DisplayListBuilder::DrawCircle(const SkPoint& center,
void DisplayListBuilder::DrawCircle(const DlPoint& center,
DlScalar radius,
const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawCircleFlags);
drawCircle(ToDlPoint(center), radius);
drawCircle(center, radius);
}
void DisplayListBuilder::drawRRect(const SkRRect& rrect) {
if (rrect.isRect()) {
Expand Down Expand Up @@ -1241,11 +1234,6 @@ void DisplayListBuilder::drawPath(const DlPath& path) {
}
}
}
void DisplayListBuilder::DrawPath(const SkPath& path, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPathFlags);
DlPath dl_path(path);
drawPath(dl_path);
}
void DisplayListBuilder::DrawPath(const DlPath& path, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPathFlags);
drawPath(path);
Expand Down Expand Up @@ -1274,14 +1262,14 @@ void DisplayListBuilder::drawArc(const DlRect& bounds,
UpdateLayerResult(result);
}
}
void DisplayListBuilder::DrawArc(const SkRect& bounds,
void DisplayListBuilder::DrawArc(const DlRect& bounds,
DlScalar start,
DlScalar sweep,
bool useCenter,
const DlPaint& paint) {
SetAttributesFromPaint(
paint, useCenter ? kDrawArcWithCenterFlags : kDrawArcNoCenterFlags);
drawArc(ToDlRect(bounds), start, sweep, useCenter);
drawArc(bounds, start, sweep, useCenter);
}

DisplayListAttributeFlags DisplayListBuilder::FlagsForPointMode(
Expand Down Expand Up @@ -1350,10 +1338,10 @@ void DisplayListBuilder::drawPoints(PointMode mode,
}
void DisplayListBuilder::DrawPoints(PointMode mode,
uint32_t count,
const SkPoint pts[],
const DlPoint pts[],
const DlPaint& paint) {
SetAttributesFromPaint(paint, FlagsForPointMode(mode));
drawPoints(mode, count, ToDlPoints(pts));
drawPoints(mode, count, pts);
}
void DisplayListBuilder::drawVertices(
const std::shared_ptr<DlVertices>& vertices,
Expand Down Expand Up @@ -1411,15 +1399,15 @@ void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
}
}
void DisplayListBuilder::DrawImage(const sk_sp<DlImage>& image,
const SkPoint& point,
const DlPoint& point,
DlImageSampling sampling,
const DlPaint* paint) {
if (paint != nullptr) {
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageWithPaintFlags);
drawImage(image, ToDlPoint(point), sampling, true);
drawImage(image, point, sampling, true);
} else {
drawImage(image, ToDlPoint(point), sampling, false);
drawImage(image, point, sampling, false);
}
}
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
Expand All @@ -1442,19 +1430,17 @@ void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
}
}
void DisplayListBuilder::DrawImageRect(const sk_sp<DlImage>& image,
const SkRect& src,
const SkRect& dst,
const DlRect& src,
const DlRect& dst,
DlImageSampling sampling,
const DlPaint* paint,
SrcRectConstraint constraint) {
if (paint != nullptr) {
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageRectWithPaintFlags);
drawImageRect(image, ToDlRect(src), ToDlRect(dst), sampling, true,
constraint);
drawImageRect(image, src, dst, sampling, true, constraint);
} else {
drawImageRect(image, ToDlRect(src), ToDlRect(dst), sampling, false,
constraint);
drawImageRect(image, src, dst, sampling, false, constraint);
}
}
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
Expand All @@ -1477,16 +1463,16 @@ void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
}
}
void DisplayListBuilder::DrawImageNine(const sk_sp<DlImage>& image,
const SkIRect& center,
const SkRect& dst,
const DlIRect& center,
const DlRect& dst,
DlFilterMode filter,
const DlPaint* paint) {
if (paint != nullptr) {
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageNineWithPaintFlags);
drawImageNine(image, ToDlIRect(center), ToDlRect(dst), filter, true);
drawImageNine(image, center, dst, filter, true);
} else {
drawImageNine(image, ToDlIRect(center), ToDlRect(dst), filter, false);
drawImageNine(image, center, dst, filter, false);
}
}
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
Expand Down Expand Up @@ -1565,21 +1551,21 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
}
void DisplayListBuilder::DrawAtlas(const sk_sp<DlImage>& atlas,
const SkRSXform xform[],
const SkRect tex[],
const DlRect tex[],
const DlColor colors[],
int count,
DlBlendMode mode,
DlImageSampling sampling,
const SkRect* cull_rect,
const DlRect* cull_rect,
const DlPaint* paint) {
if (paint != nullptr) {
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawAtlasWithPaintFlags);
drawAtlas(atlas, xform, ToDlRects(tex), colors, count, mode, sampling,
ToDlRect(cull_rect), true);
drawAtlas(atlas, xform, tex, colors, count, mode, sampling, cull_rect,
true);
} else {
drawAtlas(atlas, xform, ToDlRects(tex), colors, count, mode, sampling,
ToDlRect(cull_rect), false);
drawAtlas(atlas, xform, tex, colors, count, mode, sampling, cull_rect,
false);
}
}

Expand Down
Loading