Flutter Impeller
impeller::DlDispatcherBase Class Referenceabstract

#include <dl_dispatcher.h>

Inheritance diagram for impeller::DlDispatcherBase:
impeller::CanvasDlDispatcher

Public Member Functions

void setAntiAlias (bool aa) override
 
void setDrawStyle (flutter::DlDrawStyle style) override
 
void setColor (flutter::DlColor color) override
 
void setStrokeWidth (DlScalar width) override
 
void setStrokeMiter (DlScalar limit) override
 
void setStrokeCap (flutter::DlStrokeCap cap) override
 
void setStrokeJoin (flutter::DlStrokeJoin join) override
 
void setColorSource (const flutter::DlColorSource *source) override
 
void setColorFilter (const flutter::DlColorFilter *filter) override
 
void setInvertColors (bool invert) override
 
void setBlendMode (flutter::DlBlendMode mode) override
 
void setMaskFilter (const flutter::DlMaskFilter *filter) override
 
void setImageFilter (const flutter::DlImageFilter *filter) override
 
void save (uint32_t total_content_depth) override
 
void saveLayer (const DlRect &bounds, const flutter::SaveLayerOptions &options, uint32_t total_content_depth, flutter::DlBlendMode max_content_mode, const flutter::DlImageFilter *backdrop, std::optional< int64_t > backdrop_id) override
 
void restore () override
 
void translate (DlScalar tx, DlScalar ty) override
 
void scale (DlScalar sx, DlScalar sy) override
 
void rotate (DlScalar degrees) override
 
void skew (DlScalar sx, DlScalar sy) override
 
void transform2DAffine (DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt) override
 
