adjust naming of methods to match style guide (flutter/engine#28753)

This commit is contained in:
Jim Graham
2021-09-23 17:13:02 -07:00
committed by GitHub
parent 98716a1274
commit 9e3603308f
9 changed files with 783 additions and 538 deletions

View File

@@ -82,39 +82,37 @@ struct DLOp {
dispatcher.set##name(value); \
} \
};
DEFINE_SET_BOOL_OP(AA)
DEFINE_SET_BOOL_OP(AntiAlias)
DEFINE_SET_BOOL_OP(Dither)
DEFINE_SET_BOOL_OP(InvertColors)
#undef DEFINE_SET_BOOL_OP
// 4 byte header + 4 byte payload packs into minimum 8 bytes
#define DEFINE_SET_ENUM_OP(name) \
struct Set##name##s##Op final : DLOp { \
static const auto kType = DisplayListOpType::kSet##name##s; \
\
Set##name##s##Op(SkPaint::name value) : value(value) {} \
\
const SkPaint::name value; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.set##name##s(value); \
} \
#define DEFINE_SET_ENUM_OP(name) \
struct SetStroke##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kSetStroke##name; \
\
SetStroke##name##Op(SkPaint::name value) : value(value) {} \
\
const SkPaint::name value; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.setStroke##name(value); \
} \
};
DEFINE_SET_ENUM_OP(Cap)
DEFINE_SET_ENUM_OP(Join)
#undef DEFINE_SET_ENUM_OP
// 4 byte header + 4 byte payload packs into minimum 8 bytes
struct SetDrawStyleOp final : DLOp {
static const auto kType = DisplayListOpType::kSetDrawStyle;
struct SetStyleOp final : DLOp {
static const auto kType = DisplayListOpType::kSetStyle;
SetDrawStyleOp(SkPaint::Style style) : style(style) {}
SetStyleOp(SkPaint::Style style) : style(style) {}
const SkPaint::Style style;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.setDrawStyle(style);
}
void dispatch(Dispatcher& dispatcher) const { dispatcher.setStyle(style); }
};
// 4 byte header + 4 byte payload packs into minimum 8 bytes
struct SetStrokeWidthOp final : DLOp {
@@ -129,15 +127,15 @@ struct SetStrokeWidthOp final : DLOp {
}
};
// 4 byte header + 4 byte payload packs into minimum 8 bytes
struct SetMiterLimitOp final : DLOp {
static const auto kType = DisplayListOpType::kSetMiterLimit;
struct SetStrokeMiterOp final : DLOp {
static const auto kType = DisplayListOpType::kSetStrokeMiter;
SetMiterLimitOp(SkScalar limit) : limit(limit) {}
SetStrokeMiterOp(SkScalar limit) : limit(limit) {}
const SkScalar limit;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.setMiterLimit(limit);
dispatcher.setStrokeMiter(limit);
}
};
@@ -379,7 +377,7 @@ struct Transform3x3Op final : DLOp {
const Sk##shapetype shape; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.clip##shapetype(shape, is_aa, SkClipOp::k##clipop); \
dispatcher.clip##shapetype(shape, SkClipOp::k##clipop, is_aa); \
} \
};
DEFINE_CLIP_SHAPE_OP(Rect, Intersect)
@@ -399,7 +397,7 @@ DEFINE_CLIP_SHAPE_OP(RRect, Difference)
const SkPath path; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.clipPath(path, is_aa, SkClipOp::k##clipop); \
dispatcher.clipPath(path, SkClipOp::k##clipop, is_aa); \
} \
\
DisplayListCompare equals(const Clip##clipop##PathOp* other) const { \
@@ -556,69 +554,81 @@ struct DrawVerticesOp final : DLOp {
};
// 4 byte header + 36 byte payload packs efficiently into 40 bytes
struct DrawImageOp final : DLOp {
static const auto kType = DisplayListOpType::kDrawImage;
#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
struct name##Op final : DLOp { \
static const auto kType = DisplayListOpType::k##name; \
\
name##Op(const sk_sp<SkImage> image, \
const SkPoint& point, \
const SkSamplingOptions& sampling) \
: point(point), sampling(sampling), image(std::move(image)) {} \
\
const SkPoint point; \
const SkSamplingOptions sampling; \
const sk_sp<SkImage> image; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawImage(image, point, sampling, with_attributes); \
} \
};
DEFINE_DRAW_IMAGE_OP(DrawImage, false)
DEFINE_DRAW_IMAGE_OP(DrawImageWithAttr, true)
#undef DEFINE_DRAW_IMAGE_OP
DrawImageOp(const sk_sp<SkImage> image,
const SkPoint& point,
const SkSamplingOptions& sampling)
: point(point), sampling(sampling), image(std::move(image)) {}
// 4 byte header + 68 byte payload packs efficiently into 72 bytes
struct DrawImageRectOp final : DLOp {
static const auto kType = DisplayListOpType::kDrawImageRect;
const SkPoint point;
DrawImageRectOp(const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint)
: src(src),
dst(dst),
sampling(sampling),
render_with_attributes(render_with_attributes),
constraint(constraint),
image(std::move(image)) {}
const SkRect src;
const SkRect dst;
const SkSamplingOptions sampling;
const bool render_with_attributes;
const SkCanvas::SrcRectConstraint constraint;
const sk_sp<SkImage> image;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.drawImage(image, point, sampling);
dispatcher.drawImageRect(image, src, dst, sampling, render_with_attributes,
constraint);
}
};
// 4 byte header + 60 byte payload packs efficiently into 64 bytes
//
// The constraint could be stored in the struct, but it would not pack
// efficiently so 2 variants are defined instead.
#define DEFINE_DRAW_IMAGE_RECT_OP(name, constraint) \
struct Draw##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kDraw##name; \
\
Draw##name##Op(const sk_sp<SkImage> image, \
const SkRect& src, \
const SkRect& dst, \
const SkSamplingOptions& sampling) \
: src(src), dst(dst), sampling(sampling), image(std::move(image)) {} \
\
const SkRect src; \
const SkRect dst; \
const SkSamplingOptions sampling; \
const sk_sp<SkImage> image; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawImageRect(image, src, dst, sampling, constraint); \
} \
};
DEFINE_DRAW_IMAGE_RECT_OP(ImageRectStrict, SkCanvas::kStrict_SrcRectConstraint)
DEFINE_DRAW_IMAGE_RECT_OP(ImageRectFast, SkCanvas::kFast_SrcRectConstraint)
#undef DEFINE_DRAW_IMAGE_RECT_OP
// 4 byte header + 44 byte payload packs efficiently into 48 bytes
struct DrawImageNineOp final : DLOp {
static const auto kType = DisplayListOpType::kDrawImageNine;
DrawImageNineOp(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter)
: center(center), dst(dst), filter(filter), image(std::move(image)) {}
const SkIRect center;
const SkRect dst;
const SkFilterMode filter;
const sk_sp<SkImage> image;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.drawImageNine(image, center, dst, filter);
}
};
#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes) \
struct name##Op final : DLOp { \
static const auto kType = DisplayListOpType::k##name; \
\
name##Op(const sk_sp<SkImage> image, \
const SkIRect& center, \
const SkRect& dst, \
SkFilterMode filter) \
: center(center), dst(dst), filter(filter), image(std::move(image)) {} \
\
const SkIRect center; \
const SkRect dst; \
const SkFilterMode filter; \
const sk_sp<SkImage> image; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawImageNine(image, center, dst, filter, \
render_with_attributes); \
} \
};
DEFINE_DRAW_IMAGE_NINE_OP(DrawImageNine, false)
DEFINE_DRAW_IMAGE_NINE_OP(DrawImageNineWithAttr, true)
#undef DEFINE_DRAW_IMAGE_NINE_OP
// 4 byte header + 60 byte payload packs evenly into 64 bytes
struct DrawImageLatticeOp final : DLOp {
@@ -667,82 +677,111 @@ struct DrawImageLatticeOp final : DLOp {
}
};
#define DRAW_ATLAS_NO_COLORS_ARRAY(tex, count) nullptr
#define DRAW_ATLAS_HAS_COLORS_ARRAY(tex, count) \
reinterpret_cast<const SkColor*>(tex + count)
#define DRAW_ATLAS_NO_CULLING_ARGS \
const sk_sp<SkImage> atlas, int count, SkBlendMode mode, \
const SkSamplingOptions &sampling
#define DRAW_ATLAS_NO_CULLING_INIT \
count(count), mode(mode), sampling(sampling), atlas(std::move(atlas))
#define DRAW_ATLAS_NO_CULLING_FIELDS \
const int count; \
const SkBlendMode mode; \
const SkSamplingOptions sampling; \
const sk_sp<SkImage> atlas
#define DRAW_ATLAS_NO_CULLING_P_ARG nullptr
#define DRAW_ATLAS_HAS_CULLING_ARGS \
DRAW_ATLAS_NO_CULLING_ARGS, const SkRect& cull
#define DRAW_ATLAS_HAS_CULLING_INIT DRAW_ATLAS_NO_CULLING_INIT, cull(cull)
#define DRAW_ATLAS_HAS_CULLING_FIELDS \
DRAW_ATLAS_NO_CULLING_FIELDS; \
const SkRect cull
#define DRAW_ATLAS_HAS_CULLING_P_ARG &cull
// 4 byte header + 36 byte common payload packs efficiently into 40 bytes
// Culling version has an additional 16 bytes of payload for 56 bytes
// So all 4 versions of the base structure pack well.
// Each of these is then followed by a number of lists.
// SkRSXform list is a multiple of 16 bytes so it is always packed well
// SkRect list is also a multiple of 16 bytes so it also packs well
// SkColor list only packs well if the count is even, otherwise there
// can be 4 unusued bytes at the end.
#define DEFINE_DRAW_ATLAS_OP(name, colors, cull) \
struct Draw##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kDraw##name; \
\
Draw##name##Op(DRAW_ATLAS_##cull##_ARGS) : DRAW_ATLAS_##cull##_INIT {} \
\
DRAW_ATLAS_##cull##_FIELDS; \
\
void dispatch(Dispatcher& dispatcher) const { \
const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(this + 1); \
const SkRect* tex = reinterpret_cast<const SkRect*>(xform + count); \
const SkColor* colors = DRAW_ATLAS_##colors##_ARRAY(tex, count); \
dispatcher.drawAtlas(atlas, xform, tex, colors, count, mode, sampling, \
DRAW_ATLAS_##cull##_P_ARG); \
} \
};
DEFINE_DRAW_ATLAS_OP(Atlas, NO_COLORS, NO_CULLING)
DEFINE_DRAW_ATLAS_OP(AtlasColored, HAS_COLORS, NO_CULLING)
DEFINE_DRAW_ATLAS_OP(AtlasCulled, NO_COLORS, HAS_CULLING)
DEFINE_DRAW_ATLAS_OP(AtlasColoredCulled, HAS_COLORS, HAS_CULLING)
#undef DEFINE_DRAW_ATLAS_OP
#undef DRAW_ATLAS_NO_COLORS_ARRAY
#undef DRAW_ATLAS_HAS_COLORS_ARRAY
#undef DRAW_ATLAS_NO_CULLING_ARGS
#undef DRAW_ATLAS_NO_CULLING_INIT
#undef DRAW_ATLAS_NO_CULLING_FIELDS
#undef DRAW_ATLAS_NO_CULLING_P_ARG
#undef DRAW_ATLAS_HAS_CULLING_ARGS
#undef DRAW_ATLAS_HAS_CULLING_INIT
#undef DRAW_ATLAS_HAS_CULLING_FIELDS
#undef DRAW_ATLAS_HAS_CULLING_P_ARG
struct DrawAtlasBaseOp : DLOp {
DrawAtlasBaseOp(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
bool has_colors,
bool render_with_attributes)
: count(count),
mode_index(static_cast<uint16_t>(mode)),
has_colors(has_colors),
render_with_attributes(render_with_attributes),
sampling(sampling),
atlas(std::move(atlas)) {}
const int count;
const uint16_t mode_index;
const uint8_t has_colors;
const uint8_t render_with_attributes;
const SkSamplingOptions sampling;
const sk_sp<SkImage> atlas;
};
// Packs as efficiently into 40 bytes as per DrawAtlasBaseOp
// with array data following the struct also as per DrawAtlasBaseOp
struct DrawAtlasOp final : DrawAtlasBaseOp {
static const auto kType = DisplayListOpType::kDrawAtlas;
DrawAtlasOp(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
bool has_colors,
bool render_with_attributes)
: DrawAtlasBaseOp(atlas,
count,
mode,
sampling,
has_colors,
render_with_attributes) {}
void dispatch(Dispatcher& dispatcher) const {
const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(this + 1);
const SkRect* tex = reinterpret_cast<const SkRect*>(xform + count);
const SkColor* colors =
has_colors ? reinterpret_cast<const SkColor*>(tex + count) : nullptr;
const SkBlendMode mode = static_cast<SkBlendMode>(mode_index);
dispatcher.drawAtlas(atlas, xform, tex, colors, count, mode, sampling,
nullptr, render_with_attributes);
}
};
// Packs efficiently into the same 40 bytes as DrawAtlasBaseOp plus
// an additional 16 bytes for the cull rect resulting in a total
// of 56 bytes for the Culled drawAtlas.
// Also with array data following the struct as per DrawAtlasBaseOp
struct DrawAtlasCulledOp final : DrawAtlasBaseOp {
static const auto kType = DisplayListOpType::kDrawAtlasCulled;
DrawAtlasCulledOp(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
bool has_colors,
const SkRect& cull_rect,
bool render_with_attributes)
: DrawAtlasBaseOp(atlas,
count,
mode,
sampling,
has_colors,
render_with_attributes),
cull_rect(cull_rect) {}
const SkRect cull_rect;
void dispatch(Dispatcher& dispatcher) const {
const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(this + 1);
const SkRect* tex = reinterpret_cast<const SkRect*>(xform + count);
const SkColor* colors =
has_colors ? reinterpret_cast<const SkColor*>(tex + count) : nullptr;
const SkBlendMode mode = static_cast<SkBlendMode>(mode_index);
dispatcher.drawAtlas(atlas, xform, tex, colors, count, mode, sampling,
&cull_rect, render_with_attributes);
}
};
// 4 byte header + 12 byte payload packs evenly into 16 bytes
struct DrawSkPictureOp final : DLOp {
static const auto kType = DisplayListOpType::kDrawSkPicture;
DrawSkPictureOp(sk_sp<SkPicture> picture, bool with_layer)
: with_layer(with_layer), picture(std::move(picture)) {}
DrawSkPictureOp(sk_sp<SkPicture> picture, bool render_with_attributes)
: render_with_attributes(render_with_attributes),
picture(std::move(picture)) {}
const bool with_layer;
const bool render_with_attributes;
const sk_sp<SkPicture> picture;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.drawPicture(picture, nullptr, with_layer);
dispatcher.drawPicture(picture, nullptr, render_with_attributes);
}
};
@@ -752,15 +791,17 @@ struct DrawSkPictureMatrixOp final : DLOp {
DrawSkPictureMatrixOp(sk_sp<SkPicture> picture,
const SkMatrix matrix,
bool with_layer)
: with_layer(with_layer), picture(std::move(picture)), matrix(matrix) {}
bool render_with_attributes)
: render_with_attributes(render_with_attributes),
picture(std::move(picture)),
matrix(matrix) {}
const bool with_layer;
const bool render_with_attributes;
const sk_sp<SkPicture> picture;
const SkMatrix matrix;
void dispatch(Dispatcher& dispatcher) const {
dispatcher.drawPicture(picture, &matrix, with_layer);
dispatcher.drawPicture(picture, &matrix, render_with_attributes);
}
};
@@ -797,27 +838,28 @@ struct DrawTextBlobOp final : DLOp {
};
// 4 byte header + 28 byte payload packs evenly into 32 bytes
#define DEFINE_DRAW_SHADOW_OP(name, nonoccluding) \
struct Draw##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kDraw##name; \
\
Draw##name##Op(const SkPath& path, \
SkColor color, \
SkScalar elevation, \
SkScalar dpr) \
: color(color), elevation(elevation), dpr(dpr), path(path) {} \
\
const SkColor color; \
const SkScalar elevation; \
const SkScalar dpr; \
const SkPath path; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawShadow(path, color, elevation, nonoccluding, dpr); \
} \
#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder) \
struct Draw##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kDraw##name; \
\
Draw##name##Op(const SkPath& path, \
SkColor color, \
SkScalar elevation, \
SkScalar dpr) \
: color(color), elevation(elevation), dpr(dpr), path(path) {} \
\
const SkColor color; \
const SkScalar elevation; \
const SkScalar dpr; \
const SkPath path; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawShadow(path, color, elevation, transparent_occluder, \
dpr); \
} \
};
DEFINE_DRAW_SHADOW_OP(Shadow, false)
DEFINE_DRAW_SHADOW_OP(NonOccludingShadow, true)
DEFINE_DRAW_SHADOW_OP(ShadowTransparentOccluder, true)
#undef DEFINE_DRAW_SHADOW_OP
#pragma pack(pop, DLOp_Alignment)
@@ -825,7 +867,7 @@ DEFINE_DRAW_SHADOW_OP(NonOccludingShadow, true)
void DisplayList::ComputeBounds() {
DisplayListBoundsCalculator calculator(&bounds_cull_);
Dispatch(calculator);
bounds_ = calculator.getBounds();
bounds_ = calculator.bounds();
}
void DisplayList::Dispatch(Dispatcher& dispatcher,
@@ -1037,8 +1079,8 @@ DisplayListBuilder::~DisplayListBuilder() {
}
}
void DisplayListBuilder::setAA(bool aa) {
Push<SetAAOp>(0, 0, aa);
void DisplayListBuilder::setAntiAlias(bool aa) {
Push<SetAntiAliasOp>(0, 0, aa);
}
void DisplayListBuilder::setDither(bool dither) {
Push<SetDitherOp>(0, 0, dither);
@@ -1046,20 +1088,20 @@ void DisplayListBuilder::setDither(bool dither) {
void DisplayListBuilder::setInvertColors(bool invert) {
Push<SetInvertColorsOp>(0, 0, invert);
}
void DisplayListBuilder::setCaps(SkPaint::Cap cap) {
Push<SetCapsOp>(0, 0, cap);
void DisplayListBuilder::setStrokeCap(SkPaint::Cap cap) {
Push<SetStrokeCapOp>(0, 0, cap);
}
void DisplayListBuilder::setJoins(SkPaint::Join join) {
Push<SetJoinsOp>(0, 0, join);
void DisplayListBuilder::setStrokeJoin(SkPaint::Join join) {
Push<SetStrokeJoinOp>(0, 0, join);
}
void DisplayListBuilder::setDrawStyle(SkPaint::Style style) {
Push<SetDrawStyleOp>(0, 0, style);
void DisplayListBuilder::setStyle(SkPaint::Style style) {
Push<SetStyleOp>(0, 0, style);
}
void DisplayListBuilder::setStrokeWidth(SkScalar width) {
Push<SetStrokeWidthOp>(0, 0, width);
}
void DisplayListBuilder::setMiterLimit(SkScalar limit) {
Push<SetMiterLimitOp>(0, 0, limit);
void DisplayListBuilder::setStrokeMiter(SkScalar limit) {
Push<SetStrokeMiterOp>(0, 0, limit);
}
void DisplayListBuilder::setColor(SkColor color) {
Push<SetColorOp>(0, 0, color);
@@ -1162,17 +1204,17 @@ void DisplayListBuilder::transform3x3(SkScalar mxx,
}
void DisplayListBuilder::clipRect(const SkRect& rect,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
clip_op == SkClipOp::kIntersect //
? Push<ClipIntersectRectOp>(0, 1, rect, is_aa)
: Push<ClipDifferenceRectOp>(0, 1, rect, is_aa);
}
void DisplayListBuilder::clipRRect(const SkRRect& rrect,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
if (rrect.isRect()) {
clipRect(rrect.rect(), is_aa, clip_op);
clipRect(rrect.rect(), clip_op, is_aa);
} else {
clip_op == SkClipOp::kIntersect //
? Push<ClipIntersectRRectOp>(0, 1, rrect, is_aa)
@@ -1180,22 +1222,22 @@ void DisplayListBuilder::clipRRect(const SkRRect& rrect,
}
}
void DisplayListBuilder::clipPath(const SkPath& path,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
if (!path.isInverseFillType()) {
SkRect rect;
if (path.isRect(&rect)) {
this->clipRect(rect, is_aa, clip_op);
this->clipRect(rect, clip_op, is_aa);
return;
}
SkRRect rrect;
if (path.isOval(&rect)) {
rrect.setOval(rect);
this->clipRRect(rrect, is_aa, clip_op);
this->clipRRect(rrect, clip_op, is_aa);
return;
}
if (path.isRRect(&rrect)) {
this->clipRRect(rrect, is_aa, clip_op);
this->clipRRect(rrect, clip_op, is_aa);
return;
}
}
@@ -1274,23 +1316,30 @@ void DisplayListBuilder::drawVertices(const sk_sp<SkVertices> vertices,
void DisplayListBuilder::drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) {
Push<DrawImageOp>(0, 1, std::move(image), point, sampling);
const SkSamplingOptions& sampling,
bool render_with_attributes) {
render_with_attributes
? Push<DrawImageWithAttrOp>(0, 1, std::move(image), point, sampling)
: Push<DrawImageOp>(0, 1, std::move(image), point, sampling);
}
void DisplayListBuilder::drawImageRect(const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) {
constraint == SkCanvas::kFast_SrcRectConstraint //
? Push<DrawImageRectFastOp>(0, 1, std::move(image), src, dst, sampling)
: Push<DrawImageRectStrictOp>(0, 1, std::move(image), src, dst, sampling);
Push<DrawImageRectOp>(0, 1, std::move(image), src, dst, sampling,
render_with_attributes, constraint);
}
void DisplayListBuilder::drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) {
Push<DrawImageNineOp>(0, 1, std::move(image), center, dst, filter);
SkFilterMode filter,
bool render_with_attributes) {
render_with_attributes
? Push<DrawImageNineWithAttrOp>(0, 1, std::move(image), center, dst,
filter)
: Push<DrawImageNineOp>(0, 1, std::move(image), center, dst, filter);
}
void DisplayListBuilder::drawImageLattice(const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
@@ -1320,26 +1369,29 @@ void DisplayListBuilder::drawAtlas(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) {
const SkRect* cull_rect,
bool render_with_attributes) {
int bytes = count * (sizeof(SkRSXform) + sizeof(SkRect));
void* data_ptr;
if (colors) {
if (colors != nullptr) {
bytes += count * sizeof(SkColor);
if (cullRect) {
data_ptr = Push<DrawAtlasColoredCulledOp>(
bytes, 1, std::move(atlas), count, mode, sampling, *cullRect);
if (cull_rect != nullptr) {
data_ptr = Push<DrawAtlasCulledOp>(bytes, 1, std::move(atlas), count,
mode, sampling, true, *cull_rect,
render_with_attributes);
} else {
data_ptr = Push<DrawAtlasColoredOp>(bytes, 1, std::move(atlas), count,
mode, sampling);
data_ptr = Push<DrawAtlasOp>(bytes, 1, std::move(atlas), count, mode,
sampling, true, render_with_attributes);
}
CopyV(data_ptr, xform, count, tex, count, colors, count);
} else {
if (cullRect) {
if (cull_rect != nullptr) {
data_ptr = Push<DrawAtlasCulledOp>(bytes, 1, std::move(atlas), count,
mode, sampling, *cullRect);
mode, sampling, false, *cull_rect,
render_with_attributes);
} else {
data_ptr =
Push<DrawAtlasOp>(bytes, 1, std::move(atlas), count, mode, sampling);
data_ptr = Push<DrawAtlasOp>(bytes, 1, std::move(atlas), count, mode,
sampling, false, render_with_attributes);
}
CopyV(data_ptr, xform, count, tex, count);
}
@@ -1347,11 +1399,11 @@ void DisplayListBuilder::drawAtlas(const sk_sp<SkImage> atlas,
void DisplayListBuilder::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_layer) {
bool render_with_attributes) {
matrix //
? Push<DrawSkPictureMatrixOp>(0, 1, std::move(picture), *matrix,
with_layer)
: Push<DrawSkPictureOp>(0, 1, std::move(picture), with_layer);
render_with_attributes)
: Push<DrawSkPictureOp>(0, 1, std::move(picture), render_with_attributes);
}
void DisplayListBuilder::drawDisplayList(
const sk_sp<DisplayList> display_list) {
@@ -1365,10 +1417,10 @@ void DisplayListBuilder::drawTextBlob(const sk_sp<SkTextBlob> blob,
void DisplayListBuilder::drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) {
transparentOccluder //
? Push<DrawNonOccludingShadowOp>(0, 1, path, color, elevation, dpr)
transparent_occluder //
? Push<DrawShadowTransparentOccluderOp>(0, 1, path, color, elevation, dpr)
: Push<DrawShadowOp>(0, 1, path, color, elevation, dpr);
}

View File

@@ -64,16 +64,16 @@
namespace flutter {
#define FOR_EACH_DISPLAY_LIST_OP(V) \
V(SetAA) \
V(SetAntiAlias) \
V(SetDither) \
V(SetInvertColors) \
\
V(SetCaps) \
V(SetJoins) \
V(SetStrokeCap) \
V(SetStrokeJoin) \
\
V(SetDrawStyle) \
V(SetStyle) \
V(SetStrokeWidth) \
V(SetMiterLimit) \
V(SetStrokeMiter) \
\
V(SetColor) \
V(SetBlendMode) \
@@ -133,14 +133,13 @@ namespace flutter {
V(DrawVertices) \
\
V(DrawImage) \
V(DrawImageRectStrict) \
V(DrawImageRectFast) \
V(DrawImageWithAttr) \
V(DrawImageRect) \
V(DrawImageNine) \
V(DrawImageNineWithAttr) \
V(DrawImageLattice) \
V(DrawAtlas) \
V(DrawAtlasColored) \
V(DrawAtlasCulled) \
V(DrawAtlasColoredCulled) \
\
V(DrawSkPicture) \
V(DrawSkPictureMatrix) \
@@ -148,7 +147,7 @@ namespace flutter {
V(DrawTextBlob) \
\
V(DrawShadow) \
V(DrawNonOccludingShadow)
V(DrawShadowTransparentOccluder)
#define DL_OP_TO_ENUM_VALUE(name) k##name,
enum class DisplayListOpType { FOR_EACH_DISPLAY_LIST_OP(DL_OP_TO_ENUM_VALUE) };
@@ -226,38 +225,63 @@ class Dispatcher {
// MaxDrawPointsCount * sizeof(SkPoint) must be less than 1 << 32
static constexpr int kMaxDrawPointsCount = ((1 << 29) - 1);
virtual void setAA(bool aa) = 0;
// The following methods are nearly 1:1 with the methods on SkPaint and
// carry the same meanings. Each method sets a persistent value for the
// attribute for the rest of the display list or until it is reset by
// another method that changes the same attribute. The current set of
// attributes is not affected by |save| and |restore|.
virtual void setAntiAlias(bool aa) = 0;
virtual void setDither(bool dither) = 0;
virtual void setInvertColors(bool invert) = 0;
virtual void setCaps(SkPaint::Cap cap) = 0;
virtual void setJoins(SkPaint::Join join) = 0;
virtual void setDrawStyle(SkPaint::Style style) = 0;
virtual void setStrokeWidth(SkScalar width) = 0;
virtual void setMiterLimit(SkScalar limit) = 0;
virtual void setStyle(SkPaint::Style style) = 0;
virtual void setColor(SkColor color) = 0;
virtual void setStrokeWidth(SkScalar width) = 0;
virtual void setStrokeMiter(SkScalar limit) = 0;
virtual void setStrokeCap(SkPaint::Cap cap) = 0;
virtual void setStrokeJoin(SkPaint::Join join) = 0;
virtual void setShader(sk_sp<SkShader> shader) = 0;
virtual void setColorFilter(sk_sp<SkColorFilter> filter) = 0;
// setInvertColors does not exist in SkPaint, but is a quick way to set
// a ColorFilter that inverts the rgb values of all rendered colors.
// It is not reset by |setColorFilter|, but instead composed with that
// filter so that the color inversion happens after the ColorFilter.
virtual void setInvertColors(bool invert) = 0;
virtual void setBlendMode(SkBlendMode mode) = 0;
virtual void setBlender(sk_sp<SkBlender> blender) = 0;
virtual void setShader(sk_sp<SkShader> shader) = 0;
virtual void setImageFilter(sk_sp<SkImageFilter> filter) = 0;
virtual void setColorFilter(sk_sp<SkColorFilter> filter) = 0;
virtual void setPathEffect(sk_sp<SkPathEffect> effect) = 0;
virtual void setMaskFilter(sk_sp<SkMaskFilter> filter) = 0;
// setMaskBlurFilter is a quick way to set the parameters for a
// mask blur filter without constructing an SkMaskFilter object.
// It is equivalent to setMaskFilter(SkMaskFilter::MakeBlur(style, sigma)).
// To reset the filter use setMaskFilter(nullptr).
virtual void setMaskBlurFilter(SkBlurStyle style, SkScalar sigma) = 0;
virtual void setImageFilter(sk_sp<SkImageFilter> filter) = 0;
// All of the following methods are nearly 1:1 with their counterparts
// in |SkCanvas| and have the same behavior and output.
virtual void save() = 0;
virtual void saveLayer(const SkRect* bounds, bool restoreWithPaint) = 0;
// The |restore_with_paint| parameter determines whether the existing
// rendering attributes will be applied to the save layer surface while
// rendering it back to the current surface. If the parameter is false
// then this method is equivalent to |SkCanvas::saveLayer| with a null
// paint object.
virtual void saveLayer(const SkRect* bounds, bool restore_with_paint) = 0;
virtual void restore() = 0;
virtual void translate(SkScalar tx, SkScalar ty) = 0;
virtual void scale(SkScalar sx, SkScalar sy) = 0;
virtual void rotate(SkScalar degrees) = 0;
virtual void skew(SkScalar sx, SkScalar sy) = 0;
// |transform2x3| is equivalent to concatenating an SkMatrix
// with only the upper 2x3 affine 2D parameters and the rest
// of the transformation parameters set to their identity values.
virtual void transform2x3(SkScalar mxx,
SkScalar mxy,
SkScalar mxt,
SkScalar myx,
SkScalar myy,
SkScalar myt) = 0;
// |transform3x3| is equivalent to concatenating an SkMatrix
// with no promises about the non-affine-2D parameters.
virtual void transform3x3(SkScalar mxx,
SkScalar mxy,
SkScalar mxt,
@@ -268,12 +292,21 @@ class Dispatcher {
SkScalar py,
SkScalar pt) = 0;
virtual void clipRect(const SkRect& rect, bool isAA, SkClipOp clip_op) = 0;
virtual void clipRRect(const SkRRect& rrect, bool isAA, SkClipOp clip_op) = 0;
virtual void clipPath(const SkPath& path, bool isAA, SkClipOp clip_op) = 0;
virtual void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) = 0;
virtual void clipRRect(const SkRRect& rrect,
SkClipOp clip_op,
bool is_aa) = 0;
virtual void clipPath(const SkPath& path, SkClipOp clip_op, bool is_aa) = 0;
virtual void drawPaint() = 0;
// The following rendering methods all take their rendering attributes
// from the last value set by the attribute methods above (regardless
// of any |save| or |restore| operations which do not affect attributes).
// In cases where a paint object may have been optional in the SkCanvas
// method, the methods here will generally offer a boolean parameter
// which specifies whether to honor the attributes of the display list
// stream, or assume default attributes.
virtual void drawColor(SkColor color, SkBlendMode mode) = 0;
virtual void drawPaint() = 0;
virtual void drawLine(const SkPoint& p0, const SkPoint& p1) = 0;
virtual void drawRect(const SkRect& rect) = 0;
virtual void drawOval(const SkRect& bounds) = 0;
@@ -281,32 +314,35 @@ class Dispatcher {
virtual void drawRRect(const SkRRect& rrect) = 0;
virtual void drawDRRect(const SkRRect& outer, const SkRRect& inner) = 0;
virtual void drawPath(const SkPath& path) = 0;
virtual void drawArc(const SkRect& bounds,
SkScalar start,
SkScalar sweep,
bool useCenter) = 0;
virtual void drawArc(const SkRect& oval_bounds,
SkScalar start_degrees,
SkScalar sweep_degrees,
bool use_center) = 0;
virtual void drawPoints(SkCanvas::PointMode mode,
uint32_t count,
const SkPoint pts[]) = 0;
const SkPoint points[]) = 0;
virtual void drawVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) = 0;
virtual void drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) = 0;
const SkSamplingOptions& sampling,
bool render_with_attributes) = 0;
virtual void drawImageRect(const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) = 0;
virtual void drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) = 0;
SkFilterMode filter,
bool render_with_attributes) = 0;
virtual void drawImageLattice(const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) = 0;
bool render_with_attributes) = 0;
virtual void drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -314,10 +350,11 @@ class Dispatcher {
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) = 0;
const SkRect* cull_rect,
bool render_with_attributes) = 0;
virtual void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_save_layer) = 0;
bool render_with_attributes) = 0;
virtual void drawDisplayList(const sk_sp<DisplayList> display_list) = 0;
virtual void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
@@ -325,12 +362,12 @@ class Dispatcher {
virtual void drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) = 0;
};
// The primary class used to build a display list. The list of methods
// here matches the list of methods invoked during dispatch().
// here matches the list of methods invoked on a |Dispatcher|.
// If there is some code that already renders to an SkCanvas object,
// those rendering commands can be captured into a DisplayList using
// the DisplayListCanvasRecorder class.
@@ -339,14 +376,14 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
DisplayListBuilder(const SkRect& cull = kMaxCull_);
~DisplayListBuilder();
void setAA(bool aa) override;
void setAntiAlias(bool aa) override;
void setDither(bool dither) override;
void setInvertColors(bool invert) override;
void setCaps(SkPaint::Cap cap) override;
void setJoins(SkPaint::Join join) override;
void setDrawStyle(SkPaint::Style style) override;
void setStrokeCap(SkPaint::Cap cap) override;
void setStrokeJoin(SkPaint::Join join) override;
void setStyle(SkPaint::Style style) override;
void setStrokeWidth(SkScalar width) override;
void setMiterLimit(SkScalar limit) override;
void setStrokeMiter(SkScalar limit) override;
void setColor(SkColor color) override;
void setBlendMode(SkBlendMode mode) override;
void setBlender(sk_sp<SkBlender> blender) override;
@@ -381,9 +418,9 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
SkScalar py,
SkScalar pt) override;
void clipRect(const SkRect& rect, bool isAA, SkClipOp clip_op) override;
void clipRRect(const SkRRect& rrect, bool isAA, SkClipOp clip_op) override;
void clipPath(const SkPath& path, bool isAA, SkClipOp clip_op) override;
void clipRect(const SkRect& rect, SkClipOp clip_op, bool isAA) override;
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool isAA) override;
void clipPath(const SkPath& path, SkClipOp clip_op, bool isAA) override;
void drawPaint() override;
void drawColor(SkColor color, SkBlendMode mode) override;
@@ -405,23 +442,26 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
SkBlendMode mode) override;
void drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) override;
const SkSamplingOptions& sampling,
bool render_with_attributes) override;
void drawImageRect(
const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint =
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint) override;
void drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) override;
SkFilterMode filter,
bool render_with_attributes) override;
void drawImageLattice(const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) override;
bool render_with_attributes) override;
void drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -429,10 +469,11 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) override;
const SkRect* cullRect,
bool render_with_attributes) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_save_layer) override;
bool render_with_attributes) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
@@ -440,7 +481,7 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
void drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) override;
sk_sp<DisplayList> Build();

