delete DL ops no longer needed after removing SkCanvasRecorder (flutter/engine#39863)

delete DL ops no longer needed after removing SkCanvasRecorder
This commit is contained in:
Jim Graham
2023-02-24 17:42:20 -08:00
committed by GitHub
parent fe2238aa8e
commit 7ac53d958d
27 changed files with 69 additions and 1016 deletions

View File

@@ -38,7 +38,7 @@
// Any class implementing Dispatcher can inherit from
// these utility classes to simplify its creation
//
// The Flutter DisplayList mechanism can be used in place of the Skia
// The Flutter DisplayList mechanism is used in a similar manner to the Skia
// SkPicture mechanism. The primary means of communication into and out
// of the DisplayList is through the Dispatcher virtual class which
// provides a nearly 1:1 translation between the records of the DisplayList
@@ -75,9 +75,6 @@ namespace flutter {
V(SetColor) \
V(SetBlendMode) \
\
V(SetBlender) \
V(ClearBlender) \
\
V(SetSkPathEffect) \
V(SetPodPathEffect) \
V(ClearPathEffect) \
@@ -139,19 +136,15 @@ namespace flutter {
V(DrawLines) \
V(DrawPolygon) \
V(DrawVertices) \
V(DrawSkVertices) \
\
V(DrawImage) \
V(DrawImageWithAttr) \
V(DrawImageRect) \
V(DrawImageNine) \
V(DrawImageNineWithAttr) \
V(DrawImageLattice) \
V(DrawAtlas) \
V(DrawAtlasCulled) \
\
V(DrawSkPicture) \
V(DrawSkPictureMatrix) \
V(DrawDisplayList) \
V(DrawTextBlob) \
\
@@ -258,9 +251,9 @@ class DisplayList : public SkRefCnt {
void RenderTo(SkCanvas* canvas, SkScalar opacity = SK_Scalar1) const;
// SkPicture always includes nested bytes, but nested ops are
// only included if requested. The defaults used here for these
// accessors follow that pattern.
// From historical behavior, SkPicture always included nested bytes,
// but nested ops are only included if requested. The defaults used
// here for these accessors follow that pattern.
size_t bytes(bool nested = true) const {
return sizeof(DisplayList) + byte_count_ +
(nested ? nested_byte_count_ : 0);

View File

@@ -13,17 +13,17 @@
namespace flutter {
namespace testing {
SkPaint GetPaintForRun(unsigned attributes) {
SkPaint paint;
DlPaint GetPaintForRun(unsigned attributes) {
DlPaint paint;
if (attributes & kStrokedStyle_Flag && attributes & kFilledStyle_Flag) {
// Not currently exposed by Flutter, but we can probably benchmark this in
// the future
paint.setStyle(SkPaint::kStrokeAndFill_Style);
paint.setDrawStyle(DlDrawStyle::kStrokeAndFill);
} else if (attributes & kStrokedStyle_Flag) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setDrawStyle(DlDrawStyle::kStroke);
} else if (attributes & kFilledStyle_Flag) {
paint.setStyle(SkPaint::kFill_Style);
paint.setDrawStyle(DlDrawStyle::kFill);
}
if (attributes & kHairlineStroke_Flag) {
@@ -76,7 +76,7 @@ void BM_DrawLine(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawLineFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawLineFlags);
@@ -114,7 +114,7 @@ void BM_DrawRect(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawRectFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawRectFlags);
@@ -163,7 +163,7 @@ void BM_DrawOval(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawOvalFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawOvalFlags);
@@ -209,7 +209,7 @@ void BM_DrawCircle(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawCircleFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawCircleFlags);
@@ -258,7 +258,7 @@ void BM_DrawRRect(benchmark::State& state,
SkRRect::Type type) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawRRectFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawRRectFlags);
@@ -339,7 +339,7 @@ void BM_DrawDRRect(benchmark::State& state,
SkRRect::Type type) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawDRRectFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawDRRectFlags);
@@ -413,7 +413,7 @@ void BM_DrawArc(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawArcNoCenterFlags);
AnnotateAttributes(attributes, state,
DisplayListOpFlags::kDrawArcNoCenterFlags);
@@ -629,7 +629,7 @@ void BM_DrawPath(benchmark::State& state,
SkPath::Verb type) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawPathFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawPathFlags);
@@ -767,7 +767,7 @@ void BM_DrawVertices(benchmark::State& state,
DlVertexMode mode) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawVerticesFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawVerticesFlags);
@@ -866,21 +866,21 @@ void BM_DrawPoints(benchmark::State& state,
SkPaint paint;
switch (mode) {
case DlCanvas::PointMode::kPoints:
builder.setAttributesFromPaint(
builder.SetAttributesFromPaint(
GetPaintForRun(attributes),
DisplayListOpFlags::kDrawPointsAsPointsFlags);
AnnotateAttributes(attributes, state,
DisplayListOpFlags::kDrawPointsAsPointsFlags);
break;
case DlCanvas::PointMode::kLines:
builder.setAttributesFromPaint(
builder.SetAttributesFromPaint(
GetPaintForRun(attributes),
DisplayListOpFlags::kDrawPointsAsLinesFlags);
AnnotateAttributes(attributes, state,
DisplayListOpFlags::kDrawPointsAsLinesFlags);
break;
case DlCanvas::PointMode::kPolygon:
builder.setAttributesFromPaint(
builder.SetAttributesFromPaint(
GetPaintForRun(attributes),
DisplayListOpFlags::kDrawPointsAsPolygonFlags);
AnnotateAttributes(attributes, state,
@@ -933,7 +933,7 @@ void BM_DrawImage(benchmark::State& state,
bool upload_bitmap) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawImageWithPaintFlags);
AnnotateAttributes(attributes, state,
DisplayListOpFlags::kDrawImageWithPaintFlags);
@@ -1016,7 +1016,7 @@ void BM_DrawImageRect(benchmark::State& state,
bool upload_bitmap) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(
builder.SetAttributesFromPaint(
GetPaintForRun(attributes),
DisplayListOpFlags::kDrawImageRectWithPaintFlags);
AnnotateAttributes(attributes, state,
@@ -1104,7 +1104,7 @@ void BM_DrawImageNine(benchmark::State& state,
bool upload_bitmap) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(
builder.SetAttributesFromPaint(
GetPaintForRun(attributes),
DisplayListOpFlags::kDrawImageNineWithPaintFlags);
AnnotateAttributes(attributes, state,
@@ -1181,7 +1181,7 @@ void BM_DrawTextBlob(benchmark::State& state,
unsigned attributes) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawTextBlobFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawTextBlobFlags);
@@ -1228,7 +1228,7 @@ void BM_DrawShadow(benchmark::State& state,
SkPath::Verb type) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kDrawShadowFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawShadowFlags);
@@ -1292,7 +1292,7 @@ void BM_SaveLayer(benchmark::State& state,
size_t save_depth) {
auto surface_provider = DlSurfaceProvider::Create(backend_type);
DisplayListBuilder builder;
builder.setAttributesFromPaint(GetPaintForRun(attributes),
builder.SetAttributesFromPaint(GetPaintForRun(attributes),
DisplayListOpFlags::kSaveLayerFlags);
AnnotateAttributes(attributes, state, DisplayListOpFlags::kSaveLayerFlags);

View File

@@ -28,7 +28,7 @@ enum BenchmarkAttributes {
kAntiAliasing_Flag = 1 << 3
};
SkPaint GetPaintForRun(unsigned attributes);
DlPaint GetPaintForRun(unsigned attributes);
using BackendType = DlSurfaceProvider::BackendType;

View File

@@ -5,7 +5,7 @@
#ifndef FLUTTER_DISPLAY_LIST_DISPLAY_LIST_BLEND_MODE_H_
#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_BLEND_MODE_H_
#include "include/core/SkBlender.h"
#include "include/core/SkBlendMode.h"
namespace flutter {

View File

@@ -145,29 +145,11 @@ void DisplayListBuilder::onSetColor(DlColor color) {
Push<SetColorOp>(0, 0, color);
}
void DisplayListBuilder::onSetBlendMode(DlBlendMode mode) {
current_blender_ = nullptr;
current_.setBlendMode(mode);
Push<SetBlendModeOp>(0, 0, mode);
UpdateCurrentOpacityCompatibility();
}
void DisplayListBuilder::onSetBlender(sk_sp<SkBlender> blender) {
// setBlender(nullptr) should be redirected to setBlendMode(SrcOver)
// by the set method, if not then the following is inefficient but works
FML_DCHECK(blender);
SkPaint p;
p.setBlender(blender);
if (p.asBlendMode()) {
setBlendMode(ToDl(p.asBlendMode().value()));
} else {
// |current_blender_| supersedes any value of |current_blend_mode_|
(current_blender_ = blender) //
? Push<SetBlenderOp>(0, 0, std::move(blender))
: Push<ClearBlenderOp>(0, 0);
UpdateCurrentOpacityCompatibility();
}
}
void DisplayListBuilder::onSetColorSource(const DlColorSource* source) {
if (source == nullptr) {
current_.setColorSource(nullptr);
@@ -364,7 +346,7 @@ void DisplayListBuilder::onSetMaskFilter(const DlMaskFilter* filter) {
}
}
void DisplayListBuilder::setAttributesFromDlPaint(
void DisplayListBuilder::SetAttributesFromPaint(
const DlPaint& paint,
const DisplayListAttributeFlags flags) {
if (flags.applies_anti_alias()) {
@@ -406,60 +388,6 @@ void DisplayListBuilder::setAttributesFromDlPaint(
}
}
void DisplayListBuilder::setAttributesFromPaint(
const SkPaint& paint,
const DisplayListAttributeFlags flags) {
if (flags.applies_anti_alias()) {
setAntiAlias(paint.isAntiAlias());
}
if (flags.applies_dither()) {
setDither(paint.isDither());
}
if (flags.applies_alpha_or_color()) {
setColor(paint.getColor());
}
if (flags.applies_blend()) {
std::optional<SkBlendMode> mode_optional = paint.asBlendMode();
if (mode_optional) {
setBlendMode(ToDl(mode_optional.value()));
} else {
setBlender(sk_ref_sp(paint.getBlender()));
}
}
if (flags.applies_style()) {
setStyle(ToDl(paint.getStyle()));
}
if (flags.is_stroked(ToDl(paint.getStyle()))) {
setStrokeWidth(paint.getStrokeWidth());
setStrokeMiter(paint.getStrokeMiter());
setStrokeCap(ToDl(paint.getStrokeCap()));
setStrokeJoin(ToDl(paint.getStrokeJoin()));
}
if (flags.applies_shader()) {
SkShader* shader = paint.getShader();
setColorSource(DlColorSource::From(shader).get());
}
if (flags.applies_color_filter()) {
// invert colors is a Flutter::Paint thing, not an SkPaint thing
// we must clear it because it is a second potential color filter
// that is composed with the paint's color filter.
setInvertColors(false);
SkColorFilter* color_filter = paint.getColorFilter();
setColorFilter(DlColorFilter::From(color_filter).get());
}
if (flags.applies_image_filter()) {
setImageFilter(DlImageFilter::From(paint.getImageFilter()).get());
}
if (flags.applies_path_effect()) {
SkPathEffect* path_effect = paint.getPathEffect();
setPathEffect(DlPathEffect::From(path_effect).get());
}
if (flags.applies_mask_filter()) {
SkMaskFilter* mask_filter = paint.getMaskFilter();
setMaskFilter(DlMaskFilter::From(mask_filter).get());
}
}
void DisplayListBuilder::checkForDeferredSave() {
if (current_layer_->has_deferred_save_op_) {
size_t save_offset_ = used_;
@@ -618,8 +546,8 @@ void DisplayListBuilder::SaveLayer(const SkRect* bounds,
const DlPaint* paint,
const DlImageFilter* backdrop) {
if (paint != nullptr) {
setAttributesFromDlPaint(*paint,
DisplayListOpFlags::kSaveLayerWithPaintFlags);
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kSaveLayerWithPaintFlags);
saveLayer(bounds, SaveLayerOptions::kWithAttributes, backdrop);
} else {
saveLayer(bounds, SaveLayerOptions::kNoAttributes, backdrop);
@@ -803,7 +731,7 @@ void DisplayListBuilder::drawPaint() {
AccumulateUnbounded();
}
void DisplayListBuilder::DrawPaint(const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawPaintFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPaintFlags);
drawPaint();
}
void DisplayListBuilder::DrawColor(DlColor color, DlBlendMode mode) {
@@ -823,7 +751,7 @@ void DisplayListBuilder::drawLine(const SkPoint& p0, const SkPoint& p1) {
void DisplayListBuilder::DrawLine(const SkPoint& p0,
const SkPoint& p1,
const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawLineFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawLineFlags);
drawLine(p0, p1);
}
void DisplayListBuilder::drawRect(const SkRect& rect) {
@@ -832,7 +760,7 @@ void DisplayListBuilder::drawRect(const SkRect& rect) {
AccumulateOpBounds(rect, kDrawRectFlags);
}
void DisplayListBuilder::DrawRect(const SkRect& rect, const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawRectFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawRectFlags);
drawRect(rect);
}
void DisplayListBuilder::drawOval(const SkRect& bounds) {
@@ -841,7 +769,7 @@ void DisplayListBuilder::drawOval(const SkRect& bounds) {
AccumulateOpBounds(bounds, kDrawOvalFlags);
}
void DisplayListBuilder::DrawOval(const SkRect& bounds, const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawOvalFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawOvalFlags);
drawOval(bounds);
}
void DisplayListBuilder::drawCircle(const SkPoint& center, SkScalar radius) {
@@ -854,7 +782,7 @@ void DisplayListBuilder::drawCircle(const SkPoint& center, SkScalar radius) {
void DisplayListBuilder::DrawCircle(const SkPoint& center,
SkScalar radius,
const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawCircleFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawCircleFlags);
drawCircle(center, radius);
}
void DisplayListBuilder::drawRRect(const SkRRect& rrect) {
@@ -869,7 +797,7 @@ void DisplayListBuilder::drawRRect(const SkRRect& rrect) {
}
}
void DisplayListBuilder::DrawRRect(const SkRRect& rrect, const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawRRectFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawRRectFlags);
drawRRect(rrect);
}
void DisplayListBuilder::drawDRRect(const SkRRect& outer,
@@ -881,7 +809,7 @@ void DisplayListBuilder::drawDRRect(const SkRRect& outer,
void DisplayListBuilder::DrawDRRect(const SkRRect& outer,
const SkRRect& inner,
const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawDRRectFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawDRRectFlags);
drawDRRect(outer, inner);
}
void DisplayListBuilder::drawPath(const SkPath& path) {
@@ -894,7 +822,7 @@ void DisplayListBuilder::drawPath(const SkPath& path) {
}
}
void DisplayListBuilder::DrawPath(const SkPath& path, const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawPathFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPathFlags);
drawPath(path);
}
@@ -921,7 +849,7 @@ void DisplayListBuilder::DrawArc(const SkRect& bounds,
SkScalar sweep,
bool useCenter,
const DlPaint& paint) {
setAttributesFromDlPaint(
SetAttributesFromPaint(
paint, useCenter ? kDrawArcWithCenterFlags : kDrawArcNoCenterFlags);
drawArc(bounds, start, sweep, useCenter);
}
@@ -984,19 +912,9 @@ void DisplayListBuilder::DrawPoints(PointMode mode,
FML_DCHECK(false);
return;
}
setAttributesFromDlPaint(paint, *flags);
SetAttributesFromPaint(paint, *flags);
drawPoints(mode, count, pts);
}
void DisplayListBuilder::drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
Push<DrawSkVerticesOp>(0, 1, vertices, mode);
// DrawVertices applies its colors to the paint so we have no way
// of controlling opacity using the current paint attributes.
// Although, examination of the |mode| might find some predictable
// cases.
UpdateLayerOpacityCompatibility(false);
AccumulateOpBounds(vertices->bounds(), kDrawVerticesFlags);
}
void DisplayListBuilder::drawVertices(const DlVertices* vertices,
DlBlendMode mode) {
void* pod = Push<DrawVerticesOp>(vertices->size(), 1, mode);
@@ -1011,7 +929,7 @@ void DisplayListBuilder::drawVertices(const DlVertices* vertices,
void DisplayListBuilder::DrawVertices(const DlVertices* vertices,
DlBlendMode mode,
const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawVerticesFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawVerticesFlags);
drawVertices(vertices, mode);
}
@@ -1035,8 +953,8 @@ void DisplayListBuilder::DrawImage(const sk_sp<DlImage>& image,
DlImageSampling sampling,
const DlPaint* paint) {
if (paint != nullptr) {
setAttributesFromDlPaint(*paint,
DisplayListOpFlags::kDrawImageWithPaintFlags);
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageWithPaintFlags);
drawImage(image, point, sampling, true);
} else {
drawImage(image, point, sampling, false);
@@ -1066,8 +984,8 @@ void DisplayListBuilder::DrawImageRect(const sk_sp<DlImage>& image,
enforce_src_edges ? SkCanvas::kStrict_SrcRectConstraint
: SkCanvas::kFast_SrcRectConstraint;
if (paint != nullptr) {
setAttributesFromDlPaint(*paint,
DisplayListOpFlags::kDrawImageRectWithPaintFlags);
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageRectWithPaintFlags);
drawImageRect(image, src, dst, sampling, true, constraint);
} else {
drawImageRect(image, src, dst, sampling, false, constraint);
@@ -1093,39 +1011,13 @@ void DisplayListBuilder::DrawImageNine(const sk_sp<DlImage>& image,
DlFilterMode filter,
const DlPaint* paint) {
if (paint != nullptr) {
setAttributesFromDlPaint(*paint,
DisplayListOpFlags::kDrawImageNineWithPaintFlags);
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawImageNineWithPaintFlags);
drawImageNine(image, center, dst, filter, true);
} else {
drawImageNine(image, center, dst, filter, false);
}
}
void DisplayListBuilder::drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
int x_div_count = lattice.fXCount;
int y_div_count = lattice.fYCount;
FML_DCHECK((lattice.fRectTypes == nullptr) || (lattice.fColors != nullptr));
int cell_count = lattice.fRectTypes && lattice.fColors
? (x_div_count + 1) * (y_div_count + 1)
: 0;
size_t bytes =
(x_div_count + y_div_count) * sizeof(int) +
cell_count * (sizeof(SkColor) + sizeof(SkCanvas::Lattice::RectType));
SkIRect src = lattice.fBounds ? *lattice.fBounds : image->bounds();
void* pod = this->Push<DrawImageLatticeOp>(bytes, 1, image, x_div_count,
y_div_count, cell_count, src, dst,
filter, render_with_attributes);
CopyV(pod, lattice.fXDivs, x_div_count, lattice.fYDivs, y_div_count,
lattice.fColors, cell_count, lattice.fRectTypes, cell_count);
CheckLayerOpacityCompatibility(render_with_attributes);
DisplayListAttributeFlags flags = render_with_attributes
? kDrawImageLatticeWithPaintFlags
: kDrawImageLatticeFlags;
AccumulateOpBounds(dst, flags);
}
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -1190,8 +1082,8 @@ void DisplayListBuilder::DrawAtlas(const sk_sp<DlImage>& atlas,
const SkRect* cull_rect,
const DlPaint* paint) {
if (paint != nullptr) {
setAttributesFromDlPaint(*paint,
DisplayListOpFlags::kDrawAtlasWithPaintFlags);
SetAttributesFromPaint(*paint,
DisplayListOpFlags::kDrawAtlasWithPaintFlags);
drawAtlas(atlas, xform, tex, colors, count, mode, sampling, cull_rect,
true);
} else {
@@ -1200,35 +1092,6 @@ void DisplayListBuilder::DrawAtlas(const sk_sp<DlImage>& atlas,
}
}
void DisplayListBuilder::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) {
matrix //
? Push<DrawSkPictureMatrixOp>(0, 1, picture, *matrix,
render_with_attributes)
: Push<DrawSkPictureOp>(0, 1, picture, 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.
SkRect bounds = picture->cullRect();
if (matrix) {
matrix->mapRect(&bounds);
}
DisplayListAttributeFlags flags = render_with_attributes //
? kDrawPictureWithPaintFlags
: kDrawPictureFlags;
AccumulateOpBounds(bounds, flags);
// The non-nested op count accumulated in the |Push| method will include
// this call to |drawPicture| for non-nested op count metrics.
// But, for nested op count metrics we want the |drawPicture| call itself
// to be transparent. So we subtract 1 from our accumulated nested count to
// balance out against the 1 that was accumulated into the regular count.
// This behavior is identical to the way SkPicture computes nested op counts.
nested_op_count_ += picture->approximateOpCount(true) - 1;
nested_bytes_ += picture->approximateBytesUsed();
CheckLayerOpacityCompatibility(render_with_attributes);
}
void DisplayListBuilder::DrawDisplayList(const sk_sp<DisplayList> display_list,
SkScalar opacity) {
DlPaint current_paint = current_;
@@ -1241,8 +1104,8 @@ void DisplayListBuilder::DrawDisplayList(const sk_sp<DisplayList> display_list,
// Not really necessary if the developer is interacting with us via
// our attribute-state-less DlCanvas methods, but this avoids surprises
// for those who may have been using the stateful Dispatcher methods.
setAttributesFromDlPaint(current_paint,
DisplayListOpFlags::kSaveLayerWithPaintFlags);
SetAttributesFromPaint(current_paint,
DisplayListOpFlags::kSaveLayerWithPaintFlags);
}
const SkRect bounds = display_list->bounds();
@@ -1269,7 +1132,7 @@ void DisplayListBuilder::DrawDisplayList(const sk_sp<DisplayList> display_list,
// But, for nested op count metrics we want the |drawDisplayList| call itself
// to be transparent. So we subtract 1 from our accumulated nested count to
// balance out against the 1 that was accumulated into the regular count.
// This behavior is identical to the way SkPicture computes nested op counts.
// This behavior is identical to the way SkPicture computed nested op counts.
nested_op_count_ += display_list->op_count(true) - 1;
nested_bytes_ += display_list->bytes(true);
UpdateLayerOpacityCompatibility(display_list->can_apply_group_opacity());
@@ -1285,7 +1148,7 @@ void DisplayListBuilder::DrawTextBlob(const sk_sp<SkTextBlob>& blob,
SkScalar x,
SkScalar y,
const DlPaint& paint) {
setAttributesFromDlPaint(paint, DisplayListOpFlags::kDrawTextBlobFlags);
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawTextBlobFlags);
drawTextBlob(blob, x, y);
}
void DisplayListBuilder::DrawShadow(const SkPath& path,
@@ -1411,15 +1274,12 @@ bool DisplayListBuilder::paint_nops_on_transparency() {
return false;
}
if (!getBlendMode()) {
return false; // can we query other blenders for this?
}
// Unusual blendmodes require us to process a saved layer
// even with operations outisde the clip.
// For example, DstIn is used by masking layers.
// https://code.google.com/p/skia/issues/detail?id=1291
// https://crbug.com/401593
switch (getBlendMode().value()) {
switch (getBlendMode()) {
// For each of the following transfer modes, if the source
// alpha is zero (our transparent black), the resulting
// blended pixel is not necessarily equal to the original

View File

@@ -92,17 +92,10 @@ class DisplayListBuilder final : public virtual DlCanvas,
}
}
void setBlendMode(DlBlendMode mode) override {
if (current_blender_ || current_.getBlendMode() != mode) {
if (current_.getBlendMode() != mode) {
onSetBlendMode(mode);
}
}
void setBlender(sk_sp<SkBlender> blender) override {
if (!blender) {
setBlendMode(DlBlendMode::kSrcOver);
} else if (current_blender_ != blender) {
onSetBlender(std::move(blender));
}
}
void setColorSource(const DlColorSource* source) override {
if (NotEquals(current_.getColorSource(), source)) {
onSetColorSource(source);
@@ -144,17 +137,7 @@ class DisplayListBuilder final : public virtual DlCanvas,
return current_.getColorFilter();
}
bool isInvertColors() const { return current_.isInvertColors(); }
std::optional<DlBlendMode> getBlendMode() const {
if (current_blender_) {
// The setters will turn "Mode" style blenders into "blend_mode"s
return {};
}
return current_.getBlendMode();
}
sk_sp<SkBlender> getBlender() const {
return current_blender_ ? current_blender_
: SkBlender::Mode(ToSk(current_.getBlendMode()));
}
DlBlendMode getBlendMode() const { return current_.getBlendMode(); }
std::shared_ptr<const DlPathEffect> getPathEffect() const {
return current_.getPathEffect();
}
@@ -200,7 +183,7 @@ class DisplayListBuilder final : public virtual DlCanvas,
void rotate(SkScalar degrees) override { Rotate(degrees); }
void skew(SkScalar sx, SkScalar sy) override { Skew(sx, sy); }
void setAttributesFromPaint(const SkPaint& paint,
void SetAttributesFromPaint(const DlPaint& paint,
const DisplayListAttributeFlags flags);
// clang-format off
@@ -329,8 +312,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
uint32_t count,
const SkPoint pts[],
const DlPaint& paint) override;
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override;
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
void drawVertices(const std::shared_ptr<const DlVertices> vertices,
DlBlendMode mode) {
@@ -372,11 +353,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
const SkRect& dst,
DlFilterMode filter,
const DlPaint* paint = nullptr) override;
void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -395,9 +371,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
DlImageSampling sampling,
const SkRect* cullRect,
const DlPaint* paint = nullptr) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override;
void DrawDisplayList(const sk_sp<DisplayList> display_list,
SkScalar opacity) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override {
@@ -443,8 +416,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
template <typename T, typename... Args>
void* Push(size_t extra, int op_inc, Args&&... args);
void setAttributesFromDlPaint(const DlPaint& paint,
const DisplayListAttributeFlags flags);
void intersect(const SkRect& rect);
// kInvalidSigma is used to indicate that no MaskBlur is currently set.
@@ -514,9 +485,10 @@ class DisplayListBuilder final : public virtual DlCanvas,
// that cull rect so that the overall unbounded state of the entire
// DisplayList will never be true.
//
// SkPicture treats these same conditions as a Nop (they accumulate
// the SkPicture cull rect, but if it was not specified then it is an
// empty Rect and so has no effect on the bounds).
// For historical consistency it is worth noting that SkPicture used
// to treat these same conditions as a Nop (they accumulate the
// SkPicture cull rect, but if no cull rect was specified then it is
// an empty Rect and so has no effect on the bounds).
//
// Flutter is unlikely to ever run into this as the Dart mechanisms
// all supply a non-null cull rect for all Dart Picture objects,
@@ -564,7 +536,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
current_opacity_compatibility_ = //
current_.getColorFilter() == nullptr && //
!current_.isInvertColors() && //
current_blender_ == nullptr && //
IsOpacityCompatible(current_.getBlendMode());
}
@@ -612,7 +583,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
void onSetStrokeMiter(SkScalar limit);
void onSetColor(DlColor color);
void onSetBlendMode(DlBlendMode mode);
void onSetBlender(sk_sp<SkBlender> blender);
void onSetColorSource(const DlColorSource* source);
void onSetImageFilter(const DlImageFilter* filter);
void onSetColorFilter(const DlColorFilter* filter);
@@ -683,8 +653,6 @@ class DisplayListBuilder final : public virtual DlCanvas,
void AccumulateBounds(SkRect& bounds);
DlPaint current_;
// If |current_blender_| is set then ignore |current_.getBlendMode()|
sk_sp<SkBlender> current_blender_;
};
} // namespace flutter

View File

@@ -188,11 +188,6 @@ void DisplayListCanvasDispatcher::drawPoints(PointMode mode,
const SkPoint pts[]) {
canvas_->drawPoints(ToSk(mode), count, pts, paint());
}
void DisplayListCanvasDispatcher::drawSkVertices(
const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
canvas_->drawVertices(vertices, mode, paint());
}
void DisplayListCanvasDispatcher::drawVertices(const DlVertices* vertices,
DlBlendMode mode) {
canvas_->drawVertices(vertices->skia_object(), ToSk(mode), paint());
@@ -230,22 +225,6 @@ void DisplayListCanvasDispatcher::drawImageNine(const sk_sp<DlImage> image,
canvas_->drawImageNine(skia_image.get(), center, dst, ToSk(filter),
safe_paint(render_with_attributes));
}
void DisplayListCanvasDispatcher::drawImageLattice(
const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
if (!image) {
return;
}
auto skia_image = image->skia_image();
if (!skia_image) {
return;
}
canvas_->drawImageLattice(skia_image.get(), lattice, dst, ToSk(filter),
safe_paint(render_with_attributes));
}
void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -267,18 +246,6 @@ void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
ToSk(sampling), cullRect,
safe_paint(render_with_attributes));
}
void DisplayListCanvasDispatcher::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) {
const SkPaint* paint = safe_paint(render_with_attributes);
if (paint) {
// drawPicture does an implicit saveLayer if an SkPaint is supplied.
TRACE_EVENT0("flutter", "Canvas::saveLayer");
canvas_->drawPicture(picture, matrix, paint);
} else {
canvas_->drawPicture(picture, matrix, nullptr);
}
}
void DisplayListCanvasDispatcher::drawDisplayList(
const sk_sp<DisplayList> display_list) {
int save_count = canvas_->save();

View File

@@ -71,8 +71,6 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
SkScalar sweep,
bool useCenter) override;
void drawPoints(PointMode mode, uint32_t count, const SkPoint pts[]) override;
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override;
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
void drawImage(const sk_sp<DlImage> image,
const SkPoint point,
@@ -89,11 +87,6 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -103,9 +96,6 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
DlImageSampling sampling,
const SkRect* cullRect,
bool render_with_attributes) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,

View File

@@ -15,7 +15,6 @@
#include "flutter/testing/testing.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/effects/SkBlenders.h"
#include "third_party/skia/include/effects/SkDashPathEffect.h"
#include "third_party/skia/include/effects/SkDiscretePathEffect.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -555,7 +554,7 @@ class TestParameters {
return false;
}
if (flags_.applies_blend() && //
ref_attr.getBlender() != attr.getBlender()) {
ref_attr.getBlendMode() != attr.getBlendMode()) {
return false;
}
if (flags_.applies_color_filter() && //
@@ -1308,28 +1307,6 @@ class CanvasCompareTester {
.with_bg(bg));
}
{
sk_sp<SkBlender> blender =
SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, false);
{
RenderWith(testP, env, tolerance,
CaseParameters(
"Blender == Arithmetic 0.25-false",
[=](SkCanvas*, SkPaint& p) { p.setBlender(blender); },
[=](DisplayListBuilder& b) { b.setBlender(blender); }));
}
EXPECT_TRUE(blender->unique()) << "Blender Cleanup";
blender = SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, true);
{
RenderWith(testP, env, tolerance,
CaseParameters(
"Blender == Arithmetic 0.25-true",
[=](SkCanvas*, SkPaint& p) { p.setBlender(blender); },
[=](DisplayListBuilder& b) { b.setBlender(blender); }));
}
EXPECT_TRUE(blender->unique()) << "Blender Cleanup";
}
{
// Being able to see a blur requires some non-default attributes,
// like a non-trivial stroke width and a shader rather than a color
@@ -3146,93 +3123,6 @@ TEST_F(DisplayListCanvas, DrawImageNineLinear) {
kDrawImageNineWithPaintFlags));
}
TEST_F(DisplayListCanvas, DrawImageLatticeNearest) {
const SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
const int div_x[] = {
kRenderWidth * 1 / 4,
kRenderWidth * 2 / 4,
kRenderWidth * 3 / 4,
};
const int div_y[] = {
kRenderHeight * 1 / 4,
kRenderHeight * 2 / 4,
kRenderHeight * 3 / 4,
};
SkCanvas::Lattice lattice = {
div_x, div_y, nullptr, 3, 3, nullptr, nullptr,
};
sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) {
canvas->drawImageLattice(image.get(), lattice, dst,
SkFilterMode::kNearest, &paint);
},
[=](DisplayListBuilder& builder) {
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
DlFilterMode::kNearest, true);
},
kDrawImageLatticeWithPaintFlags));
}
TEST_F(DisplayListCanvas, DrawImageLatticeNearestNoPaint) {
const SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
const int div_x[] = {
kRenderWidth * 1 / 4,
kRenderWidth * 2 / 4,
kRenderWidth * 3 / 4,
};
const int div_y[] = {
kRenderHeight * 1 / 4,
kRenderHeight * 2 / 4,
kRenderHeight * 3 / 4,
};
SkCanvas::Lattice lattice = {
div_x, div_y, nullptr, 3, 3, nullptr, nullptr,
};
sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) {
canvas->drawImageLattice(image.get(), lattice, dst,
SkFilterMode::kNearest, nullptr);
},
[=](DisplayListBuilder& builder) {
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
DlFilterMode::kNearest, false);
},
kDrawImageLatticeFlags));
}
TEST_F(DisplayListCanvas, DrawImageLatticeLinear) {
const SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
const int div_x[] = {
kRenderWidth / 4,
kRenderWidth / 2,
kRenderWidth * 3 / 4,
};
const int div_y[] = {
kRenderHeight / 4,
kRenderHeight / 2,
kRenderHeight * 3 / 4,
};
SkCanvas::Lattice lattice = {
div_x, div_y, nullptr, 3, 3, nullptr, nullptr,
};
sk_sp<SkImage> image = CanvasCompareTester::kTestImage;
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) {
canvas->drawImageLattice(image.get(), lattice, dst,
SkFilterMode::kLinear, &paint);
},
[=](DisplayListBuilder& builder) {
builder.drawImageLattice(DlImage::Make(image), lattice, dst,
DlFilterMode::kLinear, true);
},
kDrawImageLatticeWithPaintFlags));
}
TEST_F(DisplayListCanvas, DrawAtlasNearest) {
const SkRSXform xform[] = {
// clang-format off
@@ -3375,46 +3265,6 @@ sk_sp<SkPicture> makeTestPicture() {
return recorder.finishRecordingAsPicture();
}
TEST_F(DisplayListCanvas, DrawPicture) {
sk_sp<SkPicture> picture = makeTestPicture();
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) { //
canvas->drawPicture(picture, nullptr, nullptr);
},
[=](DisplayListBuilder& builder) { //
builder.drawPicture(picture, nullptr, false);
},
kDrawPictureFlags));
}
TEST_F(DisplayListCanvas, DrawPictureWithMatrix) {
sk_sp<SkPicture> picture = makeTestPicture();
SkMatrix matrix = SkMatrix::Scale(0.9, 0.9);
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) { //
canvas->drawPicture(picture, &matrix, nullptr);
},
[=](DisplayListBuilder& builder) { //
builder.drawPicture(picture, &matrix, false);
},
kDrawPictureFlags));
}
TEST_F(DisplayListCanvas, DrawPictureWithPaint) {
sk_sp<SkPicture> picture = makeTestPicture();
CanvasCompareTester::RenderAll( //
TestParameters(
[=](SkCanvas* canvas, const SkPaint& paint) { //
canvas->drawPicture(picture, nullptr, &paint);
},
[=](DisplayListBuilder& builder) { //
builder.drawPicture(picture, nullptr, true);
},
kDrawPictureWithPaintFlags));
}
sk_sp<DisplayList> makeTestDisplayList() {
DisplayListBuilder builder;
builder.setStyle(DlDrawStyle::kFill);

View File

@@ -483,34 +483,6 @@ void DisplayListGLComplexityCalculator::GLHelper::drawPoints(
AccumulateComplexity(complexity);
}
void DisplayListGLComplexityCalculator::GLHelper::drawSkVertices(
const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
// There is currently no way for us to get the VertexMode from the SkVertices
// object, but for future reference:
//
// TriangleStrip is roughly 25% more expensive than TriangleFan.
// TriangleFan is roughly 5% more expensive than Triangles.
// There is currently no way for us to get the vertex count from an SkVertices
// object, so we have to estimate it from the approximate size.
//
// Approximate size returns the sum of the sizes of the positions (SkPoint),
// texs (SkPoint), colors (SkColor) and indices (uint16_t) arrays multiplied
// by sizeof(type). As a very, very rough estimate, divide that by 20 to get
// an idea of the vertex count.
unsigned int approximate_vertex_count = vertices->approximateSize() / 20;
// For the baseline, it's hard to identify the trend. It might be O(n^1/2)
// For now, treat it as linear as an approximation.
//
// m = 1/1600
// c = 1
unsigned int complexity = (approximate_vertex_count + 1600) * 250 / 2;
AccumulateComplexity(complexity);
}
void DisplayListGLComplexityCalculator::GLHelper::drawVertices(
const DlVertices* vertices,
DlBlendMode mode) {

View File

@@ -55,7 +55,6 @@ class DisplayListGLComplexityCalculator
void drawPoints(DlCanvas::PointMode mode,
uint32_t count,
const SkPoint points[]) override;
void drawSkVertices(const sk_sp<SkVertices>, SkBlendMode mode) override;
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
void drawImage(const sk_sp<DlImage> image,
const SkPoint point,

View File

@@ -108,7 +108,6 @@ class ComplexityCalculatorHelper
void setStrokeMiter(SkScalar limit) override {}
void setColor(DlColor color) override {}
void setBlendMode(DlBlendMode mode) override {}
void setBlender(sk_sp<SkBlender> blender) override {}
void setColorSource(const DlColorSource* source) override {}
void setImageFilter(const DlImageFilter* filter) override {}
void setColorFilter(const DlColorFilter* filter) override {}
@@ -159,22 +158,6 @@ class ComplexityCalculatorHelper
render_with_attributes, constraint);
}
void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override {
if (IsComplex()) {
return;
}
// This is not currently called from Flutter code, and this API is likely
// to be removed in the future. For now, just return what drawImageNine
// would
ImageRect(image->dimensions(), image->isTextureBacked(),
render_with_attributes,
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint);
}
void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -196,14 +179,6 @@ class ComplexityCalculatorHelper
}
}
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override {
// This API shouldn't be used, but for now just take the
// approximateOpCount() and multiply by 50 as a placeholder.
AccumulateComplexity(picture->approximateOpCount() * 50);
}
// This method finalizes the complexity score calculation and returns it
unsigned int ComplexityScore() {
// We hit our ceiling, so return that

View File

@@ -435,34 +435,6 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawPoints(
AccumulateComplexity(complexity);
}
void DisplayListMetalComplexityCalculator::MetalHelper::drawSkVertices(
const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
// There is currently no way for us to get the VertexMode from the SkVertices
// object, but for future reference:
//
// TriangleStrip is roughly 25% more expensive than TriangleFan.
// TriangleFan is roughly 5% more expensive than Triangles.
// There is currently no way for us to get the vertex count from an SkVertices
// object, so we have to estimate it from the approximate size.
//
// Approximate size returns the sum of the sizes of the positions (SkPoint),
// texs (SkPoint), colors (SkColor) and indices (uint16_t) arrays multiplied
// by sizeof(type). As a very, very rough estimate, divide that by 20 to get
// an idea of the vertex count.
unsigned int approximate_vertex_count = vertices->approximateSize() / 20;
// For the baseline, it's hard to identify the trend. It might be O(n^1/2).
// For now, treat it as linear as an approximation.
//
// m = 1/4000
// c = 1
unsigned int complexity = (approximate_vertex_count + 4000) * 50;
AccumulateComplexity(complexity);
}
void DisplayListMetalComplexityCalculator::MetalHelper::drawVertices(
const DlVertices* vertices,
DlBlendMode mode) {

View File

@@ -55,8 +55,6 @@ class DisplayListMetalComplexityCalculator
void drawPoints(DlCanvas::PointMode mode,
uint32_t count,
const SkPoint points[]) override;
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override;
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
void drawImage(const sk_sp<DlImage> image,
const SkPoint point,

View File

@@ -58,7 +58,6 @@ class Dispatcher {
// filter so that the color inversion happens after the ColorFilter.
virtual void setInvertColors(bool invert) = 0;
virtual void setBlendMode(DlBlendMode mode) = 0;
virtual void setBlender(sk_sp<SkBlender> blender) = 0;
virtual void setPathEffect(const DlPathEffect* effect) = 0;
virtual void setMaskFilter(const DlMaskFilter* filter) = 0;
virtual void setImageFilter(const DlImageFilter* filter) = 0;
@@ -215,8 +214,6 @@ class Dispatcher {
virtual void drawPoints(PointMode mode,
uint32_t count,
const SkPoint points[]) = 0;
virtual void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) = 0;
virtual void drawVertices(const DlVertices* vertices, DlBlendMode mode) = 0;
virtual void drawImage(const sk_sp<DlImage> image,
const SkPoint point,
@@ -233,11 +230,6 @@ class Dispatcher {
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) = 0;
virtual void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) = 0;
virtual void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -247,9 +239,6 @@ class Dispatcher {
DlImageSampling sampling,
const SkRect* cull_rect,
bool render_with_attributes) = 0;
virtual void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
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,

View File

@@ -194,17 +194,17 @@ class DisplayListAttributeFlags : DisplayListFlagsBase {
// bool applies_stroke_attributes() const { return is_stroked(); }
constexpr bool applies_shader() const { return has_any(kUsesShader_); }
/// The primitive honors the current SkColorFilter, including
/// The primitive honors the current DlColorFilter, including
/// the related attribute InvertColors
constexpr bool applies_color_filter() const {
return has_any(kUsesColorFilter_);
}
/// The primitive honors the SkBlendMode or SkBlender
/// The primitive honors the DlBlendMode
constexpr bool applies_blend() const { return has_any(kUsesBlend_); }
constexpr bool applies_path_effect() const {
return has_any(kUsesPathEffect_);
}
/// The primitive honors the SkMaskFilter whether set using the
/// The primitive honors the DlMaskFilter whether set using the
/// filter object or using the convenience method |setMaskBlurFilter|
constexpr bool applies_mask_filter() const {
return has_any(kUsesMaskFilter_);
@@ -401,24 +401,12 @@ class DisplayListOpFlags : DisplayListFlags {
static constexpr DisplayListAttributeFlags kDrawImageNineWithPaintFlags{
kBASE_ImageFlags_ //
};
static constexpr DisplayListAttributeFlags kDrawImageLatticeFlags{
kIgnoresPaint_ //
};
static constexpr DisplayListAttributeFlags kDrawImageLatticeWithPaintFlags{
kBASE_ImageFlags_ //
};
static constexpr DisplayListAttributeFlags kDrawAtlasFlags{
kIgnoresPaint_ //
};
static constexpr DisplayListAttributeFlags kDrawAtlasWithPaintFlags{
kBASE_ImageFlags_ //
};
static constexpr DisplayListAttributeFlags kDrawPictureFlags{
kIgnoresPaint_ //
};
static constexpr DisplayListAttributeFlags kDrawPictureWithPaintFlags{
kSaveLayerWithPaintFlags //
};
static constexpr DisplayListAttributeFlags kDrawDisplayListFlags{
kIgnoresPaint_ //
};

View File

@@ -194,35 +194,6 @@ struct SetBlendModeOp final : DLOp {
}
};
// Clear: 4 byte header + unused 4 byte payload uses 8 bytes
// (4 bytes unused)
// Set: 4 byte header + an sk_sp (ptr) uses 16 bytes due to the
// alignment of the ptr.
// (4 bytes unused)
#define DEFINE_SET_CLEAR_SKREF_OP(name, field) \
struct Clear##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kClear##name; \
\
Clear##name##Op() {} \
\
void dispatch(DispatchContext& ctx) const { \
ctx.dispatcher.set##name(nullptr); \
} \
}; \
struct Set##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kSet##name; \
\
explicit Set##name##Op(sk_sp<Sk##name> field) : field(std::move(field)) {} \
\
sk_sp<Sk##name> field; \
\
void dispatch(DispatchContext& ctx) const { \
ctx.dispatcher.set##name(field); \
} \
};
DEFINE_SET_CLEAR_SKREF_OP(Blender, blender)
#undef DEFINE_SET_CLEAR_SKREF_OP
// Clear: 4 byte header + unused 4 byte payload uses 8 bytes
// (4 bytes unused)
// Set: 4 byte header + unused 4 byte struct padding + Dl<name>
@@ -841,23 +812,6 @@ struct DrawVerticesOp final : DrawOpBase {
}
};
// 4 byte header + 12 byte payload packs efficiently into 16 bytes
struct DrawSkVerticesOp final : DrawOpBase {
static const auto kType = DisplayListOpType::kDrawSkVertices;
DrawSkVerticesOp(sk_sp<SkVertices> vertices, SkBlendMode mode)
: mode(mode), vertices(std::move(vertices)) {}
const SkBlendMode mode;
const sk_sp<SkVertices> vertices;
void dispatch(DispatchContext& ctx) const {
if (op_needed(ctx)) {
ctx.dispatcher.drawSkVertices(vertices, mode);
}
}
};
// 4 byte header + 40 byte payload uses 44 bytes but is rounded up to 48 bytes
// (4 bytes unused)
#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
@@ -943,55 +897,6 @@ 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 : DrawOpBase {
static const auto kType = DisplayListOpType::kDrawImageLattice;
DrawImageLatticeOp(const sk_sp<DlImage> image,
int x_count,
int y_count,
int cell_count,
const SkIRect& src,
const SkRect& dst,
DlFilterMode filter,
bool with_paint)
: with_paint(with_paint),
x_count(x_count),
y_count(y_count),
cell_count(cell_count),
filter(filter),
src(src),
dst(dst),
image(std::move(image)) {}
const bool with_paint;
const int x_count;
const int y_count;
const int cell_count;
const DlFilterMode filter;
const SkIRect src;
const SkRect dst;
const sk_sp<DlImage> image;
void dispatch(DispatchContext& ctx) const {
if (op_needed(ctx)) {
const int* xDivs = reinterpret_cast<const int*>(this + 1);
const int* yDivs = reinterpret_cast<const int*>(xDivs + x_count);
const SkColor* colors =
(cell_count == 0) ? nullptr
: reinterpret_cast<const SkColor*>(yDivs + y_count);
const SkCanvas::Lattice::RectType* types =
(cell_count == 0)
? nullptr
: reinterpret_cast<const SkCanvas::Lattice::RectType*>(
colors + cell_count);
ctx.dispatcher.drawImageLattice(
image, {xDivs, yDivs, types, x_count, y_count, &src, colors}, dst,
filter, with_paint);
}
}
};
// 4 byte header + 40 byte payload uses 44 bytes but is rounded up to 48 bytes
// (4 bytes unused)
// Each of these is then followed by a number of lists.
@@ -1089,53 +994,6 @@ struct DrawAtlasCulledOp final : DrawAtlasBaseOp {
}
};
// 4 byte header + 12 byte payload packs evenly into 16 bytes
struct DrawSkPictureOp final : DrawOpBase {
static const auto kType = DisplayListOpType::kDrawSkPicture;
DrawSkPictureOp(sk_sp<SkPicture> picture, bool render_with_attributes)
: render_with_attributes(render_with_attributes),
picture(std::move(picture)) {}
const bool render_with_attributes;
const sk_sp<SkPicture> picture;
void dispatch(DispatchContext& ctx) const {
if (op_needed(ctx)) {
ctx.dispatcher.drawPicture(picture, nullptr, render_with_attributes);
}
}
};
// 4 byte header + 52 byte payload packs evenly into 56 bytes
struct DrawSkPictureMatrixOp final : DrawOpBase {
static const auto kType = DisplayListOpType::kDrawSkPictureMatrix;
DrawSkPictureMatrixOp(sk_sp<SkPicture> picture,
const SkMatrix& matrix,
bool render_with_attributes)
: render_with_attributes(render_with_attributes),
picture(std::move(picture)),
matrix(matrix) {
// The copy constructor might copy in an unknown or a resolved
// type depending on whether the source Matrix had been used
// since its last mutating method. Calling getType here forces
// the matrix object into a known state so that it can be bulk
// compared without having to introduce a custom equals() method.
this->matrix.getType();
}
const bool render_with_attributes;
const sk_sp<SkPicture> picture;
const SkMatrix matrix;
void dispatch(DispatchContext& ctx) const {
if (op_needed(ctx)) {
ctx.dispatcher.drawPicture(picture, &matrix, render_with_attributes);
}
}
};
// 4 byte header + ptr aligned payload uses 12 bytes round up to 16
// (4 bytes unused)
struct DrawDisplayListOp final : DrawOpBase {

View File

@@ -20,6 +20,7 @@
#include "flutter/testing/display_list_testing.h"
#include "flutter/testing/testing.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace flutter {
@@ -230,7 +231,6 @@ TEST(DisplayList, FullRotationsAreNop) {
TEST(DisplayList, AllBlendModeNops) {
DisplayListBuilder builder;
builder.setBlendMode(DlBlendMode::kSrcOver);
builder.setBlender(nullptr);
sk_sp<DisplayList> dl = builder.Build();
ASSERT_EQ(dl->bytes(false), sizeof(DisplayList));
ASSERT_EQ(dl->bytes(true), sizeof(DisplayList));
@@ -499,57 +499,6 @@ TEST(DisplayList, NestedOpCountMetricsSameAsSkPicture) {
static_cast<int>(display_list->op_count(true)));
}
class AttributeRefTester {
public:
virtual void setRefToPaint(SkPaint& paint) const = 0;
virtual void setRefToDisplayList(DisplayListBuilder& builder) const = 0;
virtual bool ref_is_unique() const = 0;
void testDisplayList() {
{
DisplayListBuilder builder;
setRefToDisplayList(builder);
builder.drawRect(SkRect::MakeLTRB(50, 50, 100, 100));
ASSERT_FALSE(ref_is_unique());
}
ASSERT_TRUE(ref_is_unique());
}
void testPaint() {
{
SkPaint paint;
setRefToPaint(paint);
ASSERT_FALSE(ref_is_unique());
}
ASSERT_TRUE(ref_is_unique());
}
void test() {
testDisplayList();
testPaint();
}
};
TEST(DisplayList, DisplayListBlenderRefHandling) {
class BlenderRefTester : public virtual AttributeRefTester {
public:
void setRefToPaint(SkPaint& paint) const override {
paint.setBlender(blender_);
}
void setRefToDisplayList(DisplayListBuilder& builder) const override {
builder.setBlender(blender_);
}
bool ref_is_unique() const override { return blender_->unique(); }
private:
sk_sp<SkBlender> blender_ =
SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, true);
};
BlenderRefTester tester;
tester.test();
ASSERT_TRUE(tester.ref_is_unique());
}
TEST(DisplayList, DisplayListFullPerspectiveTransformHandling) {
// SkM44 constructor takes row-major order
SkM44 sk_matrix = SkM44(
@@ -677,15 +626,6 @@ TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
RUN_TESTS2(builder.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
DlFilterMode::kLinear, false);
, true);
RUN_TESTS(builder.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, &kTestLatticeSrcRect, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, true););
RUN_TESTS2(builder.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, &kTestLatticeSrcRect, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
, true);
static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
RUN_TESTS2(
@@ -696,8 +636,6 @@ TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
builder.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
DlBlendMode::kSrcIn, kNearestSampling, nullptr, false);
, false);
RUN_TESTS(builder.drawPicture(TestPicture1, nullptr, true););
RUN_TESTS2(builder.drawPicture(TestPicture1, nullptr, false);, true);
EXPECT_TRUE(TestDisplayList1->can_apply_group_opacity());
RUN_TESTS2(builder.drawDisplayList(TestDisplayList1);, true);
{

View File

@@ -75,9 +75,6 @@ void SkPaintDispatchHelper::setColor(DlColor color) {
void SkPaintDispatchHelper::setBlendMode(DlBlendMode mode) {
paint_.setBlendMode(ToSk(mode));
}
void SkPaintDispatchHelper::setBlender(sk_sp<SkBlender> blender) {
paint_.setBlender(blender);
}
void SkPaintDispatchHelper::setColorSource(const DlColorSource* source) {
paint_.setShader(source ? source->skia_object() : nullptr);
}

View File

@@ -45,7 +45,6 @@ class IgnoreAttributeDispatchHelper : public virtual Dispatcher {
void setStrokeMiter(float limit) override {}
void setColor(DlColor color) override {}
void setBlendMode(DlBlendMode mode) override {}
void setBlender(sk_sp<SkBlender> blender) override {}
void setColorSource(const DlColorSource* source) override {}
void setImageFilter(const DlImageFilter* filter) override {}
void setColorFilter(const DlColorFilter* filter) override {}
@@ -112,8 +111,6 @@ class IgnoreDrawDispatchHelper : public virtual Dispatcher {
void drawPoints(DlCanvas::PointMode mode,
uint32_t count,
const SkPoint points[]) override {}
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override {}
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override {}
void drawImage(const sk_sp<DlImage> image,
const SkPoint point,
@@ -130,11 +127,6 @@ class IgnoreDrawDispatchHelper : public virtual Dispatcher {
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override {}
void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override {}
void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -144,9 +136,6 @@ class IgnoreDrawDispatchHelper : public virtual Dispatcher {
DlImageSampling sampling,
const SkRect* cull_rect,
bool render_with_attributes) override {}
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override {}
void drawDisplayList(const sk_sp<DisplayList> display_list) override {}
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
@@ -182,7 +171,6 @@ class SkPaintDispatchHelper : public virtual Dispatcher {
void setColorFilter(const DlColorFilter* filter) override;
void setInvertColors(bool invert) override;
void setBlendMode(DlBlendMode mode) override;
void setBlender(sk_sp<SkBlender> blender) override;
void setPathEffect(const DlPathEffect* effect) override;
void setMaskFilter(const DlMaskFilter* filter) override;
void setImageFilter(const DlImageFilter* filter) override;

View File

@@ -122,17 +122,10 @@ std::vector<DisplayListInvocationGroup> CreateAllAttributesOps() {
[](DisplayListBuilder& b) { b.setBlendMode(DlBlendMode::kSrcIn); }},
{0, 8, 0, 0,
[](DisplayListBuilder& b) { b.setBlendMode(DlBlendMode::kDstIn); }},
{0, 16, 0, 0,
[](DisplayListBuilder& b) { b.setBlender(kTestBlender1); }},
{0, 16, 0, 0,
[](DisplayListBuilder& b) { b.setBlender(kTestBlender2); }},
{0, 16, 0, 0,
[](DisplayListBuilder& b) { b.setBlender(kTestBlender3); }},
{0, 0, 0, 0,
[](DisplayListBuilder& b) {
b.setBlendMode(DlBlendMode::kSrcOver);
}},
{0, 0, 0, 0, [](DisplayListBuilder& b) { b.setBlender(nullptr); }},
}},
{"SetColorSource",
{
@@ -819,7 +812,7 @@ std::vector<DisplayListInvocationGroup> CreateAllRenderingOps() {
}},
{"DrawImageNine",
{
// SkVanvas::drawImageNine is immediately converted to
// SkCanvas::drawImageNine is immediately converted to
// drawImageLattice
{1, 48, -1, 80,
[](DisplayListBuilder& b) {
@@ -852,90 +845,6 @@ std::vector<DisplayListInvocationGroup> CreateAllRenderingOps() {
DlFilterMode::kNearest, false);
}},
}},
{"DrawImageLattice",
{
// Lattice:
// const int* fXDivs; //!< x-axis values dividing bitmap
// const int* fYDivs; //!< y-axis values dividing bitmap
// const RectType* fRectTypes; //!< array of fill types
// int fXCount; //!< number of x-coordinates
// int fYCount; //!< number of y-coordinates
// const SkIRect* fBounds; //!< source bounds to draw from
// const SkColor* fColors; //!< array of colors
// size = 64 + fXCount * 4 + fYCount * 4
// if fColors and fRectTypes are not null, add (fXCount + 1) *
// (fYCount + 1) * 5
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
}},
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 45}, DlFilterMode::kNearest, false);
}},
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage1,
{kTestDivs2, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
}},
// One less yDiv does not change the allocation due to 8-byte
// alignment
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 2, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
}},
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kLinear, false);
}},
{1, 96, -1, 96,
[](DisplayListBuilder& b) {
b.setColor(SK_ColorMAGENTA);
b.drawImageLattice(
TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, true);
}},
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(
TestImage2,
{kTestDivs1, kTestDivs1, nullptr, 3, 3, nullptr, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest, false);
}},
// Supplying fBounds does not change size because the Op record
// always includes it
{1, 88, -1, 88,
[](DisplayListBuilder& b) {
b.drawImageLattice(TestImage1,
{kTestDivs1, kTestDivs1, nullptr, 3, 3,
&kTestLatticeSrcRect, nullptr},
{10, 10, 40, 40}, DlFilterMode::kNearest,
false);
}},
{1, 128, -1, 128,
[](DisplayListBuilder& b) {
b.drawImageLattice(TestImage1,
{kTestDivs3, kTestDivs3, kTestRTypes, 2, 2,
nullptr, kTestLatticeColors},
{10, 10, 40, 40}, DlFilterMode::kNearest,
false);
}},
}},
{"DrawAtlas",
{
{1, 48 + 32 + 8, -1, 48 + 32 + 32,
@@ -1013,34 +922,6 @@ std::vector<DisplayListInvocationGroup> CreateAllRenderingOps() {
false);
}},
}},
{"DrawPicture",
{
// cv.drawPicture cannot be compared as SkCanvas may inline it
{1, 16, -1, 16,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture1, nullptr, false);
}},
{1, 16, -1, 16,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture2, nullptr, false);
}},
{1, 16, -1, 16,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture1, nullptr, true);
}},
{1, 56, -1, 56,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture1, &kTestMatrix1, false);
}},
{1, 56, -1, 56,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture1, &kTestMatrix2, false);
}},
{1, 56, -1, 56,
[](DisplayListBuilder& b) {
b.drawPicture(TestPicture1, &kTestMatrix1, true);
}},
}},
{"DrawDisplayList",
{
// cv.drawDL does not exist

View File

@@ -8,10 +8,7 @@
#include "flutter/display_list/display_list.h"
#include "flutter/display_list/display_list_builder.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/effects/SkBlenders.h"
#include "third_party/skia/include/effects/SkDashPathEffect.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "third_party/skia/include/effects/SkImageFilters.h"
@@ -93,12 +90,6 @@ static sk_sp<DlImage> MakeTestImage(int w, int h, int checker_size) {
static auto TestImage1 = MakeTestImage(40, 40, 5);
static auto TestImage2 = MakeTestImage(50, 50, 5);
static const sk_sp<SkBlender> kTestBlender1 =
SkBlenders::Arithmetic(0.2, 0.2, 0.2, 0.2, false);
static const sk_sp<SkBlender> kTestBlender2 =
SkBlenders::Arithmetic(0.2, 0.2, 0.2, 0.2, true);
static const sk_sp<SkBlender> kTestBlender3 =
SkBlenders::Arithmetic(0.3, 0.3, 0.3, 0.3, true);
static const DlImageColorSource kTestSource1(TestImage1,
DlTileMode::kClamp,
DlTileMode::kMirror,
@@ -220,40 +211,6 @@ static std::shared_ptr<const DlVertices> TestVertices2 =
nullptr,
kColors);
static constexpr int kTestDivs1[] = {10, 20, 30};
static constexpr int kTestDivs2[] = {15, 20, 25};
static constexpr int kTestDivs3[] = {15, 25};
static constexpr SkCanvas::Lattice::RectType kTestRTypes[] = {
SkCanvas::Lattice::RectType::kDefault,
SkCanvas::Lattice::RectType::kTransparent,
SkCanvas::Lattice::RectType::kFixedColor,
SkCanvas::Lattice::RectType::kDefault,
SkCanvas::Lattice::RectType::kTransparent,
SkCanvas::Lattice::RectType::kFixedColor,
SkCanvas::Lattice::RectType::kDefault,
SkCanvas::Lattice::RectType::kTransparent,
SkCanvas::Lattice::RectType::kFixedColor,
};
static constexpr SkColor kTestLatticeColors[] = {
SK_ColorBLUE, SK_ColorGREEN, SK_ColorYELLOW,
SK_ColorBLUE, SK_ColorGREEN, SK_ColorYELLOW,
SK_ColorBLUE, SK_ColorGREEN, SK_ColorYELLOW,
};
static constexpr SkIRect kTestLatticeSrcRect = {1, 1, 39, 39};
static sk_sp<SkPicture> MakeTestPicture(int w, int h, SkColor color) {
SkPictureRecorder recorder;
SkRTreeFactory rtree_factory;
SkCanvas* cv = recorder.beginRecording(kTestBounds, &rtree_factory);
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
cv->drawRect(SkRect::MakeWH(w, h), paint);
return recorder.finishRecordingAsPicture();
}
static sk_sp<SkPicture> TestPicture1 = MakeTestPicture(20, 20, SK_ColorGREEN);
static sk_sp<SkPicture> TestPicture2 = MakeTestPicture(25, 25, SK_ColorBLUE);
static sk_sp<DisplayList> MakeTestDisplayList(int w, int h, SkColor color) {
DisplayListBuilder builder;
builder.setColor(color);

View File

@@ -7,7 +7,6 @@
#include "flutter/fml/macros.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBlender.h"
#include "third_party/skia/include/core/SkBlurTypes.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorFilter.h"

View File

@@ -588,12 +588,6 @@ void DisplayListDispatcher::setBlendMode(flutter::DlBlendMode dl_mode) {
paint_.blend_mode = ToBlendMode(dl_mode);
}
// |flutter::Dispatcher|
void DisplayListDispatcher::setBlender(sk_sp<SkBlender> blender) {
// Needs https://github.com/flutter/flutter/issues/95434
UNIMPLEMENTED;
}
// |flutter::Dispatcher|
void DisplayListDispatcher::setPathEffect(const flutter::DlPathEffect* effect) {
// Needs https://github.com/flutter/flutter/issues/95434
@@ -1120,13 +1114,6 @@ void DisplayListDispatcher::drawPoints(PointMode mode,
}
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
// Needs https://github.com/flutter/flutter/issues/95434
UNIMPLEMENTED;
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawVertices(const flutter::DlVertices* vertices,
flutter::DlBlendMode dl_mode) {
@@ -1193,18 +1180,6 @@ void DisplayListDispatcher::drawImageNine(const sk_sp<flutter::DlImage> image,
ToRect(dst), ToSamplerDescriptor(filter), &canvas_, &paint_);
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawImageLattice(
const sk_sp<flutter::DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
flutter::DlFilterMode filter,
bool render_with_attributes) {
// Don't implement this one since it is not exposed by flutter,
// Skia internally converts calls to drawImageNine into this method,
// which is then converted back to drawImageNine by display list.
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawAtlas(const sk_sp<flutter::DlImage> atlas,
const SkRSXform xform[],
@@ -1221,14 +1196,6 @@ void DisplayListDispatcher::drawAtlas(const sk_sp<flutter::DlImage> atlas,
ToSamplerDescriptor(sampling), ToRect(cull_rect), paint_);
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) {
// Needs https://github.com/flutter/flutter/issues/95434
UNIMPLEMENTED;
}
// |flutter::Dispatcher|
void DisplayListDispatcher::drawDisplayList(
const sk_sp<flutter::DisplayList> display_list) {

View File

@@ -58,9 +58,6 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
// |flutter::Dispatcher|
void setBlendMode(flutter::DlBlendMode mode) override;
// |flutter::Dispatcher|
void setBlender(sk_sp<SkBlender> blender) override;
// |flutter::Dispatcher|
void setPathEffect(const flutter::DlPathEffect* effect) override;
@@ -169,10 +166,6 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
uint32_t count,
const SkPoint points[]) override;
// |flutter::Dispatcher|
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override;
// |flutter::Dispatcher|
void drawVertices(const flutter::DlVertices* vertices,
flutter::DlBlendMode dl_mode) override;
@@ -198,13 +191,6 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
flutter::DlFilterMode filter,
bool render_with_attributes) override;
// |flutter::Dispatcher|
void drawImageLattice(const sk_sp<flutter::DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
flutter::DlFilterMode filter,
bool render_with_attributes) override;
// |flutter::Dispatcher|
void drawAtlas(const sk_sp<flutter::DlImage> atlas,
const SkRSXform xform[],
@@ -216,11 +202,6 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
const SkRect* cull_rect,
bool render_with_attributes) override;
// |flutter::Dispatcher|
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override;
// |flutter::Dispatcher|
void drawDisplayList(const sk_sp<flutter::DisplayList> display_list) override;

View File

@@ -513,9 +513,6 @@ void DisplayListStreamDispatcher::setInvertColors(bool invert) {
void DisplayListStreamDispatcher::setBlendMode(DlBlendMode mode) {
startl() << "setBlendMode(" << mode << ");" << std::endl;
}
void DisplayListStreamDispatcher::setBlender(sk_sp<SkBlender> blender) {
startl() << "setBlender(" << blender << ");" << std::endl;
}
void DisplayListStreamDispatcher::setPathEffect(const DlPathEffect* effect) {
startl() << "setPathEffect(" << effect << ");" << std::endl;
}
@@ -769,10 +766,6 @@ void DisplayListStreamDispatcher::drawPoints(PointMode mode,
out_array("points", count, points)
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
startl() << "drawSkVertices(" << vertices << ", " << static_cast<int>(mode) << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawVertices(const DlVertices* vertices,
DlBlendMode mode) {
startl() << "drawVertices("
@@ -820,13 +813,6 @@ void DisplayListStreamDispatcher::drawImageNine(const sk_sp<DlImage> image,
<< "with attributes: " << render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
startl() << "drawImageLattice(blah blah);" << std::endl;
}
void DisplayListStreamDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -844,15 +830,6 @@ void DisplayListStreamDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
<< "with attributes: " << render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) {
startl() << "drawPicture("
<< "SkPicture(ID: " << picture->uniqueID() << ", bounds: " << picture->cullRect() << ", @" << picture << "), "
<< matrix << ", "
<< render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawDisplayList(
const sk_sp<DisplayList> display_list) {
startl() << "drawDisplayList(ID: " << display_list->unique_id() << ", bounds: " << display_list->bounds() << ");" << std::endl;

View File

@@ -66,7 +66,6 @@ class DisplayListStreamDispatcher final : public Dispatcher {
void setColorFilter(const DlColorFilter* filter) override;
void setInvertColors(bool invert) override;
void setBlendMode(DlBlendMode mode) override;
void setBlender(sk_sp<SkBlender> blender) override;
void setPathEffect(const DlPathEffect* effect) override;
void setMaskFilter(const DlMaskFilter* filter) override;
void setImageFilter(const DlImageFilter* filter) override;
@@ -112,8 +111,6 @@ class DisplayListStreamDispatcher final : public Dispatcher {
void drawPoints(PointMode mode,
uint32_t count,
const SkPoint points[]) override;
void drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) override;
void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
void drawImage(const sk_sp<DlImage> image,
const SkPoint point,
@@ -130,11 +127,6 @@ class DisplayListStreamDispatcher final : public Dispatcher {
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
@@ -144,9 +136,6 @@ class DisplayListStreamDispatcher final : public Dispatcher {
DlImageSampling sampling,
const SkRect* cull_rect,
bool render_with_attributes) override;
void drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,