void transformFullPerspective (DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
 
void transformReset () override
 
void clipRect (const DlRect &rect, flutter::DlClipOp clip_op, bool is_aa) override
 
void clipOval (const DlRect &bounds, flutter::DlClipOp clip_op, bool is_aa) override
 
void clipRoundRect (const DlRoundRect &rrect, flutter::DlClipOp clip_op, bool is_aa) override
 
void clipRoundSuperellipse (const DlRoundSuperellipse &rse, flutter::DlClipOp clip_op, bool is_aa) override
 
void clipPath (const DlPath &path, flutter::DlClipOp clip_op, bool is_aa) override
 
void drawColor (flutter::DlColor color, flutter::DlBlendMode mode) override
 
void drawPaint () override
 
void drawLine (const DlPoint &p0, const DlPoint &p1) override
 
void drawDashedLine (const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
 
void drawRect (const DlRect &rect) override
 
void drawOval (const DlRect &bounds) override
 
void drawCircle (const DlPoint &center, DlScalar radius) override
 
void drawRoundRect (const DlRoundRect &rrect) override
 
void drawDiffRoundRect (const DlRoundRect &outer, const DlRoundRect &inner) override
 
void drawRoundSuperellipse (const DlRoundSuperellipse &rse) override
 
void drawPath (const DlPath &path) override
 
void drawArc (const DlRect &oval_bounds, DlScalar start_degrees, DlScalar sweep_degrees, bool use_center) override
 
void drawPoints (flutter::DlPointMode mode, uint32_t count, const DlPoint points[]) override
 
void drawVertices (const std::shared_ptr< flutter::DlVertices > &vertices, flutter::DlBlendMode dl_mode) override
 
void drawImage (const sk_sp< flutter::DlImage > image, const DlPoint &point, flutter::DlImageSampling sampling, bool render_with_attributes) override
 
void drawImageRect (const sk_sp< flutter::DlImage > image, const DlRect &src, const DlRect &dst, flutter::DlImageSampling sampling, bool render_with_attributes, flutter::DlSrcRectConstraint constraint) override
 
void drawImageNine (const sk_sp< flutter::DlImage > image, const DlIRect &center, const DlRect &dst, flutter::DlFilterMode filter, bool render_with_attributes) override
 
void drawAtlas (const sk_sp< flutter::DlImage > atlas, const RSTransform xform[], const DlRect tex[], const flutter::DlColor colors[], int count, flutter::DlBlendMode mode, flutter::DlImageSampling sampling, const DlRect *cull_rect, bool render_with_attributes) override
 
void drawDisplayList (const sk_sp< flutter::DisplayList > display_list, DlScalar opacity) override
 
void drawTextBlob (const sk_sp< SkTextBlob > blob, DlScalar x, DlScalar y) override
 
void drawTextFrame (const std::shared_ptr< impeller::TextFrame > &text_frame, DlScalar x, DlScalar y) override
 
void drawShadow (const DlPath &path, const flutter::DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
 
virtual CanvasGetCanvas ()=0
 

Static Protected Member Functions

static void SimplifyOrDrawPath (Canvas &canvas, const DlPath &cache, const Paint &paint)
 

Protected Attributes

Paint paint_
 
Matrix initial_matrix_
 

Detailed Description

Definition at line 31 of file dl_dispatcher.h.

Member Function Documentation

◆ clipOval()

void impeller::DlDispatcherBase::clipOval ( const DlRect bounds,
flutter::DlClipOp  clip_op,
bool  is_aa 
)
override

Definition at line 447 of file dl_dispatcher.cc.

449  {
450  AUTO_DEPTH_WATCHER(0u);
451 
452  EllipseGeometry geom(bounds);
453  GetCanvas().ClipGeometry(geom, ToClipOperation(clip_op));
454 }
void ClipGeometry(const Geometry &geometry, Entity::ClipOperation clip_op, bool is_aa=true)
Definition: canvas.cc:826
virtual Canvas & GetCanvas()=0
#define AUTO_DEPTH_WATCHER(d)
static Entity::ClipOperation ToClipOperation(flutter::DlClipOp clip_op)

References AUTO_DEPTH_WATCHER, impeller::Canvas::ClipGeometry(), GetCanvas(), and impeller::ToClipOperation().

◆ clipPath()

void impeller::DlDispatcherBase::clipPath ( const DlPath path,
flutter::DlClipOp  clip_op,
bool  is_aa 
)
override

Definition at line 498 of file dl_dispatcher.cc.

500  {
501  AUTO_DEPTH_WATCHER(0u);
502 
503  auto clip_op = ToClipOperation(sk_op);
504 
505  DlRect rect;
506  if (path.IsRect(&rect)) {
507  FillRectGeometry geom(rect);
508  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
509  } else if (path.IsOval(&rect)) {
510  EllipseGeometry geom(rect);
511  GetCanvas().ClipGeometry(geom, clip_op);
512  } else {
513  DlRoundRect rrect;
514  if (path.IsRoundRect(&rrect) && rrect.GetRadii().AreAllCornersSame()) {
515  RoundRectGeometry geom(rrect.GetBounds(), rrect.GetRadii().top_left);
516  GetCanvas().ClipGeometry(geom, clip_op);
517  } else {
518  FillPathGeometry geom(path);
519  GetCanvas().ClipGeometry(geom, clip_op);
520  }
521  }
522 }
flutter::DlRect DlRect
Definition: dl_dispatcher.h:25
flutter::DlRoundRect DlRoundRect
Definition: dl_dispatcher.h:27

References AUTO_DEPTH_WATCHER, impeller::Canvas::ClipGeometry(), GetCanvas(), and impeller::ToClipOperation().

◆ clipRect()

void impeller::DlDispatcherBase::clipRect ( const DlRect rect,
flutter::DlClipOp  clip_op,
bool  is_aa 
)
override

Definition at line 437 of file dl_dispatcher.cc.

439  {
440  AUTO_DEPTH_WATCHER(0u);
441 
442  FillRectGeometry geom(rect);
443  GetCanvas().ClipGeometry(geom, ToClipOperation(clip_op), /*is_aa=*/is_aa);
444 }

References AUTO_DEPTH_WATCHER, impeller::Canvas::ClipGeometry(), GetCanvas(), and impeller::ToClipOperation().

◆ clipRoundRect()

void impeller::DlDispatcherBase::clipRoundRect ( const DlRoundRect rrect,
flutter::DlClipOp  clip_op,
bool  is_aa 
)
override

Definition at line 457 of file dl_dispatcher.cc.

459  {
460  AUTO_DEPTH_WATCHER(0u);
461 
462  auto clip_op = ToClipOperation(sk_op);
463  if (rrect.IsRect()) {
464  FillRectGeometry geom(rrect.GetBounds());
465  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
466  } else if (rrect.IsOval()) {
467  EllipseGeometry geom(rrect.GetBounds());
468  GetCanvas().ClipGeometry(geom, clip_op);
469  } else if (rrect.GetRadii().AreAllCornersSame()) {
470  RoundRectGeometry geom(rrect.GetBounds(), rrect.GetRadii().top_left);
471  GetCanvas().ClipGeometry(geom, clip_op);
472  } else {
473  FillRoundRectGeometry geom(rrect);
474  GetCanvas().ClipGeometry(geom, clip_op);
475  }
476 }

References AUTO_DEPTH_WATCHER, impeller::Canvas::ClipGeometry(), GetCanvas(), and impeller::ToClipOperation().

◆ clipRoundSuperellipse()

void impeller::DlDispatcherBase::clipRoundSuperellipse ( const DlRoundSuperellipse rse,
flutter::DlClipOp  clip_op,
bool  is_aa 
)
override

Definition at line 479 of file dl_dispatcher.cc.

481  {
482  AUTO_DEPTH_WATCHER(0u);
483 
484  auto clip_op = ToClipOperation(sk_op);
485  if (rse.IsRect()) {
486  FillRectGeometry geom(rse.GetBounds());
487  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
488  } else if (rse.IsOval()) {
489  EllipseGeometry geom(rse.GetBounds());
490  GetCanvas().ClipGeometry(geom, clip_op);
491  } else {
492  RoundSuperellipseGeometry geom(rse.GetBounds(), rse.GetRadii());
493  GetCanvas().ClipGeometry(geom, clip_op);
494  }
495 }

References AUTO_DEPTH_WATCHER, impeller::Canvas::ClipGeometry(), GetCanvas(), and impeller::ToClipOperation().

◆ drawArc()

void impeller::DlDispatcherBase::drawArc ( const DlRect oval_bounds,
DlScalar  start_degrees,
DlScalar  sweep_degrees,
bool  use_center 
)
override

Definition at line 643 of file dl_dispatcher.cc.

646  {
647  AUTO_DEPTH_WATCHER(1u);
648 
649  GetCanvas().DrawArc(Arc(oval_bounds, Degrees(start_degrees),
650  Degrees(sweep_degrees), use_center),
651  paint_);
652 }
bool use_center
void DrawArc(const Arc &arc, const Paint &paint)
Definition: canvas.cc:678

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawArc(), GetCanvas(), paint_, and use_center.

◆ drawAtlas()

void impeller::DlDispatcherBase::drawAtlas ( const sk_sp< flutter::DlImage >  atlas,
const RSTransform  xform[],
const DlRect  tex[],
const flutter::DlColor  colors[],
int  count,
flutter::DlBlendMode  mode,
flutter::DlImageSampling  sampling,
const DlRect cull_rect,
bool  render_with_attributes 
)
override

Definition at line 763 of file dl_dispatcher.cc.

771  {
772  AUTO_DEPTH_WATCHER(1u);
773 
774  auto geometry =
775  DlAtlasGeometry(atlas->impeller_texture(), //
776  xform, //
777  tex, //
778  colors, //
779  static_cast<size_t>(count), //
780  mode, //
782  ToOptRect(cull_rect) //
783  );
784  auto atlas_contents = std::make_shared<AtlasContents>();
785  atlas_contents->SetGeometry(&geometry);
786 
787  GetCanvas().DrawAtlas(atlas_contents, paint_);
788 }
void DrawAtlas(const std::shared_ptr< AtlasContents > &atlas_contents, const Paint &paint)
Definition: canvas.cc:1117
impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
static std::optional< const Rect > ToOptRect(const flutter::DlRect *rect)

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawAtlas(), GetCanvas(), paint_, impeller::ToOptRect(), and impeller::skia_conversions::ToSamplerDescriptor().

◆ drawCircle()

void impeller::DlDispatcherBase::drawCircle ( const DlPoint center,
DlScalar  radius 
)
override

Definition at line 574 of file dl_dispatcher.cc.

574  {
575  AUTO_DEPTH_WATCHER(1u);
576 
577  GetCanvas().DrawCircle(center, radius, paint_);
578 }
void DrawCircle(const Point &center, Scalar radius, const Paint &paint)
Definition: canvas.cc:803

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawCircle(), GetCanvas(), and paint_.

◆ drawColor()

void impeller::DlDispatcherBase::drawColor ( flutter::DlColor  color,
flutter::DlBlendMode  mode 
)
override

Definition at line 525 of file dl_dispatcher.cc.

526  {
527  AUTO_DEPTH_WATCHER(1u);
528 
529  Paint paint;
530  paint.color = skia_conversions::ToColor(color);
531  paint.blend_mode = dl_mode;
532  GetCanvas().DrawPaint(paint);
533 }
void DrawPaint(const Paint &paint)
Definition: canvas.cc:340
Color ToColor(const flutter::DlColor &color)

References AUTO_DEPTH_WATCHER, impeller::Paint::blend_mode, impeller::Paint::color, impeller::Canvas::DrawPaint(), GetCanvas(), and impeller::skia_conversions::ToColor().

◆ drawDashedLine()

void impeller::DlDispatcherBase::drawDashedLine ( const DlPoint p0,
const DlPoint p1,
DlScalar  on_length,
DlScalar  off_length 
)
override

Definition at line 550 of file dl_dispatcher.cc.

553  {
554  AUTO_DEPTH_WATCHER(1u);
555 
556  GetCanvas().DrawDashedLine(p0, p1, on_length, off_length, paint_);
557 }
void DrawDashedLine(const Point &p0, const Point &p1, Scalar on_length, Scalar off_length, const Paint &paint)
Definition: canvas.cc:605

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawDashedLine(), GetCanvas(), and paint_.

◆ drawDiffRoundRect()

void impeller::DlDispatcherBase::drawDiffRoundRect ( const DlRoundRect outer,
const DlRoundRect inner 
)
override

Definition at line 588 of file dl_dispatcher.cc.

589  {
590  AUTO_DEPTH_WATCHER(1u);
591 
592  GetCanvas().DrawDiffRoundRect(outer, inner, paint_);
593 }
void DrawDiffRoundRect(const RoundRect &outer, const RoundRect &inner, const Paint &paint)
Definition: canvas.cc:765

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawDiffRoundRect(), GetCanvas(), and paint_.

◆ drawDisplayList()

void impeller::DlDispatcherBase::drawDisplayList ( const sk_sp< flutter::DisplayList >  display_list,
DlScalar  opacity 
)
override

Definition at line 791 of file dl_dispatcher.cc.

793  {
794  AUTO_DEPTH_WATCHER(display_list->total_depth());
795 
796  // Save all values that must remain untouched after the operation.
797  Paint saved_paint = paint_;
798  Matrix saved_initial_matrix = initial_matrix_;
799 
800  // Establish a new baseline for interpreting the new DL.
801  // Matrix and clip are left untouched, the current
802  // transform is saved as the new base matrix, and paint
803  // values are reset to defaults.
805  paint_ = Paint();
806 
807  // Handle passed opacity in the most brute-force way by using
808  // a SaveLayer. If the display_list is able to inherit the
809  // opacity, this could also be handled by modulating all of its
810  // attribute settings (for example, color), by the indicated
811  // opacity.
812  int restore_count = GetCanvas().GetSaveCount();
813  if (opacity < SK_Scalar1) {
814  Paint save_paint;
815  save_paint.color = Color(0, 0, 0, opacity);
816  GetCanvas().SaveLayer(save_paint, display_list->GetBounds(), nullptr,
818  display_list->total_depth(),
819  display_list->can_apply_group_opacity());
820  } else {
821  // The display list may alter the clip, which must be restored to the
822  // current clip at the end of playback.
823  GetCanvas().Save(display_list->total_depth());
824  }
825 
826  // TODO(131445): Remove this restriction if we can correctly cull with
827  // perspective transforms.
828  if (display_list->has_rtree() && !initial_matrix_.HasPerspective()) {
829  // The canvas remembers the screen-space culling bounds clipped by
830  // the surface and the history of clip calls. DisplayList can cull
831  // the ops based on a rectangle expressed in its "destination bounds"
832  // so we need the canvas to transform those into the current local
833  // coordinate space into which the DisplayList will be rendered.
834  auto global_culling_bounds = GetCanvas().GetLocalCoverageLimit();
835  if (global_culling_bounds.has_value()) {
836  Rect cull_rect = global_culling_bounds->TransformBounds(
837  GetCanvas().GetCurrentTransform().Invert());
838  display_list->Dispatch(*this, cull_rect);
839  } else {
840  // If the culling bounds are empty, this display list can be skipped
841  // entirely.
842  }
843  } else {
844  display_list->Dispatch(*this);
845  }
846 
847  // Restore all saved state back to what it was before we interpreted
848  // the display_list
850  GetCanvas().RestoreToCount(restore_count);
851  initial_matrix_ = saved_initial_matrix;
852  paint_ = saved_paint;
853 }
std::optional< Rect > GetLocalCoverageLimit() const
Return the culling bounds of the current render target, or nullopt if there is no coverage.
Definition: canvas.cc:1200
void SaveLayer(const Paint &paint, std::optional< Rect > bounds=std::nullopt, const flutter::DlImageFilter *backdrop_filter=nullptr, ContentBoundsPromise bounds_promise=ContentBoundsPromise::kUnknown, uint32_t total_content_depth=kMaxDepth, bool can_distribute_opacity=false, std::optional< int64_t > backdrop_id=std::nullopt)
Definition: canvas.cc:1231
const Matrix & GetCurrentTransform() const
Definition: canvas.cc:271
void RestoreToCount(size_t count)
Definition: canvas.cc:318
size_t GetSaveCount() const
Definition: canvas.cc:310
void Save(uint32_t total_content_depth=kMaxDepth)
Definition: canvas.cc:1183
#define AUTO_DEPTH_CHECK()
TRect< Scalar > Rect
Definition: rect.h:792
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
constexpr bool HasPerspective() const
Definition: matrix.h:365
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:476

References AUTO_DEPTH_CHECK, AUTO_DEPTH_WATCHER, impeller::Paint::color, GetCanvas(), impeller::Canvas::GetCurrentTransform(), impeller::Canvas::GetLocalCoverageLimit(), impeller::Canvas::GetSaveCount(), impeller::Matrix::HasPerspective(), initial_matrix_, impeller::kContainsContents, paint_, impeller::Canvas::RestoreToCount(), impeller::Canvas::Save(), impeller::Canvas::SaveLayer(), and impeller::TRect< T >::TransformBounds().

◆ drawImage()

void impeller::DlDispatcherBase::drawImage ( const sk_sp< flutter::DlImage >  image,
const DlPoint point,
flutter::DlImageSampling  sampling,
bool  render_with_attributes 
)
override

Definition at line 699 of file dl_dispatcher.cc.

702  {
703  AUTO_DEPTH_WATCHER(1u);
704 
705  if (!image) {
706  return;
707  }
708 
709  auto texture = image->impeller_texture();
710  if (!texture) {
711  return;
712  }
713 
714  const auto size = texture->GetSize();
715  const auto src = DlRect::MakeWH(size.width, size.height);
716  const auto dest = DlRect::MakeXYWH(point.x, point.y, size.width, size.height);
717 
718  drawImageRect(image, // image
719  src, // source rect
720  dest, // destination rect
721  sampling, // sampling options
722  render_with_attributes, // render with attributes
723  flutter::DlSrcRectConstraint::kStrict // constraint
724  );
725 }
void drawImageRect(const sk_sp< flutter::DlImage > image, const DlRect &src, const DlRect &dst, flutter::DlImageSampling sampling, bool render_with_attributes, flutter::DlSrcRectConstraint constraint) override

References AUTO_DEPTH_WATCHER, and drawImageRect().

◆ drawImageNine()

void impeller::DlDispatcherBase::drawImageNine ( const sk_sp< flutter::DlImage >  image,
const DlIRect center,
const DlRect dst,
flutter::DlFilterMode  filter,
bool  render_with_attributes 
)
override

Definition at line 747 of file dl_dispatcher.cc.

751  {
752  AUTO_DEPTH_WATCHER(9u);
753 
754  NinePatchConverter converter = {};
755  converter.DrawNinePatch(image->impeller_texture(),
756  Rect::MakeLTRB(center.GetLeft(), center.GetTop(),
757  center.GetRight(), center.GetBottom()),
758  dst, ToSamplerDescriptor(filter), &GetCanvas(),
759  &paint_);
760 }
static impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlFilterMode options)
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129

References AUTO_DEPTH_WATCHER, impeller::NinePatchConverter::DrawNinePatch(), GetCanvas(), impeller::TRect< Scalar >::MakeLTRB(), paint_, and impeller::ToSamplerDescriptor().

◆ drawImageRect()

void impeller::DlDispatcherBase::drawImageRect ( const sk_sp< flutter::DlImage >  image,
const DlRect src,
const DlRect dst,
flutter::DlImageSampling  sampling,
bool  render_with_attributes,
flutter::DlSrcRectConstraint  constraint = flutter::DlSrcRectConstraint::kFast 
)
override

Definition at line 728 of file dl_dispatcher.cc.

734  {
735  AUTO_DEPTH_WATCHER(1u);
736 
738  image->impeller_texture(), // image
739  src, // source rect
740  dst, // destination rect
741  render_with_attributes ? paint_ : Paint(), // paint
742  skia_conversions::ToSamplerDescriptor(sampling) // sampling
743  );
744 }
void DrawImageRect(const std::shared_ptr< Texture > &image, Rect source, Rect dest, const Paint &paint, const SamplerDescriptor &sampler={}, SourceRectConstraint src_rect_constraint=SourceRectConstraint::kFast)
Definition: canvas.cc:939

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawImageRect(), GetCanvas(), paint_, and impeller::skia_conversions::ToSamplerDescriptor().

Referenced by drawImage().

◆ drawLine()

void impeller::DlDispatcherBase::drawLine ( const DlPoint p0,
const DlPoint p1 
)
override

Definition at line 543 of file dl_dispatcher.cc.

543  {
544  AUTO_DEPTH_WATCHER(1u);
545 
546  GetCanvas().DrawLine(p0, p1, paint_);
547 }
void DrawLine(const Point &p0, const Point &p1, const Paint &paint, bool reuse_depth=false)
Definition: canvas.cc:583

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawLine(), GetCanvas(), and paint_.

◆ drawOval()

void impeller::DlDispatcherBase::drawOval ( const DlRect bounds)
override

Definition at line 567 of file dl_dispatcher.cc.

567  {
568  AUTO_DEPTH_WATCHER(1u);
569 
570  GetCanvas().DrawOval(bounds, paint_);
571 }
void DrawOval(const Rect &rect, const Paint &paint)
Definition: canvas.cc:649

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawOval(), GetCanvas(), and paint_.

◆ drawPaint()

void impeller::DlDispatcherBase::drawPaint ( )
override

Definition at line 536 of file dl_dispatcher.cc.

536  {
537  AUTO_DEPTH_WATCHER(1u);
538 
540 }

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawPaint(), GetCanvas(), and paint_.

◆ drawPath()

void impeller::DlDispatcherBase::drawPath ( const DlPath path)
override

Definition at line 603 of file dl_dispatcher.cc.

603  {
604  AUTO_DEPTH_WATCHER(1u);
605 
607 }
static void SimplifyOrDrawPath(Canvas &canvas, const DlPath &cache, const Paint &paint)

References AUTO_DEPTH_WATCHER, GetCanvas(), paint_, and SimplifyOrDrawPath().

◆ drawPoints()

void impeller::DlDispatcherBase::drawPoints ( flutter::DlPointMode  mode,
uint32_t  count,
const DlPoint  points[] 
)
override

Definition at line 655 of file dl_dispatcher.cc.

657  {
658  AUTO_DEPTH_WATCHER(1u);
659 
660  Paint paint = paint_;
662  switch (mode) {
663  case flutter::DlPointMode::kPoints: {
664  // Cap::kButt is also treated as a square.
665  PointStyle point_style = paint.stroke.cap == Cap::kRound
668  Scalar radius = paint.stroke.width;
669  if (radius > 0) {
670  radius /= 2.0;
671  }
672  GetCanvas().DrawPoints(points, count, radius, paint, point_style);
673  } break;
674  case flutter::DlPointMode::kLines:
675  for (uint32_t i = 1; i < count; i += 2) {
676  Point p0 = points[i - 1];
677  Point p1 = points[i];
678  GetCanvas().DrawLine(p0, p1, paint, /*reuse_depth=*/i > 1);
679  }
680  break;
681  case flutter::DlPointMode::kPolygon:
682  if (count > 1) {
683  Point p0 = points[0];
684  for (uint32_t i = 1; i < count; i++) {
685  Point p1 = points[i];
686  GetCanvas().DrawLine(p0, p1, paint, /*reuse_depth=*/i > 1);
687  p0 = p1;
688  }
689  }
690  break;
691  }
692 }
void DrawPoints(const Point points[], uint32_t count, Scalar radius, const Paint &paint, PointStyle point_style)
Definition: canvas.cc:907
float Scalar
Definition: scalar.h:19
PointStyle
Definition: canvas.h:65
@ kRound
Points are drawn as squares.
@ kSquare
Points are drawn as circles.
TPoint< Scalar > Point
Definition: point.h:327
Style style
Definition: paint.h:81
std::vector< Point > points

References AUTO_DEPTH_WATCHER, impeller::StrokeParameters::cap, impeller::Canvas::DrawLine(), impeller::Canvas::DrawPoints(), GetCanvas(), impeller::kRound, impeller::kSquare, impeller::Paint::kStroke, paint_, points, impeller::Paint::stroke, impeller::Paint::style, and impeller::StrokeParameters::width.

◆ drawRect()

void impeller::DlDispatcherBase::drawRect ( const DlRect rect)
override

Definition at line 560 of file dl_dispatcher.cc.

560  {
561  AUTO_DEPTH_WATCHER(1u);
562 
563  GetCanvas().DrawRect(rect, paint_);
564 }
void DrawRect(const Rect &rect, const Paint &paint)
Definition: canvas.cc:631

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawRect(), GetCanvas(), and paint_.

◆ drawRoundRect()

void impeller::DlDispatcherBase::drawRoundRect ( const DlRoundRect rrect)
override

Definition at line 581 of file dl_dispatcher.cc.

581  {
582  AUTO_DEPTH_WATCHER(1u);
583 
584  GetCanvas().DrawRoundRect(rrect, paint_);
585 }
void DrawRoundRect(const RoundRect &rect, const Paint &paint)
Definition: canvas.cc:733

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawRoundRect(), GetCanvas(), and paint_.

◆ drawRoundSuperellipse()

void impeller::DlDispatcherBase::drawRoundSuperellipse ( const DlRoundSuperellipse rse)
override

Definition at line 596 of file dl_dispatcher.cc.

596  {
597  AUTO_DEPTH_WATCHER(1u);
598 
600 }
void DrawRoundSuperellipse(const RoundSuperellipse &rse, const Paint &paint)
Definition: canvas.cc:781

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawRoundSuperellipse(), GetCanvas(), and paint_.

◆ drawShadow()

void impeller::DlDispatcherBase::drawShadow ( const DlPath path,
const flutter::DlColor  color,
const DlScalar  elevation,
bool  transparent_occluder,
DlScalar  dpr 
)
override

Definition at line 878 of file dl_dispatcher.cc.

882  {
883  AUTO_DEPTH_WATCHER(1u);
884 
885  Color spot_color = skia_conversions::ToColor(color);
886  spot_color.alpha *= 0.25;
887 
888  // Compute the spot color -- ported from SkShadowUtils::ComputeTonalColors.
889  {
890  Scalar max =
891  std::max(std::max(spot_color.red, spot_color.green), spot_color.blue);
892  Scalar min =
893  std::min(std::min(spot_color.red, spot_color.green), spot_color.blue);
894  Scalar luminance = (min + max) * 0.5;
895 
896  Scalar alpha_adjust =
897  (2.6f + (-2.66667f + 1.06667f * spot_color.alpha) * spot_color.alpha) *
898  spot_color.alpha;
899  Scalar color_alpha =
900  (3.544762f + (-4.891428f + 2.3466f * luminance) * luminance) *
901  luminance;
902  color_alpha = std::clamp(alpha_adjust * color_alpha, 0.0f, 1.0f);
903 
904  Scalar greyscale_alpha =
905  std::clamp(spot_color.alpha * (1 - 0.4f * luminance), 0.0f, 1.0f);
906 
907  Scalar color_scale = color_alpha * (1 - greyscale_alpha);
908  Scalar tonal_alpha = color_scale + greyscale_alpha;
909  Scalar unpremul_scale = tonal_alpha != 0 ? color_scale / tonal_alpha : 0;
910  spot_color = Color(unpremul_scale * spot_color.red,
911  unpremul_scale * spot_color.green,
912  unpremul_scale * spot_color.blue, tonal_alpha);
913  }
914 
915  Vector3 light_position(0, -1, 1);
916  Scalar occluder_z = dpr * elevation;
917 
918  constexpr Scalar kLightRadius = 800 / 600; // Light radius / light height
919 
920  Paint paint;
921  paint.style = Paint::Style::kFill;
922  paint.color = spot_color;
923  paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
925  .sigma = Radius{kLightRadius * occluder_z /
927  };
928 
929  GetCanvas().Save(1u);
931  Matrix::MakeTranslation(Vector2(0, -occluder_z * light_position.y)));
932 
933  SimplifyOrDrawPath(GetCanvas(), path, paint);
935 
936  GetCanvas().Restore();
937 }
bool Restore()
Definition: canvas.cc:1469
void PreConcat(const Matrix &transform)
Definition: canvas.cc:259
@ kNormal
Blurred inside and outside.
Point Vector2
Definition: point.h:331
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
Vector3 GetScale() const
Definition: matrix.h:341