View File

@@ -55,19 +55,19 @@ void DisplayListCanvasDispatcher::transform3x3(SkScalar mxx,
}
void DisplayListCanvasDispatcher::clipRect(const SkRect& rect,
bool isAA,
SkClipOp clip_op) {
canvas_->clipRect(rect, clip_op, isAA);
SkClipOp clip_op,
bool is_aa) {
canvas_->clipRect(rect, clip_op, is_aa);
}
void DisplayListCanvasDispatcher::clipRRect(const SkRRect& rrect,
bool isAA,
SkClipOp clip_op) {
canvas_->clipRRect(rrect, clip_op, isAA);
SkClipOp clip_op,
bool is_aa) {
canvas_->clipRRect(rrect, clip_op, is_aa);
}
void DisplayListCanvasDispatcher::clipPath(const SkPath& path,
bool isAA,
SkClipOp clip_op) {
canvas_->clipPath(path, clip_op, isAA);
SkClipOp clip_op,
bool is_aa) {
canvas_->clipPath(path, clip_op, is_aa);
}
void DisplayListCanvasDispatcher::drawPaint() {
@@ -117,31 +117,38 @@ void DisplayListCanvasDispatcher::drawVertices(const sk_sp<SkVertices> vertices,
}
void DisplayListCanvasDispatcher::drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) {
canvas_->drawImage(image, point.fX, point.fY, sampling, &paint());
const SkSamplingOptions& sampling,
bool render_with_attributes) {
canvas_->drawImage(image, point.fX, point.fY, sampling,
render_with_attributes ? &paint() : nullptr);
}
void DisplayListCanvasDispatcher::drawImageRect(
const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) {
canvas_->drawImageRect(image, src, dst, sampling, &paint(), constraint);
canvas_->drawImageRect(image, src, dst, sampling,
render_with_attributes ? &paint() : nullptr,
constraint);
}
void DisplayListCanvasDispatcher::drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) {
canvas_->drawImageNine(image.get(), center, dst, filter, &paint());
SkFilterMode filter,
bool render_with_attributes) {
canvas_->drawImageNine(image.get(), center, dst, filter,
render_with_attributes ? &paint() : nullptr);
}
void DisplayListCanvasDispatcher::drawImageLattice(
const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) {
bool render_with_attributes) {
canvas_->drawImageLattice(image.get(), lattice, dst, filter,
with_paint ? &paint() : nullptr);
render_with_attributes ? &paint() : nullptr);
}
void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
@@ -150,14 +157,16 @@ void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) {
const SkRect* cullRect,
bool render_with_attributes) {
canvas_->drawAtlas(atlas.get(), xform, tex, colors, count, mode, sampling,
cullRect, &paint());
cullRect, render_with_attributes ? &paint() : nullptr);
}
void DisplayListCanvasDispatcher::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_save_layer) {
canvas_->drawPicture(picture, matrix, with_save_layer ? &paint() : nullptr);
bool render_with_attributes) {
canvas_->drawPicture(picture, matrix,
render_with_attributes ? &paint() : nullptr);
}
void DisplayListCanvasDispatcher::drawDisplayList(
const sk_sp<DisplayList> display_list) {
@@ -176,10 +185,10 @@ void DisplayListCanvasDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
void DisplayListCanvasDispatcher::drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) {
flutter::PhysicalShapeLayer::DrawShadow(canvas_, path, color, elevation,
transparentOccluder, dpr);
transparent_occluder, dpr);
}
DisplayListCanvasRecorder::DisplayListCanvasRecorder(const SkRect& bounds)
@@ -210,21 +219,21 @@ void DisplayListCanvasRecorder::didScale(SkScalar sx, SkScalar sy) {
void DisplayListCanvasRecorder::onClipRect(const SkRect& rect,
SkClipOp clip_op,
ClipEdgeStyle edgeStyle) {
builder_->clipRect(rect, edgeStyle == ClipEdgeStyle::kSoft_ClipEdgeStyle,
clip_op);
ClipEdgeStyle edge_style) {
builder_->clipRect(rect, clip_op,
edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle);
}
void DisplayListCanvasRecorder::onClipRRect(const SkRRect& rrect,
SkClipOp clip_op,
ClipEdgeStyle edgeStyle) {
builder_->clipRRect(rrect, edgeStyle == ClipEdgeStyle::kSoft_ClipEdgeStyle,
clip_op);
ClipEdgeStyle edge_style) {
builder_->clipRRect(rrect, clip_op,
edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle);
}
void DisplayListCanvasRecorder::onClipPath(const SkPath& path,
SkClipOp clip_op,
ClipEdgeStyle edgeStyle) {
builder_->clipPath(path, edgeStyle == ClipEdgeStyle::kSoft_ClipEdgeStyle,
clip_op);
ClipEdgeStyle edge_style) {
builder_->clipPath(path, clip_op,
edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle);
}
void DisplayListCanvasRecorder::willSave() {
@@ -311,8 +320,11 @@ void DisplayListCanvasRecorder::onDrawImage2(const SkImage* image,
SkScalar dy,
const SkSamplingOptions& sampling,
const SkPaint* paint) {
RecordPaintAttributes(paint, DrawType::kImageOpType);
builder_->drawImage(sk_ref_sp(image), SkPoint::Make(dx, dy), sampling);
if (paint != nullptr) {
RecordPaintAttributes(paint, DrawType::kImageOpType);
}
builder_->drawImage(sk_ref_sp(image), SkPoint::Make(dx, dy), sampling,
paint != nullptr);
}
void DisplayListCanvasRecorder::onDrawImageRect2(
const SkImage* image,
@@ -321,8 +333,11 @@ void DisplayListCanvasRecorder::onDrawImageRect2(
const SkSamplingOptions& sampling,
const SkPaint* paint,
SrcRectConstraint constraint) {
RecordPaintAttributes(paint, DrawType::kImageRectOpType);
builder_->drawImageRect(sk_ref_sp(image), src, dst, sampling, constraint);
if (paint != nullptr) {
RecordPaintAttributes(paint, DrawType::kImageRectOpType);
}
builder_->drawImageRect(sk_ref_sp(image), src, dst, sampling,
paint != nullptr, constraint);
}
void DisplayListCanvasRecorder::onDrawImageLattice2(const SkImage* image,
const Lattice& lattice,
@@ -351,9 +366,11 @@ void DisplayListCanvasRecorder::onDrawAtlas2(const SkImage* image,
const SkSamplingOptions& sampling,
const SkRect* cull,
const SkPaint* paint) {
RecordPaintAttributes(paint, DrawType::kImageOpType);
if (paint != nullptr) {
RecordPaintAttributes(paint, DrawType::kImageOpType);
}
builder_->drawAtlas(sk_ref_sp(image), xform, src, colors, count, mode,
sampling, cull);
sampling, cull, paint != nullptr);
}
void DisplayListCanvasRecorder::onDrawTextBlob(const SkTextBlob* blob,
@@ -374,7 +391,7 @@ void DisplayListCanvasRecorder::onDrawShadowRec(const SkPath& path,
void DisplayListCanvasRecorder::onDrawPicture(const SkPicture* picture,
const SkMatrix* matrix,
const SkPaint* paint) {
if (paint) {
if (paint != nullptr) {
RecordPaintAttributes(paint, DrawType::kSaveLayerOpType);
}
builder_->drawPicture(sk_ref_sp(picture), matrix, paint != nullptr);
@@ -410,7 +427,7 @@ void DisplayListCanvasRecorder::RecordPaintAttributes(const SkPaint* paint,
paint = new SkPaint();
}
if ((dataNeeded & kAaNeeded_) != 0 && current_aa_ != paint->isAntiAlias()) {
builder_->setAA(current_aa_ = paint->isAntiAlias());
builder_->setAntiAlias(current_aa_ = paint->isAntiAlias());
}
if ((dataNeeded & kDitherNeeded_) != 0 &&
current_dither_ != paint->isDither()) {
@@ -444,7 +461,7 @@ void DisplayListCanvasRecorder::RecordPaintAttributes(const SkPaint* paint,
// }
if ((dataNeeded & kPaintStyleNeeded_) != 0) {
if (current_style_ != paint->getStyle()) {
builder_->setDrawStyle(current_style_ = paint->getStyle());
builder_->setStyle(current_style_ = paint->getStyle());
}
if (current_style_ == SkPaint::Style::kStroke_Style) {
dataNeeded |= kStrokeStyleNeeded_;
@@ -455,13 +472,13 @@ void DisplayListCanvasRecorder::RecordPaintAttributes(const SkPaint* paint,
builder_->setStrokeWidth(current_stroke_width_ = paint->getStrokeWidth());
}
if (current_cap_ != paint->getStrokeCap()) {
builder_->setCaps(current_cap_ = paint->getStrokeCap());
builder_->setStrokeCap(current_cap_ = paint->getStrokeCap());
}
if (current_join_ != paint->getStrokeJoin()) {
builder_->setJoins(current_join_ = paint->getStrokeJoin());
builder_->setStrokeJoin(current_join_ = paint->getStrokeJoin());
}
if (current_miter_limit_ != paint->getStrokeMiter()) {
builder_->setMiterLimit(current_miter_limit_ = paint->getStrokeMiter());
builder_->setStrokeMiter(current_miter_limit_ = paint->getStrokeMiter());
}
}
if ((dataNeeded & kShaderNeeded_) != 0 &&

View File

@@ -53,9 +53,9 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
SkScalar py,
SkScalar pt) override;
void clipRect(const SkRect& rect, bool isAA, SkClipOp clip_op) override;
void clipRRect(const SkRRect& rrect, bool isAA, SkClipOp clip_op) override;
void clipPath(const SkPath& path, bool isAA, SkClipOp clip_op) override;
void clipRect(const SkRect& rect, SkClipOp clip_op, bool isAA) override;
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool isAA) override;
void clipPath(const SkPath& path, SkClipOp clip_op, bool isAA) override;
void drawPaint() override;
void drawColor(SkColor color, SkBlendMode mode) override;
@@ -77,21 +77,24 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
SkBlendMode mode) override;
void drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) override;
const SkSamplingOptions& sampling,
bool render_with_attributes) override;
void drawImageRect(const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) override;
void drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) override;
SkFilterMode filter,
bool render_with_attributes) override;
void drawImageLattice(const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) override;
bool render_with_attributes) override;
void drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -99,10 +102,11 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) override;
const SkRect* cullRect,
bool render_with_attributes) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_save_layer) override;
bool render_with_attributes) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
@@ -110,7 +114,7 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
void drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) override;
private:

