Skip to content

Commit

Permalink
Revert "Reland "Sequester all Skia<->DL interactions into the skia su…
Browse files Browse the repository at this point in the history
…b-module" (flutter#40243)" (flutter#40283)

This reverts commit f9f7706.
  • Loading branch information
flar authored Mar 14, 2023
1 parent 7675de7 commit 2cf597c
Show file tree
Hide file tree
Showing 94 changed files with 3,876 additions and 4,729 deletions.
6 changes: 3 additions & 3 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
../../../flutter/build
../../../flutter/ci
../../../flutter/common/README.md
../../../flutter/display_list/display_list_canvas_unittests.cc
../../../flutter/display_list/display_list_color_filter_unittests.cc
../../../flutter/display_list/display_list_color_source_unittests.cc
../../../flutter/display_list/display_list_color_unittests.cc
../../../flutter/display_list/display_list_complexity_unittests.cc
../../../flutter/display_list/display_list_enum_unittests.cc
../../../flutter/display_list/display_list_image_filter_unittests.cc
../../../flutter/display_list/display_list_mask_filter_unittests.cc
../../../flutter/display_list/display_list_matrix_clip_tracker_unittests.cc
../../../flutter/display_list/display_list_paint_unittests.cc
../../../flutter/display_list/display_list_path_effect_unittests.cc
../../../flutter/display_list/display_list_rtree_unittests.cc
../../../flutter/display_list/display_list_unittests.cc
../../../flutter/display_list/display_list_utils_unittests.cc
../../../flutter/display_list/display_list_vertices_unittests.cc
../../../flutter/display_list/dl_rendering_unittests.cc
../../../flutter/display_list/skia/dl_sk_conversions_unittests.cc
../../../flutter/display_list/skia/dl_sk_utils_unittests.cc
../../../flutter/display_list/testing
../../../flutter/docs
../../../flutter/examples
Expand Down
26 changes: 8 additions & 18 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ ORIGIN: ../../../flutter/display_list/display_list_blend_mode.h + ../../../flutt
ORIGIN: ../../../flutter/display_list/display_list_builder.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_builder.h + ../../../flutter/LICENSE
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_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
Expand All @@ -727,6 +729,8 @@ ORIGIN: ../../../flutter/display_list/display_list_complexity_gl.h + ../../../fl
ORIGIN: ../../../flutter/display_list/display_list_complexity_helper.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_complexity_metal.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_complexity_metal.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_dispatcher.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_dispatcher.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_flags.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_flags.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_image.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -755,18 +759,9 @@ ORIGIN: ../../../flutter/display_list/display_list_utils.cc + ../../../flutter/L
ORIGIN: ../../../flutter/display_list/display_list_utils.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_vertices.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/display_list_vertices.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/dl_canvas.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/dl_canvas.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/dl_op_receiver.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/dl_op_receiver.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_canvas.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_canvas.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_conversions.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_conversions.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_dispatcher.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_dispatcher.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_utils.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/skia/dl_sk_utils.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/flow/compositor_context.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/flow/compositor_context.h + ../../../flutter/LICENSE
Expand Down Expand Up @@ -3252,6 +3247,8 @@ FILE: ../../../flutter/display_list/display_list_blend_mode.h
FILE: ../../../flutter/display_list/display_list_builder.cc
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_color.h
FILE: ../../../flutter/display_list/display_list_color_filter.cc
FILE: ../../../flutter/display_list/display_list_color_filter.h
Expand All @@ -3265,6 +3262,8 @@ FILE: ../../../flutter/display_list/display_list_complexity_gl.h
FILE: ../../../flutter/display_list/display_list_complexity_helper.h
FILE: ../../../flutter/display_list/display_list_complexity_metal.cc
FILE: ../../../flutter/display_list/display_list_complexity_metal.h
FILE: ../../../flutter/display_list/display_list_dispatcher.cc
FILE: ../../../flutter/display_list/display_list_dispatcher.h
FILE: ../../../flutter/display_list/display_list_flags.cc
FILE: ../../../flutter/display_list/display_list_flags.h
FILE: ../../../flutter/display_list/display_list_image.cc
Expand Down Expand Up @@ -3293,18 +3292,9 @@ FILE: ../../../flutter/display_list/display_list_utils.cc
FILE: ../../../flutter/display_list/display_list_utils.h
FILE: ../../../flutter/display_list/display_list_vertices.cc
FILE: ../../../flutter/display_list/display_list_vertices.h
FILE: ../../../flutter/display_list/dl_canvas.cc
FILE: ../../../flutter/display_list/dl_canvas.h
FILE: ../../../flutter/display_list/dl_op_receiver.cc
FILE: ../../../flutter/display_list/dl_op_receiver.h
FILE: ../../../flutter/display_list/skia/dl_sk_canvas.cc
FILE: ../../../flutter/display_list/skia/dl_sk_canvas.h
FILE: ../../../flutter/display_list/skia/dl_sk_conversions.cc
FILE: ../../../flutter/display_list/skia/dl_sk_conversions.h
FILE: ../../../flutter/display_list/skia/dl_sk_dispatcher.cc
FILE: ../../../flutter/display_list/skia/dl_sk_dispatcher.h
FILE: ../../../flutter/display_list/skia/dl_sk_utils.cc
FILE: ../../../flutter/display_list/skia/dl_sk_utils.h
FILE: ../../../flutter/display_list/types.h
FILE: ../../../flutter/flow/compositor_context.cc
FILE: ../../../flutter/flow/compositor_context.h
Expand Down
19 changes: 7 additions & 12 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ source_set("display_list") {
"display_list_blend_mode.h",
"display_list_builder.cc",
"display_list_builder.h",
"display_list_canvas_dispatcher.cc",
"display_list_canvas_dispatcher.h",
"display_list_color.h",
"display_list_color_filter.cc",
"display_list_color_filter.h",
Expand All @@ -35,6 +37,8 @@ source_set("display_list") {
"display_list_complexity_gl.h",
"display_list_complexity_metal.cc",
"display_list_complexity_metal.h",
"display_list_dispatcher.cc",
"display_list_dispatcher.h",
"display_list_flags.cc",
"display_list_flags.h",
"display_list_image.cc",
Expand Down Expand Up @@ -63,18 +67,9 @@ source_set("display_list") {
"display_list_utils.h",
"display_list_vertices.cc",
"display_list_vertices.h",
"dl_canvas.cc",
"dl_canvas.h",
"dl_op_receiver.cc",
"dl_op_receiver.h",
"skia/dl_sk_canvas.cc",
"skia/dl_sk_canvas.h",
"skia/dl_sk_conversions.cc",
"skia/dl_sk_conversions.h",
"skia/dl_sk_dispatcher.cc",
"skia/dl_sk_dispatcher.h",
"skia/dl_sk_utils.cc",
"skia/dl_sk_utils.h",
"types.h",
]

Expand Down Expand Up @@ -104,16 +99,16 @@ if (enable_unittests) {
"display_list_color_source_unittests.cc",
"display_list_color_unittests.cc",
"display_list_complexity_unittests.cc",
"display_list_enum_unittests.cc",
"display_list_image_filter_unittests.cc",
"display_list_mask_filter_unittests.cc",
"display_list_matrix_clip_tracker_unittests.cc",
"display_list_paint_unittests.cc",
"display_list_path_effect_unittests.cc",
"display_list_rtree_unittests.cc",
"display_list_unittests.cc",
"display_list_utils_unittests.cc",
"display_list_vertices_unittests.cc",
"skia/dl_sk_conversions_unittests.cc",
"skia/dl_sk_utils_unittests.cc",
]

deps = [
Expand Down Expand Up @@ -141,7 +136,7 @@ if (enable_unittests) {
executable("display_list_rendertests") {
testonly = true

sources = [ "dl_rendering_unittests.cc" ]
sources = [ "display_list_canvas_unittests.cc" ]

deps = [
":display_list",
Expand Down
40 changes: 30 additions & 10 deletions display_list/display_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#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_ops.h"
#include "flutter/fml/trace_event.h"

Expand Down Expand Up @@ -133,40 +134,38 @@ class VectorCuller final : public Culler {
std::vector<int>::const_iterator end_;
};

void DisplayList::Dispatch(DlOpReceiver& receiver) const {
void DisplayList::Dispatch(Dispatcher& ctx) const {
uint8_t* ptr = storage_.get();
Dispatch(receiver, ptr, ptr + byte_count_, NopCuller::instance);
Dispatch(ctx, ptr, ptr + byte_count_, NopCuller::instance);
}

void DisplayList::Dispatch(DlOpReceiver& receiver,
const SkRect& cull_rect) const {
void DisplayList::Dispatch(Dispatcher& ctx, const SkRect& cull_rect) const {
if (cull_rect.isEmpty()) {
return;
}
if (cull_rect.contains(bounds())) {
Dispatch(receiver);
Dispatch(ctx);
return;
}
const DlRTree* rtree = this->rtree().get();
FML_DCHECK(rtree != nullptr);
if (rtree == nullptr) {
FML_LOG(ERROR) << "dispatched with culling rect on DL with no rtree";
Dispatch(receiver);
Dispatch(ctx);
return;
}
uint8_t* ptr = storage_.get();
std::vector<int> rect_indices;
rtree->search(cull_rect, &rect_indices);
VectorCuller culler(rtree, rect_indices);
Dispatch(receiver, ptr, ptr + byte_count_, culler);
Dispatch(ctx, ptr, ptr + byte_count_, culler);
}

void DisplayList::Dispatch(DlOpReceiver& receiver,
void DisplayList::Dispatch(Dispatcher& dispatcher,
uint8_t* ptr,
uint8_t* end,
Culler& culler) const {
DispatchContext context = {
.receiver = receiver,
.dispatcher = dispatcher,
.cur_index = 0,
// next_render_index will be initialized by culler.init()
.next_restore_index = std::numeric_limits<int>::max(),
Expand Down Expand Up @@ -295,6 +294,27 @@ static bool CompareOps(uint8_t* ptrA,
return true;
}

void DisplayList::RenderTo(DisplayListBuilder* builder) const {
if (!builder) {
return;
}
if (has_rtree()) {
Dispatch(builder->asDispatcher(), builder->GetLocalClipBounds());
} else {
Dispatch(builder->asDispatcher());
}
}

void DisplayList::RenderTo(SkCanvas* canvas, SkScalar opacity) const {
FML_DCHECK(can_apply_group_opacity() || opacity >= SK_Scalar1);
DisplayListCanvasDispatcher dispatcher(canvas, opacity);
if (has_rtree()) {
Dispatch(dispatcher, canvas->getLocalClipBounds());
} else {
Dispatch(dispatcher);
}
}

bool DisplayList::Equals(const DisplayList* other) const {
if (this == other) {
return true;
Expand Down
51 changes: 30 additions & 21 deletions display_list/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,41 @@
//
// This file contains the definitions for:
// DisplayList: the base class that holds the information about the
// sequence of operations and can dispatch them to a DlOpReceiver
// DlOpReceiver: a pure virtual interface which can be implemented to field
// the requests for purposes such as sending them to an SkCanvas
// or detecting various rendering optimization scenarios
// DisplayListBuilder: a class for constructing a DisplayList from DlCanvas
// method calls and which can act as a DlOpReceiver as well
// sequence of operations and can dispatch them to a Dispatcher
// Dispatcher: a pure virtual interface which can be implemented to field
// the requests for purposes such as sending them to an SkCanvas
// or detecting various rendering optimization scenarios
// DisplayListBuilder: a class for constructing a DisplayList from the same
// calls defined in the Dispatcher
//
// Other files include various class definitions for dealing with display
// lists, such as:
// skia/dl_sk_*.h: classes to interact between SkCanvas and DisplayList
// (SkCanvas->DisplayList adapter and vice versa)
// display_list_canvas.h: classes to interact between SkCanvas and DisplayList
// (SkCanvas->DisplayList adapter and vice versa)
//
// display_list_utils.h: various utility classes to ease implementing
// a DlOpReceiver, including NOP implementations of
// a Dispatcher, including NOP implementations of
// the attribute, clip, and transform methods,
// classes to track attributes, clips, and transforms
// and a class to compute the bounds of a DisplayList
// Any class implementing DlOpReceiver can inherit from
// Any class implementing Dispatcher can inherit from
// these utility classes to simplify its creation
//
// The Flutter DisplayList mechanism is used in a similar manner to the Skia
// SkPicture mechanism.
// 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
// to method calls.
//
// A DisplayList must be created using a DisplayListBuilder using its stateless
// methods inherited from DlCanvas.
// 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 DlOpReceiver virtual
// A DisplayList can be read back by implementing the Dispatcher virtual
// methods (with help from some of the classes in the utils file) and
// passing an instance to the Dispatch() method, or it can be rendered
// to Skia using a DlSkCanvasDispatcher.
// passing an instance to the dispatch() method, or it can be rendered
// to Skia using a DisplayListCanvasDispatcher or simply by passing an
// SkCanvas pointer to its renderTo() method.
//
// The mechanism is inspired by the SkLiteDL class that is not directly
// supported by Skia, but has been recommended as a basis for custom
Expand Down Expand Up @@ -150,7 +155,7 @@ enum class DisplayListOpType {
};
#undef DL_OP_TO_ENUM_VALUE

class DlOpReceiver;
class Dispatcher;
class DisplayListBuilder;

class SaveLayerOptions {
Expand Down Expand Up @@ -226,16 +231,20 @@ class DisplayListStorage {
class Culler;

// The base class that contains a sequence of rendering operations
// for dispatch to a DlOpReceiver. These objects must be instantiated
// for dispatch to a Dispatcher. These objects must be instantiated
// through an instance of DisplayListBuilder::build().
class DisplayList : public SkRefCnt {
public:
DisplayList();

~DisplayList();

void Dispatch(DlOpReceiver& ctx) const;
void Dispatch(DlOpReceiver& ctx, const SkRect& cull_rect) const;
void Dispatch(Dispatcher& ctx) const;
void Dispatch(Dispatcher& ctx, const SkRect& cull_rect) const;

void RenderTo(DisplayListBuilder* builder) const;

void RenderTo(SkCanvas* canvas, SkScalar opacity = SK_Scalar1) const;

// From historical behavior, SkPicture always included nested bytes,
// but nested ops are only included if requested. The defaults used
Expand Down Expand Up @@ -291,7 +300,7 @@ class DisplayList : public SkRefCnt {
const bool can_apply_group_opacity_;
const sk_sp<const DlRTree> rtree_;

void Dispatch(DlOpReceiver& ctx,
void Dispatch(Dispatcher& ctx,
uint8_t* ptr,
uint8_t* end,
Culler& culler) const;
Expand Down
Loading

0 comments on commit 2cf597c

Please sign in to comment.