References impeller::Color::alpha, AUTO_DEPTH_CHECK, AUTO_DEPTH_WATCHER, impeller::Color::blue, impeller::Paint::color, GetCanvas(), impeller::Canvas::GetCurrentTransform(), impeller::Matrix::GetScale(), impeller::Color::green, impeller::Paint::kFill, impeller::FilterContents::kNormal, impeller::Matrix::MakeTranslation(), impeller::Paint::mask_blur_descriptor, impeller::Canvas::PreConcat(), impeller::Color::red, impeller::Canvas::Restore(), impeller::Canvas::Save(), SimplifyOrDrawPath(), impeller::Paint::MaskBlurDescriptor::style, impeller::Paint::style, impeller::skia_conversions::ToColor(), and impeller::Vector3::y.

◆ drawTextBlob()

void impeller::DlDispatcherBase::drawTextBlob ( const sk_sp< SkTextBlob >  blob,
DlScalar  x,
DlScalar  y 
)
override

Definition at line 856 of file dl_dispatcher.cc.

858  {
859  // When running with Impeller enabled Skia text blobs are converted to
860  // Impeller text frames in paragraph_skia.cc
862 }
#define UNIMPLEMENTED

References UNIMPLEMENTED.

◆ drawTextFrame()

void impeller::DlDispatcherBase::drawTextFrame ( const std::shared_ptr< impeller::TextFrame > &  text_frame,
DlScalar  x,
DlScalar  y 
)
override