View File

@@ -367,7 +367,7 @@ class CanvasCompareTester {
},
[=](DisplayListBuilder& b) {
b.save();
b.clipRect(clip, false, SkClipOp::kIntersect);
b.clipRect(clip, SkClipOp::kIntersect, false);
b.drawRect(rect);
b.restore();
},
@@ -472,11 +472,11 @@ class CanvasCompareTester {
cv_renderer, dl_renderer, adjuster, tolerance, "Base Test");
RenderWith([=](SkCanvas*, SkPaint& p) { p.setAntiAlias(true); }, //
[=](DisplayListBuilder& b) { b.setAA(true); }, //
[=](DisplayListBuilder& b) { b.setAntiAlias(true); }, //
cv_renderer, dl_renderer, adjuster, tolerance,
"AntiAlias == True");
RenderWith([=](SkCanvas*, SkPaint& p) { p.setAntiAlias(false); }, //
[=](DisplayListBuilder& b) { b.setAA(false); }, //
[=](DisplayListBuilder& b) { b.setAntiAlias(false); }, //
cv_renderer, dl_renderer, adjuster, tolerance,
"AntiAlias == False");
@@ -649,7 +649,7 @@ class CanvasCompareTester {
b.setStrokeWidth(5.0);
// A Discrete(3, 5) effect produces miters that are near
// maximal for a miter limit of 3.0.
b.setMiterLimit(3.0);
b.setStrokeMiter(3.0);
b.setPathEffect(effect);
},
cv_renderer, dl_renderer, adjuster,
@@ -676,7 +676,7 @@ class CanvasCompareTester {
b.setStrokeWidth(5.0);
// A Discrete(2, 3) effect produces miters that are near
// maximal for a miter limit of 2.5.
b.setMiterLimit(2.5);
b.setStrokeMiter(2.5);
b.setPathEffect(effect);
},
cv_renderer, dl_renderer, adjuster,
@@ -766,13 +766,13 @@ class CanvasCompareTester {
// by a couple of pixels so we will relax bounds testing for strokes by
// a couple of pixels.
BoundsTolerance tolerance = tolerance_in.addBoundsPadding(2, 2);
RenderWith(
RenderWith( //
[=](SkCanvas*, SkPaint& p) { p.setStyle(SkPaint::kFill_Style); },
[=](DisplayListBuilder& b) { b.setDrawStyle(SkPaint::kFill_Style); },
[=](DisplayListBuilder& b) { b.setStyle(SkPaint::kFill_Style); },
cv_renderer, dl_renderer, adjuster, tolerance, "Fill");
RenderWith(
[=](SkCanvas*, SkPaint& p) { p.setStyle(SkPaint::kStroke_Style); },
[=](DisplayListBuilder& b) { b.setDrawStyle(SkPaint::kStroke_Style); },
[=](DisplayListBuilder& b) { b.setStyle(SkPaint::kStroke_Style); },
cv_renderer, dl_renderer, adjuster, tolerance, "Stroke + defaults");
RenderWith(
@@ -781,7 +781,7 @@ class CanvasCompareTester {
p.setStrokeWidth(10.0);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kFill_Style);
b.setStyle(SkPaint::kFill_Style);
b.setStrokeWidth(10.0);
},
cv_renderer, dl_renderer, adjuster, tolerance,
@@ -793,7 +793,7 @@ class CanvasCompareTester {
p.setStrokeWidth(10.0);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(10.0);
},
cv_renderer, dl_renderer, adjuster, tolerance, "Stroke Width 10");
@@ -803,7 +803,7 @@ class CanvasCompareTester {
p.setStrokeWidth(5.0);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
},
cv_renderer, dl_renderer, adjuster, tolerance, "Stroke Width 5");
@@ -815,9 +815,9 @@ class CanvasCompareTester {
p.setStrokeCap(SkPaint::kButt_Cap);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setCaps(SkPaint::kButt_Cap);
b.setStrokeCap(SkPaint::kButt_Cap);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Butt Cap");
@@ -828,9 +828,9 @@ class CanvasCompareTester {
p.setStrokeCap(SkPaint::kRound_Cap);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setCaps(SkPaint::kRound_Cap);
b.setStrokeCap(SkPaint::kRound_Cap);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Round Cap");
@@ -842,9 +842,9 @@ class CanvasCompareTester {
p.setStrokeJoin(SkPaint::kBevel_Join);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setJoins(SkPaint::kBevel_Join);
b.setStrokeJoin(SkPaint::kBevel_Join);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Bevel Join");
@@ -855,9 +855,9 @@ class CanvasCompareTester {
p.setStrokeJoin(SkPaint::kRound_Join);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setJoins(SkPaint::kRound_Join);
b.setStrokeJoin(SkPaint::kRound_Join);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Round Join");
@@ -873,13 +873,13 @@ class CanvasCompareTester {
p.setAntiAlias(true);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setMiterLimit(10.0);
b.setJoins(SkPaint::kMiter_Join);
b.setStrokeMiter(10.0);
b.setStrokeJoin(SkPaint::kMiter_Join);
// AA helps fill in the peaks of the really thin miters better
// for bounds accuracy testing
b.setAA(true);
b.setAntiAlias(true);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Miter 10");
@@ -892,10 +892,10 @@ class CanvasCompareTester {
p.setStrokeJoin(SkPaint::kMiter_Join);
},
[=](DisplayListBuilder& b) {
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
b.setStrokeWidth(5.0);
b.setMiterLimit(0.0);
b.setJoins(SkPaint::kMiter_Join);
b.setStrokeMiter(0.0);
b.setStrokeJoin(SkPaint::kMiter_Join);
},
cv_renderer, dl_renderer, adjuster, tolerance,
"Stroke Width 5, Miter 0");
@@ -915,7 +915,7 @@ class CanvasCompareTester {
},
[=](DisplayListBuilder& b) {
// Need stroke style to see dashing properly
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
// Provide some non-trivial stroke size to get dashed
b.setStrokeWidth(5.0);
b.setPathEffect(effect);
@@ -936,7 +936,7 @@ class CanvasCompareTester {
},
[=](DisplayListBuilder& b) {
// Need stroke style to see dashing properly
b.setDrawStyle(SkPaint::kStroke_Style);
b.setStyle(SkPaint::kStroke_Style);
// Provide some non-trivial stroke size to get dashed
b.setStrokeWidth(5.0);
b.setPathEffect(effect);
@@ -1012,7 +1012,7 @@ class CanvasCompareTester {
c->clipRect(r_clip, SkClipOp::kIntersect, false);
},
[=](DisplayListBuilder& b) {
b.clipRect(r_clip, false, SkClipOp::kIntersect);
b.clipRect(r_clip, SkClipOp::kIntersect, false);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"Hard ClipRect inset by 15.5");
@@ -1021,7 +1021,7 @@ class CanvasCompareTester {
c->clipRect(r_clip, SkClipOp::kIntersect, true);
},
[=](DisplayListBuilder& b) {
b.clipRect(r_clip, true, SkClipOp::kIntersect);
b.clipRect(r_clip, SkClipOp::kIntersect, true);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"AntiAlias ClipRect inset by 15.5");
@@ -1030,7 +1030,7 @@ class CanvasCompareTester {
c->clipRect(r_clip, SkClipOp::kDifference, false);
},
[=](DisplayListBuilder& b) {
b.clipRect(r_clip, false, SkClipOp::kDifference);
b.clipRect(r_clip, SkClipOp::kDifference, false);
},
cv_renderer, dl_renderer, diff_adjuster, diff_tolerance,
"Hard ClipRect Diff, inset by 15.5");
@@ -1040,7 +1040,7 @@ class CanvasCompareTester {
c->clipRRect(rr_clip, SkClipOp::kIntersect, false);
},
[=](DisplayListBuilder& b) {
b.clipRRect(rr_clip, false, SkClipOp::kIntersect);
b.clipRRect(rr_clip, SkClipOp::kIntersect, false);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"Hard ClipRRect inset by 15.5");
@@ -1049,7 +1049,7 @@ class CanvasCompareTester {
c->clipRRect(rr_clip, SkClipOp::kIntersect, true);
},
[=](DisplayListBuilder& b) {
b.clipRRect(rr_clip, true, SkClipOp::kIntersect);
b.clipRRect(rr_clip, SkClipOp::kIntersect, true);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"AntiAlias ClipRRect inset by 15.5");
@@ -1058,7 +1058,7 @@ class CanvasCompareTester {
c->clipRRect(rr_clip, SkClipOp::kDifference, false);
},
[=](DisplayListBuilder& b) {
b.clipRRect(rr_clip, false, SkClipOp::kDifference);
b.clipRRect(rr_clip, SkClipOp::kDifference, false);
},
cv_renderer, dl_renderer, diff_adjuster, diff_tolerance,
"Hard ClipRRect Diff, inset by 15.5");
@@ -1071,7 +1071,7 @@ class CanvasCompareTester {
c->clipPath(path_clip, SkClipOp::kIntersect, false);
},
[=](DisplayListBuilder& b) {
b.clipPath(path_clip, false, SkClipOp::kIntersect);
b.clipPath(path_clip, SkClipOp::kIntersect, false);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"Hard ClipPath inset by 15.5");
@@ -1080,7 +1080,7 @@ class CanvasCompareTester {
c->clipPath(path_clip, SkClipOp::kIntersect, true);
},
[=](DisplayListBuilder& b) {
b.clipPath(path_clip, true, SkClipOp::kIntersect);
b.clipPath(path_clip, SkClipOp::kIntersect, true);
},
cv_renderer, dl_renderer, intersect_adjuster, intersect_tolerance,
"AntiAlias ClipPath inset by 15.5");
@@ -1089,7 +1089,7 @@ class CanvasCompareTester {
c->clipPath(path_clip, SkClipOp::kDifference, false);
},
[=](DisplayListBuilder& b) {
b.clipPath(path_clip, false, SkClipOp::kDifference);
b.clipPath(path_clip, SkClipOp::kDifference, false);
},
cv_renderer, dl_renderer, diff_adjuster, diff_tolerance,
"Hard ClipPath Diff, inset by 15.5");
@@ -1872,7 +1872,20 @@ TEST(DisplayListCanvas, DrawImageNearest) {
[=](DisplayListBuilder& builder) { //
builder.drawImage(CanvasCompareTester::testImage,
SkPoint::Make(RenderLeft, RenderTop),
DisplayList::NearestSampling);
DisplayList::NearestSampling, true);
});
}
TEST(DisplayListCanvas, DrawImageNearestNoPaint) {
CanvasCompareTester::RenderAll(
[=](SkCanvas* canvas, SkPaint& paint) { //
canvas->drawImage(CanvasCompareTester::testImage, RenderLeft, RenderTop,
DisplayList::NearestSampling, nullptr);
},
[=](DisplayListBuilder& builder) { //
builder.drawImage(CanvasCompareTester::testImage,
SkPoint::Make(RenderLeft, RenderTop),
DisplayList::NearestSampling, false);
});
}
@@ -1885,7 +1898,7 @@ TEST(DisplayListCanvas, DrawImageLinear) {
[=](DisplayListBuilder& builder) { //
builder.drawImage(CanvasCompareTester::testImage,
SkPoint::Make(RenderLeft, RenderTop),
DisplayList::LinearSampling);
DisplayList::LinearSampling, true);
});
}
@@ -1900,7 +1913,22 @@ TEST(DisplayListCanvas, DrawImageRectNearest) {
},
[=](DisplayListBuilder& builder) { //
builder.drawImageRect(CanvasCompareTester::testImage, src, dst,
DisplayList::NearestSampling);
DisplayList::NearestSampling, true);
});
}
TEST(DisplayListCanvas, DrawImageRectNearestNoPaint) {
SkRect src = SkRect::MakeIWH(RenderWidth, RenderHeight).makeInset(5, 5);
SkRect dst = RenderBounds.makeInset(15.5, 10.5);
CanvasCompareTester::RenderAll(
[=](SkCanvas* canvas, SkPaint& paint) { //
canvas->drawImageRect(CanvasCompareTester::testImage, src, dst,
DisplayList::NearestSampling, nullptr,
SkCanvas::kFast_SrcRectConstraint);
},
[=](DisplayListBuilder& builder) { //
builder.drawImageRect(CanvasCompareTester::testImage, src, dst,
DisplayList::NearestSampling, false);
});
}
@@ -1915,7 +1943,7 @@ TEST(DisplayListCanvas, DrawImageRectLinear) {
},
[=](DisplayListBuilder& builder) { //
builder.drawImageRect(CanvasCompareTester::testImage, src, dst,
DisplayList::LinearSampling);
DisplayList::LinearSampling, true);
});
}
@@ -1929,7 +1957,21 @@ TEST(DisplayListCanvas, DrawImageNineNearest) {
},
[=](DisplayListBuilder& builder) { //
builder.drawImageNine(CanvasCompareTester::testImage, src, dst,
SkFilterMode::kNearest);
SkFilterMode::kNearest, true);
});
}
TEST(DisplayListCanvas, DrawImageNineNearestNoPaint) {
SkIRect src = SkIRect::MakeWH(RenderWidth, RenderHeight).makeInset(5, 5);
SkRect dst = RenderBounds.makeInset(15.5, 10.5);
CanvasCompareTester::RenderAll(
[=](SkCanvas* canvas, SkPaint& paint) { //
canvas->drawImageNine(CanvasCompareTester::testImage.get(), src, dst,
SkFilterMode::kNearest, nullptr);
},
[=](DisplayListBuilder& builder) { //
builder.drawImageNine(CanvasCompareTester::testImage, src, dst,
SkFilterMode::kNearest, false);
});
}
@@ -1943,7 +1985,7 @@ TEST(DisplayListCanvas, DrawImageNineLinear) {
},
[=](DisplayListBuilder& builder) { //
builder.drawImageNine(CanvasCompareTester::testImage, src, dst,
SkFilterMode::kLinear);
SkFilterMode::kLinear, true);
});
}
@@ -1973,6 +2015,32 @@ TEST(DisplayListCanvas, DrawImageLatticeNearest) {
});
}
TEST(DisplayListCanvas, DrawImageLatticeNearestNoPaint) {
const SkRect dst = RenderBounds.makeInset(15.5, 10.5);
const int divX[] = {
(RenderLeft + RenderCenterX) / 2,
RenderCenterX,
(RenderRight + RenderCenterX) / 2,
};
const int divY[] = {
(RenderTop + RenderCenterY) / 2,
RenderCenterY,
(RenderBottom + RenderCenterY) / 2,
};
SkCanvas::Lattice lattice = {
divX, divY, nullptr, 3, 3, nullptr, nullptr,
};
CanvasCompareTester::RenderAll(
[=](SkCanvas* canvas, SkPaint& paint) { //
canvas->drawImageLattice(CanvasCompareTester::testImage.get(), lattice,
dst, SkFilterMode::kNearest, nullptr);
},
[=](DisplayListBuilder& builder) { //
builder.drawImageLattice(CanvasCompareTester::testImage, lattice, //
dst, SkFilterMode::kNearest, false);
});
}
TEST(DisplayListCanvas, DrawImageLatticeLinear) {
const SkRect dst = RenderBounds.makeInset(15.5, 10.5);
const int divX[] = {
@@ -2032,7 +2100,44 @@ TEST(DisplayListCanvas, DrawAtlasNearest) {
[=](DisplayListBuilder& builder) {
builder.drawAtlas(image, xform, tex, colors, 4, //
SkBlendMode::kSrcOver, DisplayList::NearestSampling,
nullptr);
nullptr, true);
});
}
TEST(DisplayListCanvas, DrawAtlasNearestNoPaint) {
const SkRSXform xform[] = {
// clang-format off
{ 1.2f, 0.0f, RenderLeft, RenderTop},
{ 0.0f, 1.2f, RenderRight, RenderTop},
{-1.2f, 0.0f, RenderRight, RenderBottom},
{ 0.0f, -1.2f, RenderLeft, RenderBottom},
// clang-format on
};
const SkRect tex[] = {
// clang-format off
{0, 0, RenderHalfWidth, RenderHalfHeight},
{RenderHalfWidth, 0, RenderWidth, RenderHalfHeight},
{RenderHalfWidth, RenderHalfHeight, RenderWidth, RenderHeight},
{0, RenderHalfHeight, RenderHalfWidth, RenderHeight},
// clang-format on
};
const SkColor colors[] = {
SK_ColorBLUE,
SK_ColorGREEN,
SK_ColorYELLOW,
SK_ColorMAGENTA,
};
const sk_sp<SkImage> image = CanvasCompareTester::testImage;
CanvasCompareTester::RenderAtlas(
[=](SkCanvas* canvas, SkPaint& paint) {
canvas->drawAtlas(image.get(), xform, tex, colors, 4,
SkBlendMode::kSrcOver, DisplayList::NearestSampling,
nullptr, nullptr);
},
[=](DisplayListBuilder& builder) {
builder.drawAtlas(image, xform, tex, colors, 4, //
SkBlendMode::kSrcOver, DisplayList::NearestSampling,
nullptr, false);
});
}
@@ -2069,7 +2174,7 @@ TEST(DisplayListCanvas, DrawAtlasLinear) {
[=](DisplayListBuilder& builder) {
builder.drawAtlas(image, xform, tex, colors, 2, //
SkBlendMode::kSrcOver, DisplayList::LinearSampling,
nullptr);
nullptr, true);
});
}
@@ -2149,7 +2254,7 @@ TEST(DisplayListCanvas, DrawPictureWithPaint) {
TEST(DisplayListCanvas, DrawDisplayList) {
DisplayListBuilder builder;
builder.setDrawStyle(SkPaint::kFill_Style);
builder.setStyle(SkPaint::kFill_Style);
builder.setColor(SK_ColorBLUE);
builder.drawOval(RenderBounds);
sk_sp<DisplayList> display_list = builder.Build();
@@ -2227,7 +2332,7 @@ TEST(DisplayListCanvas, DrawShadow) {
CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
}
TEST(DisplayListCanvas, DrawNonOccludedShadow) {
TEST(DisplayListCanvas, DrawShadowTransparentOccluder) {
SkPath path;
path.addRoundRect(
{

View File

@@ -251,8 +251,8 @@ struct DisplayListInvocationGroup {
std::vector<DisplayListInvocationGroup> allGroups = {
{ "SetAA", {
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setAA(false);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setAA(true);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setAntiAlias(false);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setAntiAlias(true);}},
}
},
{ "SetDither", {
@@ -266,20 +266,20 @@ std::vector<DisplayListInvocationGroup> allGroups = {
}
},
{ "SetStrokeCap", {
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setCaps(SkPaint::kButt_Cap);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setCaps(SkPaint::kRound_Cap);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setCaps(SkPaint::kSquare_Cap);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeCap(SkPaint::kButt_Cap);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeCap(SkPaint::kRound_Cap);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeCap(SkPaint::kSquare_Cap);}},
}
},
{ "SetStrokeJoin", {
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setJoins(SkPaint::kBevel_Join);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setJoins(SkPaint::kRound_Join);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setJoins(SkPaint::kMiter_Join);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeJoin(SkPaint::kBevel_Join);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeJoin(SkPaint::kRound_Join);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeJoin(SkPaint::kMiter_Join);}},
}
},
{ "SetDrawStyle", {
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setDrawStyle(SkPaint::kFill_Style);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setDrawStyle(SkPaint::kStroke_Style);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStyle(SkPaint::kFill_Style);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStyle(SkPaint::kStroke_Style);}},
}
},
{ "SetStrokeWidth", {
@@ -288,8 +288,8 @@ std::vector<DisplayListInvocationGroup> allGroups = {
}
},
{ "SetMiterLimit", {
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setMiterLimit(0.0);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setMiterLimit(5.0);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeMiter(0.0);}},
{0, 8, 0, 0, [](DisplayListBuilder& b) {b.setStrokeMiter(5.0);}},
}
},
{ "SetColor", {
@@ -397,34 +397,34 @@ std::vector<DisplayListInvocationGroup> allGroups = {
}
},
{ "ClipRect", {
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, SkClipOp::kIntersect, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds.makeOffset(1, 1),
true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, false, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, true, SkClipOp::kDifference);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, false, SkClipOp::kDifference);}},
SkClipOp::kIntersect, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, SkClipOp::kIntersect, false);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, SkClipOp::kDifference, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipRect(TestBounds, SkClipOp::kDifference, false);}},
}
},
{ "ClipRRect", {
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, true, SkClipOp::kIntersect);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, SkClipOp::kIntersect, true);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect.makeOffset(1, 1),
true, SkClipOp::kIntersect);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, false, SkClipOp::kIntersect);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, true, SkClipOp::kDifference);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, false, SkClipOp::kDifference);}},
SkClipOp::kIntersect, true);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, SkClipOp::kIntersect, false);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, SkClipOp::kDifference, true);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipRRect(TestRRect, SkClipOp::kDifference, false);}},
}
},
{ "ClipPath", {
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath2, true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath3, true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, false, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, true, SkClipOp::kDifference);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, false, SkClipOp::kDifference);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, SkClipOp::kIntersect, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath2, SkClipOp::kIntersect, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath3, SkClipOp::kIntersect, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, SkClipOp::kIntersect, false);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, SkClipOp::kDifference, true);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPath1, SkClipOp::kDifference, false);}},
// clipPath(rect) becomes clipRect
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPathRect, true, SkClipOp::kIntersect);}},
{1, 24, 1, 24, [](DisplayListBuilder& b) {b.clipPath(TestPathRect, SkClipOp::kIntersect, true);}},
// clipPath(oval) becomes clipRRect
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipPath(TestPathOval, true, SkClipOp::kIntersect);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.clipPath(TestPathOval, SkClipOp::kIntersect, true);}},
}
},
{ "DrawPaint", {
@@ -520,41 +520,46 @@ std::vector<DisplayListInvocationGroup> allGroups = {
}
},
{ "DrawImage", {
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, DisplayList::NearestSampling);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {20, 10}, DisplayList::NearestSampling);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 20}, DisplayList::NearestSampling);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, DisplayList::LinearSampling);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage2, {10, 10}, DisplayList::NearestSampling);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, DisplayList::NearestSampling, false);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, DisplayList::NearestSampling, true);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {20, 10}, DisplayList::NearestSampling, false);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 20}, DisplayList::NearestSampling, false);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage1, {10, 10}, DisplayList::LinearSampling, false);}},
{1, 40, 1, 40, [](DisplayListBuilder& b) {b.drawImage(TestImage2, {10, 10}, DisplayList::NearestSampling, false);}},
}
},
{ "DrawImageRect", {
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling,
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling, false);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling, true);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling, false,
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
DisplayList::NearestSampling);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::LinearSampling);}},
{1, 64, 1, 64, [](DisplayListBuilder& b) {b.drawImageRect(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
DisplayList::NearestSampling);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
DisplayList::NearestSampling, false);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
DisplayList::NearestSampling, false);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
DisplayList::LinearSampling, false);}},
{1, 72, 1, 72, [](DisplayListBuilder& b) {b.drawImageRect(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
DisplayList::NearestSampling, false);}},
}
},
{ "DrawImageNine", {
// SkVanvas::drawImageNine is immediately converted to drawImageLattice
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
SkFilterMode::kNearest);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
SkFilterMode::kNearest);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
SkFilterMode::kNearest);}},
SkFilterMode::kNearest, false);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
SkFilterMode::kLinear);}},
SkFilterMode::kNearest, true);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
SkFilterMode::kNearest, false);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
SkFilterMode::kNearest, false);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
SkFilterMode::kLinear, false);}},
{1, 48, 1, 80, [](DisplayListBuilder& b) {b.drawImageNine(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
SkFilterMode::kNearest);}},
SkFilterMode::kNearest, false);}},
}
},
{ "DrawImageLattice", {
@@ -605,46 +610,51 @@ std::vector<DisplayListInvocationGroup> allGroups = {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, nullptr);}},
DisplayList::NearestSampling, nullptr, false);}},
{1, 40 + 32 + 32, 1, 40 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, nullptr, true);}},
{1, 40 + 32 + 32, 1, 40 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {0, 1, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, nullptr);}},
DisplayList::NearestSampling, nullptr, false);}},
{1, 40 + 32 + 32, 1, 40 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 25, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, nullptr);}},
DisplayList::NearestSampling, nullptr, false);}},
{1, 40 + 32 + 32, 1, 40 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::LinearSampling, nullptr);}},
DisplayList::LinearSampling, nullptr, false);}},
{1, 40 + 32 + 32, 1, 40 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
b.drawAtlas(TestImage1, xforms, texs, nullptr, 2, SkBlendMode::kDstIn,
DisplayList::NearestSampling, nullptr);}},
DisplayList::NearestSampling, nullptr, false);}},
{1, 56 + 32 + 32, 1, 56 + 32 + 32, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
static SkRect cullRect = { 0, 0, 200, 200 };
b.drawAtlas(TestImage2, xforms, texs, nullptr, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, &cullRect);}},
DisplayList::NearestSampling, &cullRect, false);}},
{1, 40 + 32 + 32 + 8, 1, 40 + 32 + 32 + 8, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
static SkColor colors[] = { SK_ColorBLUE, SK_ColorGREEN };
b.drawAtlas(TestImage1, xforms, texs, colors, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, nullptr);}},
DisplayList::NearestSampling, nullptr, false);}},
{1, 56 + 32 + 32 + 8, 1, 56 + 32 + 32 + 8, [](DisplayListBuilder& b) {
static SkRSXform xforms[] = { {1, 0, 0, 0}, {0, 1, 0, 0} };
static SkRect texs[] = { { 10, 10, 20, 20 }, {20, 20, 30, 30} };
static SkColor colors[] = { SK_ColorBLUE, SK_ColorGREEN };
static SkRect cullRect = { 0, 0, 200, 200 };
b.drawAtlas(TestImage1, xforms, texs, colors, 2, SkBlendMode::kSrcIn,
DisplayList::NearestSampling, &cullRect);}},
DisplayList::NearestSampling, &cullRect, false);}},
}
},
{ "DrawPicture", {

View File

@@ -26,7 +26,7 @@ constexpr float invert_color_matrix[20] = {
};
// clang-format on
void SkPaintDispatchHelper::setAA(bool aa) {
void SkPaintDispatchHelper::setAntiAlias(bool aa) {
paint_.setAntiAlias(aa);
}
void SkPaintDispatchHelper::setDither(bool dither) {
@@ -36,19 +36,19 @@ void SkPaintDispatchHelper::setInvertColors(bool invert) {
invert_colors_ = invert;
paint_.setColorFilter(makeColorFilter());
}
void SkPaintDispatchHelper::setCaps(SkPaint::Cap cap) {
void SkPaintDispatchHelper::setStrokeCap(SkPaint::Cap cap) {
paint_.setStrokeCap(cap);
}
void SkPaintDispatchHelper::setJoins(SkPaint::Join join) {
void SkPaintDispatchHelper::setStrokeJoin(SkPaint::Join join) {
paint_.setStrokeJoin(join);
}
void SkPaintDispatchHelper::setDrawStyle(SkPaint::Style style) {
void SkPaintDispatchHelper::setStyle(SkPaint::Style style) {
paint_.setStyle(style);
}
void SkPaintDispatchHelper::setStrokeWidth(SkScalar width) {
paint_.setStrokeWidth(width);
}
void SkPaintDispatchHelper::setMiterLimit(SkScalar limit) {
void SkPaintDispatchHelper::setStrokeMiter(SkScalar limit) {
paint_.setStrokeMiter(limit);
}
void SkPaintDispatchHelper::setColor(SkColor color) {
@@ -137,22 +137,22 @@ void SkMatrixDispatchHelper::reset() {
}
void ClipBoundsDispatchHelper::clipRect(const SkRect& rect,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
if (clip_op == SkClipOp::kIntersect) {
intersect(rect, is_aa);
}
}
void ClipBoundsDispatchHelper::clipRRect(const SkRRect& rrect,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
if (clip_op == SkClipOp::kIntersect) {
intersect(rrect.getBounds(), is_aa);
}
}
void ClipBoundsDispatchHelper::clipPath(const SkPath& path,
bool is_aa,
SkClipOp clip_op) {
SkClipOp clip_op,
bool is_aa) {
if (clip_op == SkClipOp::kIntersect) {
intersect(path.getBounds(), is_aa);
}
@@ -205,22 +205,22 @@ DisplayListBoundsCalculator::DisplayListBoundsCalculator(
const SkRect* cull_rect)
: ClipBoundsDispatchHelper(cull_rect) {
layer_infos_.emplace_back(std::make_unique<RootLayerData>());
accumulator_ = layer_infos_.back()->accumulatorForLayer();
accumulator_ = layer_infos_.back()->layer_accumulator();
}
void DisplayListBoundsCalculator::setCaps(SkPaint::Cap cap) {
void DisplayListBoundsCalculator::setStrokeCap(SkPaint::Cap cap) {
cap_is_square_ = (cap == SkPaint::kSquare_Cap);
}
void DisplayListBoundsCalculator::setJoins(SkPaint::Join join) {
void DisplayListBoundsCalculator::setStrokeJoin(SkPaint::Join join) {
join_is_miter_ = (join == SkPaint::kMiter_Join);
}
void DisplayListBoundsCalculator::setDrawStyle(SkPaint::Style style) {
void DisplayListBoundsCalculator::setStyle(SkPaint::Style style) {
style_flag_ = (style == SkPaint::kFill_Style) ? kIsFilledGeometry //
: kIsStrokedGeometry;
}
void DisplayListBoundsCalculator::setStrokeWidth(SkScalar width) {
half_stroke_width_ = std::max(width * 0.5f, kMinStrokeWidth);
}
void DisplayListBoundsCalculator::setMiterLimit(SkScalar limit) {
void DisplayListBoundsCalculator::setStrokeMiter(SkScalar limit) {
miter_limit_ = std::max(limit, 1.0f);
}
void DisplayListBoundsCalculator::setBlendMode(SkBlendMode mode) {
@@ -253,7 +253,7 @@ void DisplayListBoundsCalculator::save() {
SkMatrixDispatchHelper::save();
ClipBoundsDispatchHelper::save();
layer_infos_.emplace_back(std::make_unique<SaveData>(accumulator_));
accumulator_ = layer_infos_.back()->accumulatorForLayer();
accumulator_ = layer_infos_.back()->layer_accumulator();
}
void DisplayListBoundsCalculator::saveLayer(const SkRect* bounds,
bool with_paint) {
@@ -261,12 +261,12 @@ void DisplayListBoundsCalculator::saveLayer(const SkRect* bounds,
ClipBoundsDispatchHelper::save();
if (with_paint) {
layer_infos_.emplace_back(std::make_unique<SaveLayerData>(
accumulator_, image_filter_, paintNopsOnTransparenBlack()));
accumulator_, image_filter_, paint_nops_on_transparency()));
} else {
layer_infos_.emplace_back(
std::make_unique<SaveLayerData>(accumulator_, nullptr, true));
}
accumulator_ = layer_infos_.back()->accumulatorForLayer();
accumulator_ = layer_infos_.back()->layer_accumulator();
// Accumulate the layer in its own coordinate system and then
// filter and transform its bounds on restore.
SkMatrixDispatchHelper::reset();
@@ -276,8 +276,8 @@ void DisplayListBoundsCalculator::restore() {
if (layer_infos_.size() > 1) {
SkMatrixDispatchHelper::restore();
ClipBoundsDispatchHelper::restore();
accumulator_ = layer_infos_.back()->accumulatorForRestore();
SkRect layer_bounds = layer_infos_.back()->getLayerBounds();
accumulator_ = layer_infos_.back()->restore_accumulator();
SkRect layer_bounds = layer_infos_.back()->layer_bounds();
// Must read unbounded state after layer_bounds
bool layer_unbounded = layer_infos_.back()->is_unbounded();
layer_infos_.pop_back();
@@ -290,19 +290,19 @@ void DisplayListBoundsCalculator::restore() {
// modifications based on the attributes that were in place
// when it was instantiated. Modifying it further base on the
// current attributes would mix attribute states.
accumulateRect(layer_bounds, kIsUnfiltered);
AccumulateRect(layer_bounds, kIsUnfiltered);
}
if (layer_unbounded) {
accumulateUnbounded();
AccumulateUnbounded();
}
}
}
void DisplayListBoundsCalculator::drawPaint() {
accumulateUnbounded();
AccumulateUnbounded();
}
void DisplayListBoundsCalculator::drawColor(SkColor color, SkBlendMode mode) {
accumulateUnbounded();
AccumulateUnbounded();
}
void DisplayListBoundsCalculator::drawLine(const SkPoint& p0,
const SkPoint& p1) {
@@ -311,32 +311,32 @@ void DisplayListBoundsCalculator::drawLine(const SkPoint& p0,
if (bounds.width() > 0.0f && bounds.height() > 0.0f) {
cap_flag |= kGeometryMayHaveDiagonalEndCaps;
}
accumulateRect(bounds, cap_flag);
AccumulateRect(bounds, cap_flag);
}
void DisplayListBoundsCalculator::drawRect(const SkRect& rect) {
accumulateRect(rect, kIsDrawnGeometry);
AccumulateRect(rect, kIsDrawnGeometry);
}
void DisplayListBoundsCalculator::drawOval(const SkRect& bounds) {
accumulateRect(bounds, kIsDrawnGeometry);
AccumulateRect(bounds, kIsDrawnGeometry);
}
void DisplayListBoundsCalculator::drawCircle(const SkPoint& center,
SkScalar radius) {
accumulateRect(SkRect::MakeLTRB(center.fX - radius, center.fY - radius,
AccumulateRect(SkRect::MakeLTRB(center.fX - radius, center.fY - radius,
center.fX + radius, center.fY + radius),
kIsDrawnGeometry);
}
void DisplayListBoundsCalculator::drawRRect(const SkRRect& rrect) {
accumulateRect(rrect.getBounds(), kIsDrawnGeometry);
AccumulateRect(rrect.getBounds(), kIsDrawnGeometry);
}
void DisplayListBoundsCalculator::drawDRRect(const SkRRect& outer,
const SkRRect& inner) {
accumulateRect(outer.getBounds(), kIsDrawnGeometry);
AccumulateRect(outer.getBounds(), kIsDrawnGeometry);
}
void DisplayListBoundsCalculator::drawPath(const SkPath& path) {
if (path.isInverseFillType()) {
accumulateUnbounded();
AccumulateUnbounded();
} else {
accumulateRect(path.getBounds(), //
AccumulateRect(path.getBounds(), //
(kIsDrawnGeometry | //
kGeometryMayHaveDiagonalEndCaps | //
kGeometryMayHaveProblematicJoins));
@@ -349,7 +349,7 @@ void DisplayListBoundsCalculator::drawArc(const SkRect& bounds,
// This could be tighter if we compute where the start and end
// angles are and then also consider the quadrants swept and
// the center if specified.
accumulateRect(bounds, kIsDrawnGeometry | kGeometryMayHaveDiagonalEndCaps);
AccumulateRect(bounds, kIsDrawnGeometry | kGeometryMayHaveDiagonalEndCaps);
}
void DisplayListBoundsCalculator::drawPoints(SkCanvas::PointMode mode,
uint32_t count,
@@ -364,41 +364,50 @@ void DisplayListBoundsCalculator::drawPoints(SkCanvas::PointMode mode,
flags |= kGeometryMayHaveDiagonalEndCaps;
// Even Polygon mode just draws (count-1) separate lines, no joins
}
accumulateRect(ptBounds.getBounds(), flags);
AccumulateRect(ptBounds.bounds(), flags);
}
}
void DisplayListBoundsCalculator::drawVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
accumulateRect(vertices->bounds(), kIsNonGeometric);
AccumulateRect(vertices->bounds(), kIsNonGeometric);
}
void DisplayListBoundsCalculator::drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) {
const SkSamplingOptions& sampling,
bool render_with_attributes) {
SkRect bounds = SkRect::MakeXYWH(point.fX, point.fY, //
image->width(), image->height());
accumulateRect(bounds, kIsNonGeometric | kApplyMaskFilter);
int flags = render_with_attributes ? kIsNonGeometric | kApplyMaskFilter
: kIsUnfiltered;
AccumulateRect(bounds, flags);
}
void DisplayListBoundsCalculator::drawImageRect(
const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) {
accumulateRect(dst, kIsNonGeometric | kApplyMaskFilter);
int flags = render_with_attributes ? kIsNonGeometric | kApplyMaskFilter
: kIsUnfiltered;
AccumulateRect(dst, flags);
}
void DisplayListBoundsCalculator::drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) {
accumulateRect(dst, kIsNonGeometric);
SkFilterMode filter,
bool render_with_attributes) {
AccumulateRect(dst, render_with_attributes ? kIsNonGeometric : kIsUnfiltered);
}
void DisplayListBoundsCalculator::drawImageLattice(
const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) {
accumulateRect(dst, kIsNonGeometric | kApplyMaskFilter);
bool render_with_attributes) {
int flags = render_with_attributes ? kIsNonGeometric | kApplyMaskFilter
: kIsUnfiltered;
AccumulateRect(dst, flags);
}
void DisplayListBoundsCalculator::drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
@@ -407,7 +416,8 @@ void DisplayListBoundsCalculator::drawAtlas(const sk_sp<SkImage> atlas,
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) {
const SkRect* cullRect,
bool render_with_attributes) {
SkPoint quad[4];
BoundsAccumulator atlasBounds;
for (int i = 0; i < count; i++) {
@@ -417,13 +427,14 @@ void DisplayListBoundsCalculator::drawAtlas(const sk_sp<SkImage> atlas,
atlasBounds.accumulate(quad[j]);
}
}
if (atlasBounds.isNotEmpty()) {
accumulateRect(atlasBounds.getBounds(), kIsNonGeometric);
if (atlasBounds.is_not_empty()) {
int flags = render_with_attributes ? kIsNonGeometric : kIsUnfiltered;
AccumulateRect(atlasBounds.bounds(), flags);
}
}
void DisplayListBoundsCalculator::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* pic_matrix,
bool with_save_layer) {
bool render_with_attributes) {
// TODO(flar) cull rect really cannot be trusted in general, but it will
// work for SkPictures generated from our own PictureRecorder or any
// picture captured with an SkRTreeFactory or accurate bounds estimate.
@@ -431,29 +442,30 @@ void DisplayListBoundsCalculator::drawPicture(const sk_sp<SkPicture> picture,
if (pic_matrix) {
pic_matrix->mapRect(&bounds);
}
accumulateRect(bounds, with_save_layer ? kIsNonGeometric : kIsUnfiltered);
AccumulateRect(bounds,
render_with_attributes ? kIsNonGeometric : kIsUnfiltered);
}
void DisplayListBoundsCalculator::drawDisplayList(
const sk_sp<DisplayList> display_list) {
accumulateRect(display_list->bounds(), kIsUnfiltered);
AccumulateRect(display_list->bounds(), kIsUnfiltered);
}
void DisplayListBoundsCalculator::drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
SkScalar y) {
accumulateRect(blob->bounds().makeOffset(x, y), kIsFilledGeometry);
AccumulateRect(blob->bounds().makeOffset(x, y), kIsFilledGeometry);
}
void DisplayListBoundsCalculator::drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) {
SkRect shadow_bounds =
PhysicalShapeLayer::ComputeShadowBounds(path, elevation, dpr, matrix());
accumulateRect(shadow_bounds, kIsUnfiltered);
AccumulateRect(shadow_bounds, kIsUnfiltered);
}
bool DisplayListBoundsCalculator::getFilteredBounds(SkRect& bounds,
SkImageFilter* filter) {
bool DisplayListBoundsCalculator::ComputeFilteredBounds(SkRect& bounds,
SkImageFilter* filter) {
if (filter) {
if (!filter->canComputeFastBounds()) {
return false;
@@ -463,7 +475,7 @@ bool DisplayListBoundsCalculator::getFilteredBounds(SkRect& bounds,
return true;
}
bool DisplayListBoundsCalculator::adjustBoundsForPaint(SkRect& bounds,
bool DisplayListBoundsCalculator::AdjustBoundsForPaint(SkRect& bounds,
int flags) {
if ((flags & kIsUnfiltered) != 0) {
FML_DCHECK(flags == kIsUnfiltered);
@@ -534,28 +546,28 @@ bool DisplayListBoundsCalculator::adjustBoundsForPaint(SkRect& bounds,
}
}
return getFilteredBounds(bounds, image_filter_.get());
return ComputeFilteredBounds(bounds, image_filter_.get());
}
void DisplayListBoundsCalculator::accumulateUnbounded() {
void DisplayListBoundsCalculator::AccumulateUnbounded() {
if (has_clip()) {
accumulator_->accumulate(getClipBounds());
accumulator_->accumulate(clip_bounds());
} else {
layer_infos_.back()->set_unbounded();
}
}
void DisplayListBoundsCalculator::accumulateRect(SkRect& rect, int flags) {
if (adjustBoundsForPaint(rect, flags)) {
void DisplayListBoundsCalculator::AccumulateRect(SkRect& rect, int flags) {
if (AdjustBoundsForPaint(rect, flags)) {
matrix().mapRect(&rect);
if (!has_clip() || rect.intersect(getClipBounds())) {
if (!has_clip() || rect.intersect(clip_bounds())) {
accumulator_->accumulate(rect);
}
} else {
accumulateUnbounded();
AccumulateUnbounded();
}
}
bool DisplayListBoundsCalculator::paintNopsOnTransparenBlack() {
bool DisplayListBoundsCalculator::paint_nops_on_transparency() {
// SkImageFilter::canComputeFastBounds tests for transparency behavior
// This test assumes that the blend mode checked down below will
// NOP on transparent black.

View File

@@ -43,14 +43,14 @@ namespace flutter {
// to the setting of attributes.
class IgnoreAttributeDispatchHelper : public virtual Dispatcher {
public:
void setAA(bool aa) override {}
void setAntiAlias(bool aa) override {}
void setDither(bool dither) override {}
void setInvertColors(bool invert) override {}
void setCaps(SkPaint::Cap cap) override {}
void setJoins(SkPaint::Join join) override {}
void setDrawStyle(SkPaint::Style style) override {}
void setStrokeCap(SkPaint::Cap cap) override {}
void setStrokeJoin(SkPaint::Join join) override {}
void setStyle(SkPaint::Style style) override {}
void setStrokeWidth(SkScalar width) override {}
void setMiterLimit(SkScalar limit) override {}
void setStrokeMiter(SkScalar limit) override {}
void setColor(SkColor color) override {}
void setBlendMode(SkBlendMode mode) override {}
void setBlender(sk_sp<SkBlender> blender) override {}
@@ -65,9 +65,9 @@ class IgnoreAttributeDispatchHelper : public virtual Dispatcher {
// A utility class that will ignore all Dispatcher methods relating
// to setting a clip.
class IgnoreClipDispatchHelper : public virtual Dispatcher {
void clipRect(const SkRect& rect, bool isAA, SkClipOp clip_op) override {}
void clipRRect(const SkRRect& rrect, bool isAA, SkClipOp clip_op) override {}
void clipPath(const SkPath& path, bool isAA, SkClipOp clip_op) override {}
void clipRect(const SkRect& rect, SkClipOp clip_op, bool isAA) override {}
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool isAA) override {}
void clipPath(const SkPath& path, SkClipOp clip_op, bool isAA) override {}
};
// A utility class that will ignore all Dispatcher methods relating
@@ -100,23 +100,23 @@ class IgnoreTransformDispatchHelper : public virtual Dispatcher {
// which can be accessed at any time via paint().
class SkPaintDispatchHelper : public virtual Dispatcher {
public:
void setAA(bool aa) override;
void setAntiAlias(bool aa) override;
void setDither(bool dither) override;
void setInvertColors(bool invert) override;
void setCaps(SkPaint::Cap cap) override;
void setJoins(SkPaint::Join join) override;
void setDrawStyle(SkPaint::Style style) override;
void setStrokeWidth(SkScalar width) override;
void setMiterLimit(SkScalar limit) override;
void setStyle(SkPaint::Style style) override;
void setColor(SkColor color) override;
void setStrokeWidth(SkScalar width) override;
void setStrokeMiter(SkScalar limit) override;
void setStrokeCap(SkPaint::Cap cap) override;
void setStrokeJoin(SkPaint::Join join) override;
void setShader(sk_sp<SkShader> shader) override;
void setColorFilter(sk_sp<SkColorFilter> filter) override;
void setInvertColors(bool invert) override;
void setBlendMode(SkBlendMode mode) override;
void setBlender(sk_sp<SkBlender> blender) override;
void setShader(sk_sp<SkShader> shader) override;
void setImageFilter(sk_sp<SkImageFilter> filter) override;
void setColorFilter(sk_sp<SkColorFilter> filter) override;
void setPathEffect(sk_sp<SkPathEffect> effect) override;
void setMaskFilter(sk_sp<SkMaskFilter> filter) override;
void setMaskBlurFilter(SkBlurStyle style, SkScalar sigma) override;
void setImageFilter(sk_sp<SkImageFilter> filter) override;
const SkPaint& paint() { return paint_; }
@@ -135,7 +135,7 @@ class SkMatrixSource {
// A utility class that will monitor the Dispatcher methods relating
// to the transform and accumulate them into an SkMatrix which can
// be accessed at any time via getMatrix().
// be accessed at any time via matrix().
//
// This class also implements an appropriate stack of transforms via
// its save() and restore() methods so those methods will need to be
@@ -197,15 +197,15 @@ class ClipBoundsDispatchHelper : public virtual Dispatcher,
bounds_(cull_rect && !cull_rect->isEmpty() ? *cull_rect
: SkRect::MakeEmpty()) {}
void clipRect(const SkRect& rect, bool is_aa, SkClipOp clip_op) override;
void clipRRect(const SkRRect& rrect, bool is_aa, SkClipOp clip_op) override;
void clipPath(const SkPath& path, bool is_aa, SkClipOp clip_op) override;
void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) override;
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool is_aa) override;
void clipPath(const SkPath& path, SkClipOp clip_op, bool is_aa) override;
void save() override;
void restore() override;
bool has_clip() const { return has_clip_; }
const SkRect& getClipBounds() const { return bounds_; }
const SkRect& clip_bounds() const { return bounds_; }
protected:
void reset(const SkRect* cull_rect);
@@ -238,10 +238,10 @@ class BoundsAccumulator {
}
}
bool isEmpty() const { return min_x_ >= max_x_ || min_y_ >= max_y_; }
bool isNotEmpty() const { return min_x_ < max_x_ && min_y_ < max_y_; }
bool is_empty() const { return min_x_ >= max_x_ || min_y_ >= max_y_; }
bool is_not_empty() const { return min_x_ < max_x_ && min_y_ < max_y_; }
SkRect getBounds() const {
SkRect bounds() const {
return (max_x_ > min_x_ && max_y_ > min_y_)
? SkRect::MakeLTRB(min_x_, min_y_, max_x_, max_y_)
: SkRect::MakeEmpty();
@@ -273,11 +273,11 @@ class DisplayListBoundsCalculator final
// The flag should never be set if a cull_rect is provided.
DisplayListBoundsCalculator(const SkRect* cull_rect = nullptr);
void setCaps(SkPaint::Cap cap) override;
void setJoins(SkPaint::Join join) override;
void setDrawStyle(SkPaint::Style style) override;
void setStrokeCap(SkPaint::Cap cap) override;
void setStrokeJoin(SkPaint::Join join) override;
void setStyle(SkPaint::Style style) override;
void setStrokeWidth(SkScalar width) override;
void setMiterLimit(SkScalar limit) override;
void setStrokeMiter(SkScalar limit) override;
void setBlendMode(SkBlendMode mode) override;
void setBlender(sk_sp<SkBlender> blender) override;
void setImageFilter(sk_sp<SkImageFilter> filter) override;
@@ -310,21 +310,24 @@ class DisplayListBoundsCalculator final
SkBlendMode mode) override;
void drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling) override;
const SkSamplingOptions& sampling,
bool render_with_attributes) override;
void drawImageRect(const sk_sp<SkImage> image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) override;
void drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter) override;
SkFilterMode filter,
bool render_with_attributes) override;
void drawImageLattice(const sk_sp<SkImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
SkFilterMode filter,
bool with_paint) override;
bool render_with_attributes) override;
void drawAtlas(const sk_sp<SkImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -332,7 +335,8 @@ class DisplayListBoundsCalculator final
int count,
SkBlendMode mode,
const SkSamplingOptions& sampling,
const SkRect* cullRect) override;
const SkRect* cullRect,
bool render_with_attributes) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool with_save_layer) override;
@@ -343,7 +347,7 @@ class DisplayListBoundsCalculator final
void drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparentOccluder,
bool transparent_occluder,
SkScalar dpr) override;
// The DisplayList had an unbounded call with no cull rect or clip
@@ -355,17 +359,17 @@ class DisplayListBoundsCalculator final
// In those cases the bounds will represent only the accumulation
// of the bounded calls and this flag will be set to indicate that
// condition.
bool isUnbounded() const {
bool is_unbounded() const {
FML_DCHECK(layer_infos_.size() == 1);
return layer_infos_.front()->is_unbounded();
}
SkRect getBounds() const {
SkRect bounds() const {
FML_DCHECK(layer_infos_.size() == 1);
if (isUnbounded()) {
if (is_unbounded()) {
FML_LOG(INFO) << "returning partial bounds for unbounded DisplayList";
}
return accumulator_->getBounds();
return accumulator_->bounds();
}
private:
@@ -396,16 +400,16 @@ class DisplayListBoundsCalculator final
// The accumulator to use while this layer is put in play by
// a |save| or |saveLayer|
virtual BoundsAccumulator* accumulatorForLayer() { return outer_; }
virtual BoundsAccumulator* layer_accumulator() { return outer_; }
// The accumulator to use after this layer is removed from play
// via |restore|
virtual BoundsAccumulator* accumulatorForRestore() { return outer_; }
virtual BoundsAccumulator* restore_accumulator() { return outer_; }
// The bounds of this layer. May be empty for cases like
// a non-layer |save| call which uses the |outer_| accumulator
// to accumulate draw calls inside of it
virtual SkRect getLayerBounds() = 0;
virtual SkRect layer_bounds() = 0;
// is_unbounded should be set to true if we ever encounter an operation
// on a layer that either is unrestricted (|drawColor| or |drawPaint|)
@@ -449,16 +453,16 @@ class DisplayListBoundsCalculator final
// and |SaveLayerData|.
class AccumulatorLayerData : public LayerData {
public:
BoundsAccumulator* accumulatorForLayer() override {
BoundsAccumulator* layer_accumulator() override {
return &layer_accumulator_;
}
SkRect getLayerBounds() override {
SkRect layer_bounds() override {
// Even though this layer might be unbounded, we still
// accumulate what bounds we have as the unbounded condition
// may be contained at a higher level and we at least want to
// account for the bounds that we do have.
return layer_accumulator_.getBounds();
return layer_accumulator_.bounds();
}
protected:
@@ -485,7 +489,7 @@ class DisplayListBoundsCalculator final
using LayerData::LayerData;
~SaveData() = default;
SkRect getLayerBounds() override { return SkRect::MakeEmpty(); }
SkRect layer_bounds() override { return SkRect::MakeEmpty(); }
private:
FML_DISALLOW_COPY_AND_ASSIGN(SaveData);
@@ -504,9 +508,9 @@ class DisplayListBoundsCalculator final
}
~SaveLayerData() = default;
SkRect getLayerBounds() override {
SkRect bounds = AccumulatorLayerData::getLayerBounds();
if (!getFilteredBounds(bounds, layer_filter_.get())) {
SkRect layer_bounds() override {
SkRect bounds = AccumulatorLayerData::layer_bounds();
if (!ComputeFilteredBounds(bounds, layer_filter_.get())) {
set_unbounded();
}
return bounds;
@@ -590,17 +594,17 @@ class DisplayListBoundsCalculator final
sk_sp<SkMaskFilter> mask_filter_;
SkScalar mask_sigma_pad_ = 0.0;
bool paintNopsOnTransparenBlack();
bool paint_nops_on_transparency();
static bool getFilteredBounds(SkRect& rect, SkImageFilter* filter);
bool adjustBoundsForPaint(SkRect& bounds, int flags);
static bool ComputeFilteredBounds(SkRect& rect, SkImageFilter* filter);
bool AdjustBoundsForPaint(SkRect& bounds, int flags);
void accumulateUnbounded();
void accumulateRect(const SkRect& rect, int flags) {
void AccumulateUnbounded();
void AccumulateRect(const SkRect& rect, int flags) {
SkRect bounds = rect;
accumulateRect(bounds, flags);
AccumulateRect(bounds, flags);
}
void accumulateRect(SkRect& rect, int flags);
void AccumulateRect(SkRect& rect, int flags);
};
} // namespace flutter

View File

@@ -392,7 +392,7 @@ void Canvas::drawImageNine(const CanvasImage* image,
// simpler DrawImageNineOp record directly.
display_list_recorder_->RecordPaintAttributes(
paint.paint(), DisplayListCanvasRecorder::DrawType::kImageOpType);
builder()->drawImageNine(image->image(), icenter, dst, filter);
builder()->drawImageNine(image->image(), icenter, dst, filter, true);
} else {
canvas_->drawImageNine(image->image().get(), icenter, dst, filter,
paint.paint());