diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5a89b4f08cc77..7f33cd34a9f7f 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -715,8 +715,6 @@ ORIGIN: ../../../flutter/display_list/display_list_builder.h + ../../../flutter/ ORIGIN: ../../../flutter/display_list/display_list_builder_benchmarks.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/display_list/display_list_canvas_dispatcher.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/display_list/display_list_canvas_dispatcher.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/display_list/display_list_canvas_recorder.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/display_list/display_list_canvas_recorder.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/display_list/display_list_color.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/display_list/display_list_color_filter.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/display_list/display_list_color_filter.h + ../../../flutter/LICENSE @@ -3216,8 +3214,6 @@ FILE: ../../../flutter/display_list/display_list_builder.h FILE: ../../../flutter/display_list/display_list_builder_benchmarks.cc FILE: ../../../flutter/display_list/display_list_canvas_dispatcher.cc FILE: ../../../flutter/display_list/display_list_canvas_dispatcher.h -FILE: ../../../flutter/display_list/display_list_canvas_recorder.cc -FILE: ../../../flutter/display_list/display_list_canvas_recorder.h FILE: ../../../flutter/display_list/display_list_color.h FILE: ../../../flutter/display_list/display_list_color_filter.cc FILE: ../../../flutter/display_list/display_list_color_filter.h diff --git a/display_list/BUILD.gn b/display_list/BUILD.gn index 027fa35e16bb6..35e6c8f689302 100644 --- a/display_list/BUILD.gn +++ b/display_list/BUILD.gn @@ -18,8 +18,6 @@ source_set("display_list") { "display_list_builder.h", "display_list_canvas_dispatcher.cc", "display_list_canvas_dispatcher.h", - "display_list_canvas_recorder.cc", - "display_list_canvas_recorder.h", "display_list_color.h", "display_list_color_filter.cc", "display_list_color_filter.h", diff --git a/display_list/display_list.h b/display_list/display_list.h index 78b739d6fe914..bcbd9f673539b 100644 --- a/display_list/display_list.h +++ b/display_list/display_list.h @@ -44,9 +44,9 @@ // provides a nearly 1:1 translation between the records of the DisplayList // to method calls. // -// A DisplayList can be created directly using a DisplayListBuilder and -// the Dispatcher methods that it implements, or it can be created from -// a sequence of SkCanvas calls using the DisplayListCanvasRecorder class. +// A DisplayList must be created using a DisplayListBuilder using either its +// stateful methods inherited from Dispatcher, or from its stateless methods +// inherited from DlCanvas. // // A DisplayList can be read back by implementing the Dispatcher virtual // methods (with help from some of the classes in the utils file) and diff --git a/display_list/display_list_builder.h b/display_list/display_list_builder.h index d2846f87e5aec..56e94f193e5da 100644 --- a/display_list/display_list_builder.h +++ b/display_list/display_list_builder.h @@ -23,10 +23,8 @@ namespace flutter { // The primary class used to build a display list. The list of methods -// 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. +// here matches the list of methods invoked on a |Dispatcher| combined +// with the list of methods invoked on a |DlCanvas|. class DisplayListBuilder final : public virtual DlCanvas, public SkRefCnt, virtual Dispatcher, diff --git a/display_list/display_list_canvas_recorder.cc b/display_list/display_list_canvas_recorder.cc deleted file mode 100644 index 31de676db2f2d..0000000000000 --- a/display_list/display_list_canvas_recorder.cc +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/display_list/display_list_canvas_recorder.h" - -#include "flutter/display_list/display_list_blend_mode.h" -#include "flutter/display_list/display_list_builder.h" -#include "flutter/display_list/display_list_image_filter.h" - -namespace flutter { - -#define CHECK_DISPOSE(ret) \ - do { \ - if (!builder_) { \ - FML_DCHECK(builder_) \ - << "Calling method on DisplayListCanvasRecorder after Build()"; \ - return ret; \ - } \ - } while (0) - -static DlCanvas::ClipOp ToDl(SkClipOp op) { - return static_cast(op); -} - -static DlCanvas::PointMode ToDl(SkCanvas::PointMode mode) { - return static_cast(mode); -} - -DisplayListCanvasRecorder::DisplayListCanvasRecorder(const SkRect& bounds, - bool prepare_rtree) - : SkCanvasVirtualEnforcer(0, 0), - builder_(sk_make_sp(bounds, prepare_rtree)) { - // isEmpty protects us against NaN as we normalize any empty cull rects - SkIRect cull = bounds.isEmpty() ? SkIRect::MakeEmpty() : bounds.roundOut(); - SkCanvasVirtualEnforcer::resetCanvas(cull); -} - -sk_sp DisplayListCanvasRecorder::Build() { - CHECK_DISPOSE(nullptr); - sk_sp display_list = builder_->Build(); - builder_.reset(); - return display_list; -} - -// clang-format off -void DisplayListCanvasRecorder::didConcat44(const SkM44& m44) { - CHECK_DISPOSE(); - builder_->transform(m44); -} -// clang-format on -void DisplayListCanvasRecorder::didSetM44(const SkM44& matrix) { - CHECK_DISPOSE(); - builder_->transformReset(); - builder_->transform(matrix); -} -void DisplayListCanvasRecorder::didTranslate(SkScalar tx, SkScalar ty) { - CHECK_DISPOSE(); - builder_->translate(tx, ty); -} -void DisplayListCanvasRecorder::didScale(SkScalar sx, SkScalar sy) { - CHECK_DISPOSE(); - builder_->scale(sx, sy); -} - -void DisplayListCanvasRecorder::onClipRect(const SkRect& rect, - SkClipOp clip_op, - ClipEdgeStyle edge_style) { - CHECK_DISPOSE(); - builder_->clipRect(rect, ToDl(clip_op), - edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle); - SkCanvasVirtualEnforcer::onClipRect(rect, clip_op, edge_style); -} -void DisplayListCanvasRecorder::onClipRRect(const SkRRect& rrect, - SkClipOp clip_op, - ClipEdgeStyle edge_style) { - CHECK_DISPOSE(); - builder_->clipRRect(rrect, ToDl(clip_op), - edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle); - SkCanvasVirtualEnforcer::onClipRRect(rrect, clip_op, edge_style); -} -void DisplayListCanvasRecorder::onClipPath(const SkPath& path, - SkClipOp clip_op, - ClipEdgeStyle edge_style) { - CHECK_DISPOSE(); - builder_->clipPath(path, ToDl(clip_op), - edge_style == ClipEdgeStyle::kSoft_ClipEdgeStyle); - SkCanvasVirtualEnforcer::onClipPath(path, clip_op, edge_style); -} - -void DisplayListCanvasRecorder::willSave() { - CHECK_DISPOSE(); - builder_->save(); -} -SkCanvas::SaveLayerStrategy DisplayListCanvasRecorder::getSaveLayerStrategy( - const SaveLayerRec& rec) { - CHECK_DISPOSE(SaveLayerStrategy::kNoLayer_SaveLayerStrategy); - std::shared_ptr backdrop = DlImageFilter::From(rec.fBackdrop); - if (rec.fPaint) { - builder_->setAttributesFromPaint(*rec.fPaint, kSaveLayerWithPaintFlags); - builder_->saveLayer(rec.fBounds, SaveLayerOptions::kWithAttributes, - backdrop.get()); - } else { - builder_->saveLayer(rec.fBounds, SaveLayerOptions::kNoAttributes, - backdrop.get()); - } - return SaveLayerStrategy::kNoLayer_SaveLayerStrategy; -} -void DisplayListCanvasRecorder::didRestore() { - CHECK_DISPOSE(); - builder_->restore(); -} - -void DisplayListCanvasRecorder::onDrawPaint(const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawPaintFlags); - builder_->drawPaint(); -} -void DisplayListCanvasRecorder::onDrawRect(const SkRect& rect, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawRectFlags); - builder_->drawRect(rect); -} -void DisplayListCanvasRecorder::onDrawRRect(const SkRRect& rrect, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawRRectFlags); - builder_->drawRRect(rrect); -} -void DisplayListCanvasRecorder::onDrawDRRect(const SkRRect& outer, - const SkRRect& inner, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawDRRectFlags); - builder_->drawDRRect(outer, inner); -} -void DisplayListCanvasRecorder::onDrawOval(const SkRect& rect, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawOvalFlags); - builder_->drawOval(rect); -} -void DisplayListCanvasRecorder::onDrawArc(const SkRect& rect, - SkScalar startAngle, - SkScalar sweepAngle, - bool useCenter, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, - useCenter // - ? kDrawArcWithCenterFlags - : kDrawArcNoCenterFlags); - builder_->drawArc(rect, startAngle, sweepAngle, useCenter); -} -void DisplayListCanvasRecorder::onDrawPath(const SkPath& path, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawPathFlags); - builder_->drawPath(path); -} - -void DisplayListCanvasRecorder::onDrawPoints(SkCanvas::PointMode mode, - size_t count, - const SkPoint pts[], - const SkPaint& paint) { - CHECK_DISPOSE(); - switch (mode) { - case SkCanvas::kPoints_PointMode: - builder_->setAttributesFromPaint(paint, kDrawPointsAsPointsFlags); - break; - case SkCanvas::kLines_PointMode: - builder_->setAttributesFromPaint(paint, kDrawPointsAsLinesFlags); - break; - case SkCanvas::kPolygon_PointMode: - builder_->setAttributesFromPaint(paint, kDrawPointsAsPolygonFlags); - break; - } - if (mode == SkCanvas::PointMode::kLines_PointMode && count == 2) { - builder_->drawLine(pts[0], pts[1]); - } else { - uint32_t count32 = static_cast(count); - // TODO(flar): depending on the mode we could break it down into - // multiple calls to drawPoints, but how much do we really want - // to support more than a couple billion points? - FML_DCHECK(count32 == count); - builder_->drawPoints(ToDl(mode), count32, pts); - } -} -void DisplayListCanvasRecorder::onDrawVerticesObject(const SkVertices* vertices, - SkBlendMode mode, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawVerticesFlags); - builder_->drawSkVertices(sk_ref_sp(vertices), mode); -} - -void DisplayListCanvasRecorder::onDrawImage2(const SkImage* image, - SkScalar dx, - SkScalar dy, - const SkSamplingOptions& sampling, - const SkPaint* paint) { - CHECK_DISPOSE(); - if (paint != nullptr) { - builder_->setAttributesFromPaint(*paint, kDrawImageWithPaintFlags); - } - builder_->drawImage(DlImage::Make(image), SkPoint::Make(dx, dy), - ToDl(sampling), paint != nullptr); -} -void DisplayListCanvasRecorder::onDrawImageRect2( - const SkImage* image, - const SkRect& src, - const SkRect& dst, - const SkSamplingOptions& sampling, - const SkPaint* paint, - SrcRectConstraint constraint) { - CHECK_DISPOSE(); - if (paint != nullptr) { - builder_->setAttributesFromPaint(*paint, kDrawImageRectWithPaintFlags); - } - builder_->drawImageRect(DlImage::Make(image), src, dst, ToDl(sampling), - paint != nullptr, constraint); -} -void DisplayListCanvasRecorder::onDrawImageLattice2(const SkImage* image, - const Lattice& lattice, - const SkRect& dst, - SkFilterMode filter, - const SkPaint* paint) { - CHECK_DISPOSE(); - if (paint != nullptr) { - // SkCanvas will always construct a paint, - // though it is a default paint most of the time - SkPaint default_paint; - if (*paint == default_paint) { - paint = nullptr; - } else { - builder_->setAttributesFromPaint(*paint, kDrawImageLatticeWithPaintFlags); - } - } - builder_->drawImageLattice(DlImage::Make(image), lattice, dst, ToDl(filter), - paint != nullptr); -} -void DisplayListCanvasRecorder::onDrawAtlas2(const SkImage* image, - const SkRSXform xform[], - const SkRect src[], - const SkColor colors[], - int count, - SkBlendMode mode, - const SkSamplingOptions& sampling, - const SkRect* cull, - const SkPaint* paint) { - CHECK_DISPOSE(); - if (paint != nullptr) { - builder_->setAttributesFromPaint(*paint, kDrawAtlasWithPaintFlags); - } - const DlColor* dl_colors = reinterpret_cast(colors); - builder_->drawAtlas(DlImage::Make(image), xform, src, dl_colors, count, - ToDl(mode), ToDl(sampling), cull, paint != nullptr); -} - -void DisplayListCanvasRecorder::onDrawTextBlob(const SkTextBlob* blob, - SkScalar x, - SkScalar y, - const SkPaint& paint) { - CHECK_DISPOSE(); - builder_->setAttributesFromPaint(paint, kDrawTextBlobFlags); - builder_->drawTextBlob(sk_ref_sp(blob), x, y); -} - -void DisplayListCanvasRecorder::onDrawPicture(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint) { - CHECK_DISPOSE(); - if (paint != nullptr) { - builder_->setAttributesFromPaint(*paint, kDrawPictureWithPaintFlags); - } - builder_->drawPicture(sk_ref_sp(picture), matrix, paint != nullptr); -} - -void DisplayListCanvasRecorder::onDrawShadowRec(const SkPath& path, - const SkDrawShadowRec& rec) { - CHECK_DISPOSE(); - // Skia does not expose the SkDrawShadowRec structure in a public - // header file so we cannot record this operation. - // See: https://bugs.chromium.org/p/skia/issues/detail?id=12125 - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawBehind(const SkPaint&) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawRegion(const SkRegion& region, - const SkPaint& paint) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawPatch(const SkPoint cubics[12], - const SkColor colors[4], - const SkPoint texCoords[4], - SkBlendMode mode, - const SkPaint& paint) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawEdgeAAQuad(const SkRect& rect, - const SkPoint clip[4], - SkCanvas::QuadAAFlags aaFlags, - const SkColor4f& color, - SkBlendMode mode) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawAnnotation(const SkRect& rect, - const char key[], - SkData* value) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -void DisplayListCanvasRecorder::onDrawDrawable(SkDrawable* drawable, - const SkMatrix* matrix) { - CHECK_DISPOSE(); - FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::" - << __FUNCTION__; -} - -} // namespace flutter diff --git a/display_list/display_list_canvas_recorder.h b/display_list/display_list_canvas_recorder.h deleted file mode 100644 index a2977693078c3..0000000000000 --- a/display_list/display_list_canvas_recorder.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_DISPLAY_LIST_DISPLAY_LIST_CANVAS_RECORDER_H_ -#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_CANVAS_RECORDER_H_ - -#include "flutter/display_list/display_list.h" -#include "flutter/display_list/display_list_builder.h" -#include "flutter/display_list/display_list_flags.h" -#include "flutter/fml/macros.h" -#include "third_party/skia/include/core/SkCanvasVirtualEnforcer.h" -#include "third_party/skia/include/utils/SkNoDrawCanvas.h" - -namespace flutter { - -//------------------------------------------------------------------------------ -/// An adapter that implements an SkCanvas interface which can then be handed to -/// code that outputs to an SkCanvas to capture the output into a Flutter -/// DisplayList. -/// -/// Receives all methods on SkCanvas and sends them to a DisplayListBuilder -/// -class DisplayListCanvasRecorder - : public SkCanvasVirtualEnforcer, - public SkRefCnt, - DisplayListOpFlags { - public: - explicit DisplayListCanvasRecorder(const SkRect& bounds, - bool prepare_rtree = false); - - const sk_sp builder() { return builder_; } - - sk_sp Build(); - - void didConcat44(const SkM44&) override; - void didSetM44(const SkM44&) override; - void didTranslate(SkScalar, SkScalar) override; - void didScale(SkScalar, SkScalar) override; - - void onClipRect(const SkRect& rect, - SkClipOp op, - ClipEdgeStyle edgeStyle) override; - void onClipRRect(const SkRRect& rrect, - SkClipOp op, - ClipEdgeStyle edgeStyle) override; - void onClipPath(const SkPath& path, - SkClipOp op, - ClipEdgeStyle edgeStyle) override; - - void willSave() override; - SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; - void didRestore() override; - - void onDrawPaint(const SkPaint& paint) override; - void onDrawBehind(const SkPaint&) override; - void onDrawRect(const SkRect& rect, const SkPaint& paint) override; - void onDrawRRect(const SkRRect& rrect, const SkPaint& paint) override; - void onDrawDRRect(const SkRRect& outer, - const SkRRect& inner, - const SkPaint& paint) override; - void onDrawOval(const SkRect& rect, const SkPaint& paint) override; - void onDrawArc(const SkRect& rect, - SkScalar startAngle, - SkScalar sweepAngle, - bool useCenter, - const SkPaint& paint) override; - void onDrawPath(const SkPath& path, const SkPaint& paint) override; - void onDrawRegion(const SkRegion& region, const SkPaint& paint) override; - - void onDrawTextBlob(const SkTextBlob* blob, - SkScalar x, - SkScalar y, - const SkPaint& paint) override; - - void onDrawPatch(const SkPoint cubics[12], - const SkColor colors[4], - const SkPoint texCoords[4], - SkBlendMode mode, - const SkPaint& paint) override; - void onDrawPoints(SkCanvas::PointMode mode, - size_t count, - const SkPoint pts[], - const SkPaint& paint) override; - void onDrawVerticesObject(const SkVertices* vertices, - SkBlendMode mode, - const SkPaint& paint) override; - - void onDrawImage2(const SkImage*, - SkScalar dx, - SkScalar dy, - const SkSamplingOptions&, - const SkPaint*) override; - void onDrawImageRect2(const SkImage*, - const SkRect& src, - const SkRect& dst, - const SkSamplingOptions&, - const SkPaint*, - SrcRectConstraint) override; - void onDrawImageLattice2(const SkImage*, - const Lattice&, - const SkRect& dst, - SkFilterMode, - const SkPaint*) override; - void onDrawAtlas2(const SkImage*, - const SkRSXform[], - const SkRect src[], - const SkColor[], - int count, - SkBlendMode, - const SkSamplingOptions&, - const SkRect* cull, - const SkPaint*) override; - - void onDrawEdgeAAQuad(const SkRect& rect, - const SkPoint clip[4], - SkCanvas::QuadAAFlags aaFlags, - const SkColor4f& color, - SkBlendMode mode) override; - - void onDrawAnnotation(const SkRect& rect, - const char key[], - SkData* value) override; - void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override; - - void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override; - void onDrawPicture(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint) override; - - private: - sk_sp builder_; -}; - -} // namespace flutter - -#endif // FLUTTER_DISPLAY_LIST_DISPLAY_LIST_CANVAS_RECORDER_H_ diff --git a/display_list/display_list_canvas_unittests.cc b/display_list/display_list_canvas_unittests.cc index dee47a5c18d07..dad0f57d137c7 100644 --- a/display_list/display_list_canvas_unittests.cc +++ b/display_list/display_list_canvas_unittests.cc @@ -5,8 +5,8 @@ #include #include "flutter/display_list/display_list.h" +#include "flutter/display_list/display_list_builder.h" #include "flutter/display_list/display_list_canvas_dispatcher.h" -#include "flutter/display_list/display_list_canvas_recorder.h" #include "flutter/display_list/display_list_comparable.h" #include "flutter/display_list/display_list_flags.h" #include "flutter/display_list/display_list_sampling_options.h" @@ -712,14 +712,6 @@ class TestParameters { dl_renderer_(builder); } - // If a test is using any shadow operations then we cannot currently - // record those in an SkCanvas and play it back into a DisplayList - // because internally the operation gets encapsulated in a Skia - // ShadowRec which is not exposed by their headers. For operations - // that use shadows, we can perform a lot of tests, but not the tests - // that require SkCanvas->DisplayList transfers. - // See: https://bugs.chromium.org/p/skia/issues/detail?id=12125 - bool is_draw_shadows() const { return is_draw_shadows_; } // Tests that call drawTextBlob with an sk_ref paint attribute will cause // those attributes to be stored in an internal Skia cache so we need // to expect that the |sk_ref.unique()| call will fail in those cases. @@ -733,10 +725,6 @@ class TestParameters { bool is_vertical_line() const { return is_vertical_line_; } bool ignores_dashes() const { return ignores_dashes_; } - TestParameters& set_draw_shadows() { - is_draw_shadows_ = true; - return *this; - } TestParameters& set_draw_text_blob() { is_draw_text_blob_ = true; return *this; @@ -775,7 +763,6 @@ class TestParameters { const DlRenderer& dl_renderer_; const DisplayListAttributeFlags& flags_; - bool is_draw_shadows_ = false; bool is_draw_text_blob_ = false; bool is_draw_display_list_ = false; bool is_draw_line_ = false; @@ -2113,22 +2100,6 @@ class CanvasCompareTester { } } - // This test cannot work if the rendering is using shadows until - // we can access the Skia ShadowRec via public headers. - if (!testP.is_draw_shadows()) { - // This sequence renders SkCanvas calls to a DisplayList and then - // plays them back on SkCanvas to SkSurface - // SkCanvas calls => DisplayList => rendering - DisplayListCanvasRecorder dl_recorder(kTestBounds); - sk_job.Render(&dl_recorder, base_info); - DlRenderJob cv_dl_job(dl_recorder.Build()); - auto cv_dl_result = env.getResult(base_info, cv_dl_job); - compareToReference(cv_dl_result.get(), sk_result.get(), - info + " (Skia calls -> DisplayList -> surface)", - nullptr, nullptr, bg, - caseP.fuzzy_compare_components()); - } - { // This sequence renders the SkCanvas calls to an SkPictureRecorder and // renders the DisplayList calls to a DisplayListBuilder and then @@ -3529,8 +3500,7 @@ TEST_F(DisplayListCanvas, DrawShadow) { [=](DisplayListBuilder& builder) { // builder.drawShadow(path, color, elevation, false, 1.0); }, - kDrawShadowFlags) - .set_draw_shadows(), + kDrawShadowFlags), CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3)); } @@ -3556,8 +3526,7 @@ TEST_F(DisplayListCanvas, DrawShadowTransparentOccluder) { [=](DisplayListBuilder& builder) { // builder.drawShadow(path, color, elevation, true, 1.0); }, - kDrawShadowFlags) - .set_draw_shadows(), + kDrawShadowFlags), CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3)); } @@ -3583,8 +3552,7 @@ TEST_F(DisplayListCanvas, DrawShadowDpr) { [=](DisplayListBuilder& builder) { // builder.drawShadow(path, color, elevation, false, 1.5); }, - kDrawShadowFlags) - .set_draw_shadows(), + kDrawShadowFlags), CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3)); } diff --git a/display_list/display_list_color_filter.h b/display_list/display_list_color_filter.h index ee536b30eb215..6fbef21821d26 100644 --- a/display_list/display_list_color_filter.h +++ b/display_list/display_list_color_filter.h @@ -255,11 +255,11 @@ class DlLinearToSrgbGammaColorFilter final : public DlColorFilter { // A wrapper class for a Skia ColorFilter of unknown type. The above 4 types // are the only types that can be constructed by Flutter using the -// ui.ColorFilter class so this class should be rarely used. The main use -// would come from the |DisplayListCanvasRecorder| recording Skia rendering -// calls that originated outside of the Flutter dart code. This would -// primarily happen in the Paragraph code that renders the text using the -// SkCanvas interface which we capture into DisplayList data structures. +// ui.ColorFilter class so this class should be rarely used. +// In fact, now that the DisplayListCanvasRecorder is deleted and the +// Paragraph code talks directly to a DisplayListBuilder, there may be +// no more reasons to maintain this sub-class. +// See: https://github.com/flutter/flutter/issues/121389 class DlUnknownColorFilter final : public DlColorFilter { public: DlUnknownColorFilter(sk_sp sk_filter) diff --git a/display_list/display_list_color_source.h b/display_list/display_list_color_source.h index 361e7b2817b01..bf15441913b26 100644 --- a/display_list/display_list_color_source.h +++ b/display_list/display_list_color_source.h @@ -811,6 +811,10 @@ class DlSceneColorSource final : public DlColorSource { }; #endif // IMPELLER_ENABLE_3D +// Now that the DisplayListCanvasRecorder is deleted and the +// Paragraph code talks directly to a DisplayListBuilder, there may be +// no more reasons to maintain this sub-class. +// See: https://github.com/flutter/flutter/issues/121389 class DlUnknownColorSource final : public DlColorSource { public: DlUnknownColorSource(sk_sp shader) diff --git a/display_list/display_list_image_filter.h b/display_list/display_list_image_filter.h index 3a79b89aa43b8..f8a084858ed42 100644 --- a/display_list/display_list_image_filter.h +++ b/display_list/display_list_image_filter.h @@ -738,11 +738,11 @@ class DlLocalMatrixImageFilter final : public DlImageFilter { // A wrapper class for a Skia ImageFilter of unknown type. The above 4 types // are the only types that can be constructed by Flutter using the -// ui.ImageFilter class so this class should be rarely used. The main use -// would come from the |DisplayListCanvasRecorder| recording Skia rendering -// calls that originated outside of the Flutter dart code. This would -// primarily happen in the Paragraph code that renders the text using the -// SkCanvas interface which we capture into DisplayList data structures. +// ui.ImageFilter class so this class should be rarely used. +// In fact, now that the DisplayListCanvasRecorder is deleted and the +// Paragraph code talks directly to a DisplayListBuilder, there may be +// no more reasons to maintain this sub-class. +// See: https://github.com/flutter/flutter/issues/121389 class DlUnknownImageFilter final : public DlImageFilter { public: explicit DlUnknownImageFilter(sk_sp sk_filter) diff --git a/display_list/display_list_mask_filter.h b/display_list/display_list_mask_filter.h index 336d7c58e74fd..9210d45a2b318 100644 --- a/display_list/display_list_mask_filter.h +++ b/display_list/display_list_mask_filter.h @@ -101,11 +101,11 @@ class DlBlurMaskFilter final : public DlMaskFilter { // A wrapper class for a Skia MaskFilter of unknown type. The above 4 types // are the only types that can be constructed by Flutter using the -// ui.MaskFilter class so this class should be rarely used. The main use -// would come from the |DisplayListCanvasRecorder| recording Skia rendering -// calls that originated outside of the Flutter dart code. This would -// primarily happen in the Paragraph code that renders the text using the -// SkCanvas interface which we capture into DisplayList data structures. +// ui.MaskFilter class so this class should be rarely used. +// In fact, now that the DisplayListCanvasRecorder is deleted and the +// Paragraph code talks directly to a DisplayListBuilder, there may be +// no more reasons to maintain this sub-class. +// See: https://github.com/flutter/flutter/issues/121389 class DlUnknownMaskFilter final : public DlMaskFilter { public: DlUnknownMaskFilter(sk_sp sk_filter) diff --git a/display_list/display_list_path_effect.h b/display_list/display_list_path_effect.h index a6d2f02361df3..cf98d698f1c64 100644 --- a/display_list/display_list_path_effect.h +++ b/display_list/display_list_path_effect.h @@ -136,6 +136,10 @@ class DlDashPathEffect final : public DlPathEffect { FML_DISALLOW_COPY_ASSIGN_AND_MOVE(DlDashPathEffect); }; +// Now that the DisplayListCanvasRecorder is deleted and the +// Paragraph code talks directly to a DisplayListBuilder, there may be +// no more reasons to maintain this sub-class. +// See: https://github.com/flutter/flutter/issues/121389 class DlUnknownPathEffect final : public DlPathEffect { public: DlUnknownPathEffect(sk_sp effect) diff --git a/display_list/display_list_unittests.cc b/display_list/display_list_unittests.cc index 145117d995dae..dfbbf877573ec 100644 --- a/display_list/display_list_unittests.cc +++ b/display_list/display_list_unittests.cc @@ -11,7 +11,6 @@ #include "flutter/display_list/display_list.h" #include "flutter/display_list/display_list_blend_mode.h" #include "flutter/display_list/display_list_builder.h" -#include "flutter/display_list/display_list_canvas_recorder.h" #include "flutter/display_list/display_list_paint.h" #include "flutter/display_list/display_list_rtree.h" #include "flutter/display_list/display_list_utils.h" @@ -32,31 +31,13 @@ static std::vector allGroups = using ClipOp = DlCanvas::ClipOp; using PointMode = DlCanvas::PointMode; -#ifndef NDEBUG -TEST(DisplayList, CallMethodAfterBuild) { - DisplayListCanvasRecorder recorder(kTestBounds); - recorder.drawRect(kTestBounds, SkPaint()); - recorder.Build(); - EXPECT_DEATH_IF_SUPPORTED( - recorder.drawRect(kTestBounds, SkPaint()), - "Calling method on DisplayListCanvasRecorder after Build\\(\\)"); -} -#endif // NDEBUG - -TEST(DisplayList, RecorderInitialClipBounds) { - SkRect cull_rect = SkRect::MakeWH(100, 100); - SkIRect clip_bounds = SkIRect::MakeWH(100, 100); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); -} - -TEST(DisplayList, RecorderInitialClipBoundsNaN) { - SkRect cull_rect = SkRect::MakeWH(SK_ScalarNaN, SK_ScalarNaN); - SkIRect clip_bounds = SkIRect::MakeEmpty(); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); +TEST(DisplayList, BuilderCanBeReused) { + DisplayListBuilder builder(kTestBounds); + builder.DrawRect(kTestBounds, DlPaint()); + auto dl = builder.Build(); + builder.DrawRect(kTestBounds, DlPaint()); + auto dl2 = builder.Build(); + ASSERT_TRUE(dl->Equals(dl2)); } TEST(DisplayList, BuilderBoundsTransformComparedToSkia) { @@ -71,45 +52,6 @@ TEST(DisplayList, BuilderBoundsTransformComparedToSkia) { ASSERT_EQ(builder.GetTransform(), canvas->getTotalMatrix()); } -TEST(DisplayList, RecorderClipBoundsAfterClipRect) { - SkRect cull_rect = SkRect::MakeWH(100, 100); - SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20); - SkIRect clip_bounds = SkIRect::MakeLTRB(10, 10, 20, 20); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - canvas->clipRect(clip_rect); - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); -} - -TEST(DisplayList, RecorderClipBoundsAfterClipRRect) { - SkRect cull_rect = SkRect::MakeWH(100, 100); - SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20); - SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 2, 2); - SkIRect clip_bounds = SkIRect::MakeLTRB(10, 10, 20, 20); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - canvas->clipRRect(clip_rrect); - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); -} - -TEST(DisplayList, RecorderClipBoundsAfterClipPath) { - SkRect cull_rect = SkRect::MakeWH(100, 100); - SkPath clip_path = SkPath().addRect(10, 10, 15, 15).addRect(15, 15, 20, 20); - SkIRect clip_bounds = SkIRect::MakeLTRB(10, 10, 20, 20); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - canvas->clipPath(clip_path); - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); -} - -TEST(DisplayList, RecorderInitialClipBoundsNonZero) { - SkRect cull_rect = SkRect::MakeLTRB(10, 10, 100, 100); - SkIRect clip_bounds = SkIRect::MakeLTRB(10, 10, 100, 100); - DisplayListCanvasRecorder recorder(cull_rect); - SkCanvas* canvas = &recorder; - ASSERT_EQ(canvas->getDeviceClipBounds(), clip_bounds); -} - TEST(DisplayList, BuilderInitialClipBounds) { SkRect cull_rect = SkRect::MakeWH(100, 100); SkRect clip_bounds = SkRect::MakeWH(100, 100); @@ -147,7 +89,6 @@ TEST(DisplayList, BuilderClipBoundsAfterClipPath) { SkRect cull_rect = SkRect::MakeWH(100, 100); SkPath clip_path = SkPath().addRect(10, 10, 15, 15).addRect(15, 15, 20, 20); SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20); - DisplayListCanvasRecorder recorder(cull_rect); DisplayListBuilder builder(cull_rect); builder.clipPath(clip_path, ClipOp::kIntersect, false); ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds); @@ -156,7 +97,6 @@ TEST(DisplayList, BuilderClipBoundsAfterClipPath) { TEST(DisplayList, BuilderInitialClipBoundsNonZero) { SkRect cull_rect = SkRect::MakeLTRB(10, 10, 100, 100); SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 100, 100); - DisplayListCanvasRecorder recorder(cull_rect); DisplayListBuilder builder(cull_rect); ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds); } @@ -213,44 +153,6 @@ TEST(DisplayList, SingleOpDisplayListsRecapturedAreEqual) { } } -TEST(DisplayList, SingleOpDisplayListsRecapturedViaSkCanvasAreEqual) { - for (auto& group : allGroups) { - for (size_t i = 0; i < group.variants.size(); i++) { - if (group.variants[i].sk_testing_invalid()) { - continue; - } - // Verify a DisplayList (re)built by "rendering" it to an - // [SkCanvas->DisplayList] recorder recaptures an equivalent - // sequence. - // Note that sometimes the rendering ops can be optimized out by - // SkCanvas so the transfer is not always 1:1. We control for - // this by having separate op counts and sizes for the sk results - // and changing our expectation of Equals() results accordingly. - sk_sp dl = group.variants[i].Build(); - - DisplayListCanvasRecorder recorder(dl->bounds()); - dl->RenderTo(&recorder); - sk_sp sk_copy = recorder.Build(); - auto desc = group.op_name + "[variant " + std::to_string(i + 1) + "]"; - EXPECT_EQ(static_cast(sk_copy->op_count(false)), - group.variants[i].sk_op_count()) - << desc; - EXPECT_EQ(sk_copy->bytes(false), group.variants[i].sk_byte_count()) - << desc; - if (group.variants[i].sk_version_matches()) { - EXPECT_EQ(sk_copy->bounds(), dl->bounds()) << desc; - EXPECT_TRUE(dl->Equals(*sk_copy)) << desc << " == sk_copy"; - EXPECT_TRUE(sk_copy->Equals(*dl)) << "sk_copy == " << desc; - } else { - // No assertion on bounds - // they could be equal, hard to tell - EXPECT_FALSE(dl->Equals(*sk_copy)) << desc << " != sk_copy"; - EXPECT_FALSE(sk_copy->Equals(*dl)) << "sk_copy != " << desc; - } - } - } -} - TEST(DisplayList, SingleOpDisplayListsCompareToEachOther) { for (auto& group : allGroups) { std::vector> lists_a; @@ -595,13 +497,6 @@ TEST(DisplayList, NestedOpCountMetricsSameAsSkPicture) { static_cast(display_list->op_count())); ASSERT_EQ(picture->approximateOpCount(true), static_cast(display_list->op_count(true))); - - DisplayListCanvasRecorder dl_recorder(SkRect::MakeWH(150, 100)); - picture->playback(&dl_recorder); - - auto sk_display_list = dl_recorder.Build(); - ASSERT_EQ(display_list->op_count(), 1u); - ASSERT_EQ(display_list->op_count(true), 36u); } class AttributeRefTester { @@ -627,32 +522,10 @@ class AttributeRefTester { } ASSERT_TRUE(ref_is_unique()); } - void testCanvasRecorder() { - { - sk_sp display_list; - { - DisplayListCanvasRecorder recorder(SkRect::MakeLTRB(0, 0, 200, 200)); - { - { - SkPaint paint; - setRefToPaint(paint); - recorder.drawRect(SkRect::MakeLTRB(50, 50, 100, 100), paint); - ASSERT_FALSE(ref_is_unique()); - } - ASSERT_FALSE(ref_is_unique()); - } - display_list = recorder.Build(); - ASSERT_FALSE(ref_is_unique()); - } - ASSERT_FALSE(ref_is_unique()); - } - ASSERT_TRUE(ref_is_unique()); - } void test() { testDisplayList(); testPaint(); - testCanvasRecorder(); } }; @@ -2528,11 +2401,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), expected)); } { // Rect 1 @@ -2546,11 +2414,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), expected)); } { // Rect 2 @@ -2564,11 +2427,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), expected)); } { // Rect 3 @@ -2582,11 +2440,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), expected)); } { // Rect 4 @@ -2600,11 +2453,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), expected)); } { // All 4 rects @@ -2614,11 +2462,6 @@ TEST(DisplayList, RTreeRenderCulling) { main->RenderTo(&culling_builder); EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), main)); - - DisplayListCanvasRecorder culling_recorder(cull_rect); - main->RenderTo(&culling_recorder); - - EXPECT_TRUE(DisplayListsEQ_Verbose(culling_recorder.Build(), main)); } }