Definition at line 865 of file dl_dispatcher.cc.

868  {
869  AUTO_DEPTH_WATCHER(1u);
870 
871  GetCanvas().DrawTextFrame(text_frame, //
872  impeller::Point{x, y}, //
873  paint_ //
874  );
875 }
void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint)
Definition: canvas.cc:1660
int32_t x

References AUTO_DEPTH_WATCHER, impeller::Canvas::DrawTextFrame(), GetCanvas(), paint_, and x.

◆ drawVertices()

void impeller::DlDispatcherBase::drawVertices ( const std::shared_ptr< flutter::DlVertices > &  vertices,
flutter::DlBlendMode  dl_mode 
)
override

Definition at line 694 of file dl_dispatcher.cc.

696  {}

◆ GetCanvas()

◆ restore()

void impeller::DlDispatcherBase::restore ( )
override

Definition at line 336 of file dl_dispatcher.cc.

336  {
337  GetCanvas().Restore();
338 }

References GetCanvas(), and impeller::Canvas::Restore().

◆ rotate()

void impeller::DlDispatcherBase::rotate ( DlScalar  degrees)
override

Definition at line 355 of file dl_dispatcher.cc.

355  {
356  AUTO_DEPTH_WATCHER(0u);
357 
358  GetCanvas().Rotate(Degrees{degrees});
359 }
void Rotate(Radians radians)
Definition: canvas.cc:291

References AUTO_DEPTH_WATCHER, GetCanvas(), and impeller::Canvas::Rotate().

◆ save()

void impeller::DlDispatcherBase::save ( uint32_t  total_content_depth)
override

Definition at line 300 of file dl_dispatcher.cc.

300  {
301  AUTO_DEPTH_WATCHER(1u);
302 
303  GetCanvas().Save(total_content_depth);
304 }

References AUTO_DEPTH_WATCHER, GetCanvas(), and impeller::Canvas::Save().

◆ saveLayer()

void impeller::DlDispatcherBase::saveLayer ( const DlRect bounds,
const flutter::SaveLayerOptions &  options,
uint32_t  total_content_depth,
flutter::DlBlendMode  max_content_mode,
const flutter::DlImageFilter *  backdrop,
std::optional< int64_t >  backdrop_id 
)
override

Definition at line 307 of file dl_dispatcher.cc.

312  {
313  AUTO_DEPTH_WATCHER(1u);
314 
315  auto paint = options.renders_with_attributes() ? paint_ : Paint{};
316  auto promise = options.content_is_clipped()
319  std::optional<Rect> impeller_bounds;
320  // If the content is unbounded but has developer specified bounds, we take
321  // the original bounds so that we clip the content as expected.
322  if (!options.content_is_unbounded() || options.bounds_from_caller()) {
323  impeller_bounds = bounds;
324  }
325 
327  paint, impeller_bounds, backdrop, promise, total_content_depth,
328  // Unbounded content can still have user specified bounds that require a
329  // saveLayer to be created to perform the clip.
330  options.can_distribute_opacity() && !options.content_is_unbounded(),
331  backdrop_id //
332  );
333 }
@ kMayClipContents
The caller claims the bounds are a subset of an estimate of the reasonably tight bounds but likely cl...

References AUTO_DEPTH_WATCHER, GetCanvas(), impeller::kContainsContents, impeller::kMayClipContents, paint_, and impeller::Canvas::SaveLayer().

◆ scale()

void impeller::DlDispatcherBase::scale ( DlScalar  sx,
DlScalar  sy 
)
override

Definition at line 348 of file dl_dispatcher.cc.

348  {
349  AUTO_DEPTH_WATCHER(0u);
350 
351  GetCanvas().Scale({sx, sy, 1.0});
352 }
void Scale(const Vector2 &scale)
Definition: canvas.cc:279

References AUTO_DEPTH_WATCHER, GetCanvas(), and impeller::Canvas::Scale().

◆ setAntiAlias()

void impeller::DlDispatcherBase::setAntiAlias ( bool  aa)
override

Definition at line 147 of file dl_dispatcher.cc.

147  {
148  AUTO_DEPTH_WATCHER(0u);
149 
150  // Nothing to do because AA is implicit.
151 }

References AUTO_DEPTH_WATCHER.

◆ setBlendMode()

void impeller::DlDispatcherBase::setBlendMode ( flutter::DlBlendMode  mode)
override

Definition at line 250 of file dl_dispatcher.cc.

250  {
251  AUTO_DEPTH_WATCHER(0u);
252 
253  paint_.blend_mode = dl_mode;
254 }
BlendMode blend_mode
Definition: paint.h:82

References AUTO_DEPTH_WATCHER, impeller::Paint::blend_mode, and paint_.

◆ setColor()

void impeller::DlDispatcherBase::setColor ( flutter::DlColor  color)
override

Definition at line 174 of file dl_dispatcher.cc.

174  {
175  AUTO_DEPTH_WATCHER(0u);
176 
178 }
Color color
Definition: paint.h:75

References AUTO_DEPTH_WATCHER, impeller::Paint::color, paint_, and impeller::skia_conversions::ToColor().

◆ setColorFilter()

void impeller::DlDispatcherBase::setColorFilter ( const flutter::DlColorFilter *  filter)
override

Definition at line 236 of file dl_dispatcher.cc.

236  {
237  AUTO_DEPTH_WATCHER(0u);
238 
239  paint_.color_filter = filter;
240 }
const flutter::DlColorFilter * color_filter
Definition: paint.h:77

References AUTO_DEPTH_WATCHER, impeller::Paint::color_filter, and paint_.

◆ setColorSource()

void impeller::DlDispatcherBase::setColorSource ( const flutter::DlColorSource *  source)
override

Definition at line 229 of file dl_dispatcher.cc.

229  {
230  AUTO_DEPTH_WATCHER(0u);
231 
232  paint_.color_source = source;
233 }
const flutter::DlColorSource * color_source
Definition: paint.h:76

References AUTO_DEPTH_WATCHER, impeller::Paint::color_source, and paint_.

◆ setDrawStyle()

void impeller::DlDispatcherBase::setDrawStyle ( flutter::DlDrawStyle  style)
override

Definition at line 167 of file dl_dispatcher.cc.

167  {
168  AUTO_DEPTH_WATCHER(0u);
169 
170  paint_.style = ToStyle(style);
171 }
static Paint::Style ToStyle(flutter::DlDrawStyle style)

References AUTO_DEPTH_WATCHER, paint_, impeller::Paint::style, and impeller::ToStyle().

◆ setImageFilter()

void impeller::DlDispatcherBase::setImageFilter ( const flutter::DlImageFilter *  filter)
override

Definition at line 293 of file dl_dispatcher.cc.

293  {
294  AUTO_DEPTH_WATCHER(0u);
295 
296  paint_.image_filter = filter;
297 }
const flutter::DlImageFilter * image_filter
Definition: paint.h:78

References AUTO_DEPTH_WATCHER, impeller::Paint::image_filter, and paint_.

◆ setInvertColors()

void impeller::DlDispatcherBase::setInvertColors ( bool  invert)
override

Definition at line 243 of file dl_dispatcher.cc.

243  {
244  AUTO_DEPTH_WATCHER(0u);
245 
246  paint_.invert_colors = invert;
247 }
bool invert_colors
Definition: paint.h:83

References AUTO_DEPTH_WATCHER, impeller::Paint::invert_colors, and paint_.

◆ setMaskFilter()

void impeller::DlDispatcherBase::setMaskFilter ( const flutter::DlMaskFilter *  filter)
override

Definition at line 270 of file dl_dispatcher.cc.

270  {
271  AUTO_DEPTH_WATCHER(0u);
272 
273  // Needs https://github.com/flutter/flutter/issues/95434
274  if (filter == nullptr) {
275  paint_.mask_blur_descriptor = std::nullopt;
276  return;
277  }
278  switch (filter->type()) {
279  case flutter::DlMaskFilterType::kBlur: {
280  auto blur = filter->asBlur();
281 
283  .style = ToBlurStyle(blur->style()),
284  .sigma = Sigma(blur->sigma()),
285  .respect_ctm = blur->respectCTM(),
286  };
287  break;
288  }
289  }
290 }
static FilterContents::BlurStyle ToBlurStyle(flutter::DlBlurStyle blur_style)
std::optional< MaskBlurDescriptor > mask_blur_descriptor
Definition: paint.h:85

References AUTO_DEPTH_WATCHER, impeller::Paint::mask_blur_descriptor, paint_, and impeller::ToBlurStyle().

◆ setStrokeCap()

void impeller::DlDispatcherBase::setStrokeCap ( flutter::DlStrokeCap  cap)
override

Definition at line 195 of file dl_dispatcher.cc.

195  {
196  AUTO_DEPTH_WATCHER(0u);
197 
198  switch (cap) {
199  case flutter::DlStrokeCap::kButt:
201  break;
202  case flutter::DlStrokeCap::kRound:
204  break;
205  case flutter::DlStrokeCap::kSquare:
207  break;
208  }
209 }
StrokeParameters stroke
Definition: paint.h:80

References AUTO_DEPTH_WATCHER, impeller::StrokeParameters::cap, impeller::kButt, impeller::kRound, impeller::kSquare, paint_, and impeller::Paint::stroke.

◆ setStrokeJoin()

void impeller::DlDispatcherBase::setStrokeJoin ( flutter::DlStrokeJoin  join)
override

Definition at line 212 of file dl_dispatcher.cc.

212  {
213  AUTO_DEPTH_WATCHER(0u);
214 
215  switch (join) {
216  case flutter::DlStrokeJoin::kMiter:
218  break;
219  case flutter::DlStrokeJoin::kRound:
221  break;
222  case flutter::DlStrokeJoin::kBevel:
224  break;
225  }
226 }

References AUTO_DEPTH_WATCHER, impeller::StrokeParameters::join, impeller::kBevel, impeller::kMiter, impeller::kRound, paint_, and impeller::Paint::stroke.

◆ setStrokeMiter()

void impeller::DlDispatcherBase::setStrokeMiter ( DlScalar  limit)
override

◆ setStrokeWidth()

void impeller::DlDispatcherBase::setStrokeWidth ( DlScalar  width)
override

Definition at line 181 of file dl_dispatcher.cc.

181  {
182  AUTO_DEPTH_WATCHER(0u);
183 
184  paint_.stroke.width = width;
185 }

References AUTO_DEPTH_WATCHER, paint_, impeller::Paint::stroke, and impeller::StrokeParameters::width.

◆ SimplifyOrDrawPath()

void impeller::DlDispatcherBase::SimplifyOrDrawPath ( Canvas canvas,
const DlPath cache,
const Paint paint 
)
staticprotected

Definition at line 609 of file dl_dispatcher.cc.

611  {
612  DlRect rect;
613 
614  // We can't "optimize" a path into a rectangle if it's open.
615  bool closed;
616  if (path.IsRect(&rect, &closed) && closed) {
617  canvas.DrawRect(rect, paint);
618  return;
619  }
620 
621  DlRoundRect rrect;
622  if (path.IsRoundRect(&rrect) && rrect.GetRadii().AreAllCornersSame()) {
623  canvas.DrawRoundRect(rrect, paint);
624  return;
625  }
626 
627  if (path.IsOval(&rect)) {
628  canvas.DrawOval(rect, paint);
629  return;
630  }
631 
632  DlPoint start;
633  DlPoint end;
634  if (path.IsLine(&start, &end)) {
635  canvas.DrawLine(start, end, paint);
636  return;
637  }
638 
639  canvas.DrawPath(path, paint);
640 }
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:24
const size_t start
const size_t end

References impeller::Canvas::DrawLine(), impeller::Canvas::DrawOval(), impeller::Canvas::DrawPath(), impeller::Canvas::DrawRect(), impeller::Canvas::DrawRoundRect(), end, and start.

Referenced by drawPath(), and drawShadow().

◆ skew()

void impeller::DlDispatcherBase::skew ( DlScalar  sx,
DlScalar  sy 
)
override

Definition at line 362 of file dl_dispatcher.cc.

362  {
363  AUTO_DEPTH_WATCHER(0u);
364 
365  GetCanvas().Skew(sx, sy);
366 }
void Skew(Scalar sx, Scalar sy)
Definition: canvas.cc:287

References AUTO_DEPTH_WATCHER, GetCanvas(), and impeller::Canvas::Skew().

◆ transform2DAffine()

void impeller::DlDispatcherBase::transform2DAffine ( DlScalar  mxx,
DlScalar  mxy,
DlScalar  mxt,
DlScalar  myx,
DlScalar  myy,
DlScalar  myt 
)
override

Definition at line 369 of file dl_dispatcher.cc.

374  {
375  AUTO_DEPTH_WATCHER(0u);
376 
377  // clang-format off
379  mxx, mxy, 0, mxt,
380  myx, myy, 0, myt,
381  0 , 0, 1, 0,
382  0 , 0, 0, 1
383  );
384  // clang-format on
385 }
void transformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override

References AUTO_DEPTH_WATCHER, and transformFullPerspective().

◆ transformFullPerspective()

void impeller::DlDispatcherBase::transformFullPerspective ( DlScalar  mxx,
DlScalar  mxy,
DlScalar  mxz,
DlScalar  mxt,
DlScalar  myx,
DlScalar  myy,
DlScalar  myz,
DlScalar  myt,
DlScalar  mzx,
DlScalar  mzy,
DlScalar  mzz,
DlScalar  mzt,
DlScalar  mwx,
DlScalar  mwy,
DlScalar  mwz,
DlScalar  mwt 
)
override

Definition at line 388 of file dl_dispatcher.cc.

403  {
404  AUTO_DEPTH_WATCHER(0u);
405 
406  // The order of arguments is row-major but Impeller matrices are
407  // column-major.
408  // clang-format off
409  auto transform = Matrix{
410  mxx, myx, mzx, mwx,
411  mxy, myy, mzy, mwy,
412  mxz, myz, mzz, mwz,
413  mxt, myt, mzt, mwt
414  };
415  // clang-format on
417 }
void Transform(const Matrix &transform)
Definition: canvas.cc:267

References AUTO_DEPTH_WATCHER, GetCanvas(), impeller::Canvas::Transform(), and transform.

Referenced by transform2DAffine().

◆ transformReset()

void impeller::DlDispatcherBase::transformReset ( )
override

◆ translate()

void impeller::DlDispatcherBase::translate ( DlScalar  tx,
DlScalar  ty 
)
override

Definition at line 341 of file dl_dispatcher.cc.

341  {
342  AUTO_DEPTH_WATCHER(0u);
343 
344  GetCanvas().Translate({tx, ty, 0.0});
345 }
void Translate(const Vector3 &offset)
Definition: canvas.cc:275

References AUTO_DEPTH_WATCHER, GetCanvas(), and impeller::Canvas::Translate().

Member Data Documentation

◆ initial_matrix_

Matrix impeller::DlDispatcherBase::initial_matrix_
protected

Definition at line 261 of file dl_dispatcher.h.

Referenced by drawDisplayList(), and transformReset().

◆ paint_


The documentation for this class was generated from the following files: