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 drawText (const std::shared_ptr< flutter::DlText > &text, 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 434 of file dl_dispatcher.cc.

436  {
437  AUTO_DEPTH_WATCHER(0u);
438 
439  EllipseGeometry geom(bounds);
440  GetCanvas().ClipGeometry(geom, ToClipOperation(clip_op));
441 }
void ClipGeometry(const Geometry &geometry, Entity::ClipOperation clip_op, bool is_aa=true)
Definition: canvas.cc:827
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 485 of file dl_dispatcher.cc.

487  {
488  AUTO_DEPTH_WATCHER(0u);
489 
490  auto clip_op = ToClipOperation(sk_op);
491 
492  DlRect rect;
493  if (path.IsRect(&rect)) {
494  FillRectGeometry geom(rect);
495  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
496  } else if (path.IsOval(&rect)) {
497  EllipseGeometry geom(rect);
498  GetCanvas().ClipGeometry(geom, clip_op);
499  } else {
500  DlRoundRect rrect;
501  if (path.IsRoundRect(&rrect) && rrect.GetRadii().AreAllCornersSame()) {
502  RoundRectGeometry geom(rrect.GetBounds(), rrect.GetRadii().top_left);
503  GetCanvas().ClipGeometry(geom, clip_op);
504  } else {
505  FillPathGeometry geom(path);
506  GetCanvas().ClipGeometry(geom, clip_op);
507  }
508  }
509 }
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 424 of file dl_dispatcher.cc.

426  {
427  AUTO_DEPTH_WATCHER(0u);
428 
429  FillRectGeometry geom(rect);
430  GetCanvas().ClipGeometry(geom, ToClipOperation(clip_op), /*is_aa=*/is_aa);
431 }

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 444 of file dl_dispatcher.cc.

446  {
447  AUTO_DEPTH_WATCHER(0u);
448 
449  auto clip_op = ToClipOperation(sk_op);
450  if (rrect.IsRect()) {
451  FillRectGeometry geom(rrect.GetBounds());
452  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
453  } else if (rrect.IsOval()) {
454  EllipseGeometry geom(rrect.GetBounds());
455  GetCanvas().ClipGeometry(geom, clip_op);
456  } else if (rrect.GetRadii().AreAllCornersSame()) {
457  RoundRectGeometry geom(rrect.GetBounds(), rrect.GetRadii().top_left);
458  GetCanvas().ClipGeometry(geom, clip_op);
459  } else {
460  FillRoundRectGeometry geom(rrect);
461  GetCanvas().ClipGeometry(geom, clip_op);
462  }
463 }

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 466 of file dl_dispatcher.cc.

468  {
469  AUTO_DEPTH_WATCHER(0u);
470 
471  auto clip_op = ToClipOperation(sk_op);
472  if (rse.IsRect()) {
473  FillRectGeometry geom(rse.GetBounds());
474  GetCanvas().ClipGeometry(geom, clip_op, /*is_aa=*/is_aa);
475  } else if (rse.IsOval()) {
476  EllipseGeometry geom(rse.GetBounds());
477  GetCanvas().ClipGeometry(geom, clip_op);
478  } else {
479  RoundSuperellipseGeometry geom(rse.GetBounds(), rse.GetRadii());
480  GetCanvas().ClipGeometry(geom, clip_op);
481  }
482 }

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 630 of file dl_dispatcher.cc.

633  {
634  AUTO_DEPTH_WATCHER(1u);
635 
636  GetCanvas().DrawArc(Arc(oval_bounds, Degrees(start_degrees),
637  Degrees(sweep_degrees), use_center),
638  paint_);
639 }
bool use_center
void DrawArc(const Arc &arc, const Paint &paint)
Definition: canvas.cc:679

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 750 of file dl_dispatcher.cc.

758  {
759  AUTO_DEPTH_WATCHER(1u);
760 
761  auto geometry =
762  DlAtlasGeometry(atlas->impeller_texture(), //
763  xform, //
764  tex, //
765  colors, //
766  static_cast<size_t>(count), //
767  mode, //
769  ToOptRect(cull_rect) //
770  );
771  auto atlas_contents = std::make_shared<AtlasContents>();
772  atlas_contents->SetGeometry(&geometry);
773 
774  GetCanvas().DrawAtlas(atlas_contents, paint_);
775 }
void DrawAtlas(const std::shared_ptr< AtlasContents > &atlas_contents, const Paint &paint)
Definition: canvas.cc:1120
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 561 of file dl_dispatcher.cc.

561  {
562  AUTO_DEPTH_WATCHER(1u);
563 
564  GetCanvas().DrawCircle(center, radius, paint_);
565 }
void DrawCircle(const Point &center, Scalar radius, const Paint &paint)
Definition: canvas.cc:804

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 512 of file dl_dispatcher.cc.

513  {
514  AUTO_DEPTH_WATCHER(1u);
515 
516  Paint paint;
517  paint.color = skia_conversions::ToColor(color);
518  paint.blend_mode = dl_mode;
519  GetCanvas().DrawPaint(paint);
520 }
void DrawPaint(const Paint &paint)
Definition: canvas.cc:341
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 537 of file dl_dispatcher.cc.

540  {
541  AUTO_DEPTH_WATCHER(1u);
542 
543  GetCanvas().DrawDashedLine(p0, p1, on_length, off_length, paint_);
544 }
void DrawDashedLine(const Point &p0, const Point &p1, Scalar on_length, Scalar off_length, const Paint &paint)
Definition: canvas.cc:606

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 575 of file dl_dispatcher.cc.

576  {
577  AUTO_DEPTH_WATCHER(1u);
578 
579  GetCanvas().DrawDiffRoundRect(outer, inner, paint_);
580 }
void DrawDiffRoundRect(const RoundRect &outer, const RoundRect &inner, const Paint &paint)
Definition: canvas.cc:766

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 778 of file dl_dispatcher.cc.

780  {
781  AUTO_DEPTH_WATCHER(display_list->total_depth());
782 
783  // Save all values that must remain untouched after the operation.
784  Paint saved_paint = paint_;
785  Matrix saved_initial_matrix = initial_matrix_;
786 
787  // Establish a new baseline for interpreting the new DL.
788  // Matrix and clip are left untouched, the current
789  // transform is saved as the new base matrix, and paint
790  // values are reset to defaults.
792  paint_ = Paint();
793 
794  // Handle passed opacity in the most brute-force way by using
795  // a SaveLayer. If the display_list is able to inherit the
796  // opacity, this could also be handled by modulating all of its
797  // attribute settings (for example, color), by the indicated
798  // opacity.
799  int restore_count = GetCanvas().GetSaveCount();
800  if (opacity < SK_Scalar1) {
801  Paint save_paint;
802  save_paint.color = Color(0, 0, 0, opacity);
803  GetCanvas().SaveLayer(save_paint, display_list->GetBounds(), nullptr,
805  display_list->total_depth(),
806  display_list->can_apply_group_opacity());
807  } else {
808  // The display list may alter the clip, which must be restored to the
809  // current clip at the end of playback.
810  GetCanvas().Save(display_list->total_depth());
811  }
812 
813  // TODO(131445): Remove this restriction if we can correctly cull with
814  // perspective transforms.
815  if (display_list->has_rtree() && !initial_matrix_.HasPerspective()) {
816  // The canvas remembers the screen-space culling bounds clipped by
817  // the surface and the history of clip calls. DisplayList can cull
818  // the ops based on a rectangle expressed in its "destination bounds"
819  // so we need the canvas to transform those into the current local
820  // coordinate space into which the DisplayList will be rendered.
821  auto global_culling_bounds = GetCanvas().GetLocalCoverageLimit();
822  if (global_culling_bounds.has_value()) {
823  Rect cull_rect = global_culling_bounds->TransformBounds(
824  GetCanvas().GetCurrentTransform().Invert());
825  display_list->Dispatch(*this, cull_rect);
826  } else {
827  // If the culling bounds are empty, this display list can be skipped
828  // entirely.
829  }
830  } else {
831  display_list->Dispatch(*this);
832  }
833 
834  // Restore all saved state back to what it was before we interpreted
835  // the display_list
837  GetCanvas().RestoreToCount(restore_count);
838  initial_matrix_ = saved_initial_matrix;
839  paint_ = saved_paint;
840 }
std::optional< Rect > GetLocalCoverageLimit() const
Return the culling bounds of the current render target, or nullopt if there is no coverage.
Definition: canvas.cc:1203
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:1240
const Matrix & GetCurrentTransform() const
Definition: canvas.cc:272
void RestoreToCount(size_t count)
Definition: canvas.cc:319
size_t GetSaveCount() const
Definition: canvas.cc:311
void Save(uint32_t total_content_depth=kMaxDepth)
Definition: canvas.cc:1186
#define AUTO_DEPTH_CHECK()
TRect< Scalar > Rect
Definition: rect.h:788
@ 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:418
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:472

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 686 of file dl_dispatcher.cc.

689  {
690  AUTO_DEPTH_WATCHER(1u);
691 
692  if (!image) {
693  return;
694  }
695 
696  auto texture = image->impeller_texture();
697  if (!texture) {
698  return;
699  }
700 
701  const auto size = texture->GetSize();
702  const auto src = DlRect::MakeWH(size.width, size.height);
703  const auto dest = DlRect::MakeXYWH(point.x, point.y, size.width, size.height);
704 
705  drawImageRect(image, // image
706  src, // source rect
707  dest, // destination rect
708  sampling, // sampling options
709  render_with_attributes, // render with attributes
710  flutter::DlSrcRectConstraint::kStrict // constraint
711  );
712 }
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 734 of file dl_dispatcher.cc.

738  {
739  AUTO_DEPTH_WATCHER(9u);
740 
741  NinePatchConverter converter = {};
742  converter.DrawNinePatch(image->impeller_texture(),
743  Rect::MakeLTRB(center.GetLeft(), center.GetTop(),
744  center.GetRight(), center.GetBottom()),
745  dst, ToSamplerDescriptor(filter), &GetCanvas(),
746  &paint_);
747 }
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 715 of file dl_dispatcher.cc.

721  {
722  AUTO_DEPTH_WATCHER(1u);
723 
725  image->impeller_texture(), // image
726  src, // source rect
727  dst, // destination rect
728  render_with_attributes ? paint_ : Paint(), // paint
729  skia_conversions::ToSamplerDescriptor(sampling) // sampling
730  );
731 }
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:941

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 530 of file dl_dispatcher.cc.

530  {
531  AUTO_DEPTH_WATCHER(1u);
532 
533  GetCanvas().DrawLine(p0, p1, paint_);
534 }
void DrawLine(const Point &p0, const Point &p1, const Paint &paint, bool reuse_depth=false)
Definition: canvas.cc:584

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

◆ drawOval()

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

Definition at line 554 of file dl_dispatcher.cc.

554  {
555  AUTO_DEPTH_WATCHER(1u);
556 
557  GetCanvas().DrawOval(bounds, paint_);
558 }
void DrawOval(const Rect &rect, const Paint &paint)
Definition: canvas.cc:650

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

◆ drawPaint()

void impeller::DlDispatcherBase::drawPaint ( )
override

Definition at line 523 of file dl_dispatcher.cc.

523  {
524  AUTO_DEPTH_WATCHER(1u);
525 
527 }

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

◆ drawPath()

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

Definition at line 590 of file dl_dispatcher.cc.

590  {
591  AUTO_DEPTH_WATCHER(1u);
592 
594 }
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 642 of file dl_dispatcher.cc.

644  {
645  AUTO_DEPTH_WATCHER(1u);
646 
647  Paint paint = paint_;
649  switch (mode) {
650  case flutter::DlPointMode::kPoints: {
651  // Cap::kButt is also treated as a square.
652  PointStyle point_style = paint.stroke.cap == Cap::kRound
655  Scalar radius = paint.stroke.width;
656  if (radius > 0) {
657  radius /= 2.0;
658  }
659  GetCanvas().DrawPoints(points, count, radius, paint, point_style);
660  } break;
661  case flutter::DlPointMode::kLines:
662  for (uint32_t i = 1; i < count; i += 2) {
663  Point p0 = points[i - 1];
664  Point p1 = points[i];
665  GetCanvas().DrawLine(p0, p1, paint, /*reuse_depth=*/i > 1);
666  }
667  break;
668  case flutter::DlPointMode::kPolygon:
669  if (count > 1) {
670  Point p0 = points[0];
671  for (uint32_t i = 1; i < count; i++) {
672  Point p1 = points[i];
673  GetCanvas().DrawLine(p0, p1, paint, /*reuse_depth=*/i > 1);
674  p0 = p1;
675  }
676  }
677  break;
678  }
679 }
void DrawPoints(const Point points[], uint32_t count, Scalar radius, const Paint &paint, PointStyle point_style)
Definition: canvas.cc:909
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 547 of file dl_dispatcher.cc.

547  {
548  AUTO_DEPTH_WATCHER(1u);
549 
550  GetCanvas().DrawRect(rect, paint_);
551 }
void DrawRect(const Rect &rect, const Paint &paint)
Definition: canvas.cc:632

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

◆ drawRoundRect()

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

Definition at line 568 of file dl_dispatcher.cc.

568  {
569  AUTO_DEPTH_WATCHER(1u);
570 
571  GetCanvas().DrawRoundRect(rrect, paint_);
572 }
void DrawRoundRect(const RoundRect &rect, const Paint &paint)
Definition: canvas.cc:734

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

◆ drawRoundSuperellipse()

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

Definition at line 583 of file dl_dispatcher.cc.

583  {
584  AUTO_DEPTH_WATCHER(1u);
585 
587 }
void DrawRoundSuperellipse(const RoundSuperellipse &rse, const Paint &paint)
Definition: canvas.cc:782

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 860 of file dl_dispatcher.cc.

864  {
865  AUTO_DEPTH_WATCHER(1u);
866 
867  Color spot_color = skia_conversions::ToColor(color);
868  spot_color.alpha *= 0.25;
869 
870  // Compute the spot color -- ported from SkShadowUtils::ComputeTonalColors.
871  {
872  Scalar max =
873  std::max(std::max(spot_color.red, spot_color.green), spot_color.blue);
874  Scalar min =
875  std::min(std::min(spot_color.red, spot_color.green), spot_color.blue);
876  Scalar luminance = (min + max) * 0.5;
877 
878  Scalar alpha_adjust =
879  (2.6f + (-2.66667f + 1.06667f * spot_color.alpha) * spot_color.alpha) *
880  spot_color.alpha;
881  Scalar color_alpha =
882  (3.544762f + (-4.891428f + 2.3466f * luminance) * luminance) *
883  luminance;
884  color_alpha = std::clamp(alpha_adjust * color_alpha, 0.0f, 1.0f);
885 
886  Scalar greyscale_alpha =
887  std::clamp(spot_color.alpha * (1 - 0.4f * luminance), 0.0f, 1.0f);
888 
889  Scalar color_scale = color_alpha * (1 - greyscale_alpha);
890  Scalar tonal_alpha = color_scale + greyscale_alpha;
891  Scalar unpremul_scale = tonal_alpha != 0 ? color_scale / tonal_alpha : 0;
892  spot_color = Color(unpremul_scale * spot_color.red,
893  unpremul_scale * spot_color.green,
894  unpremul_scale * spot_color.blue, tonal_alpha);
895  }
896 
897  Vector3 light_position(0, -1, 1);
898  Scalar occluder_z = dpr * elevation;
899 
900  constexpr Scalar kLightRadius = 800 / 600; // Light radius / light height
901 
902  Paint paint;
903  paint.style = Paint::Style::kFill;
904  paint.color = spot_color;
905  paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
907  .sigma = Radius{kLightRadius * occluder_z /
909  };
910 
911  GetCanvas().Save(1u);
913  Matrix::MakeTranslation(Vector2(0, -occluder_z * light_position.y)));
914 
915  SimplifyOrDrawPath(GetCanvas(), path, paint);
917 
918  GetCanvas().Restore();
919 }
bool Restore()
Definition: canvas.cc:1478
void PreConcat(const Matrix &transform)
Definition: canvas.cc:260
@ 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:394

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.

◆ drawText()

void impeller::DlDispatcherBase::drawText ( const std::shared_ptr< flutter::DlText > &  text,
DlScalar  x,
DlScalar  y 
)
override

Definition at line 843 of file dl_dispatcher.cc.

845  {
846  AUTO_DEPTH_WATCHER(1u);
847 
848  auto text_frame = text->GetTextFrame();
849 
850  // When running with Impeller enabled Skia text blobs are converted to
851  // Impeller text frames in paragraph_skia.cc
852  FML_CHECK(text_frame != nullptr);
853  GetCanvas().DrawTextFrame(text_frame, //
854  impeller::Point{x, y}, //
855  paint_ //
856  );
857 }
void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint)
Definition: canvas.cc:1669
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 681 of file dl_dispatcher.cc.

683  {}

◆ GetCanvas()

◆ restore()

void impeller::DlDispatcherBase::restore ( )
override

Definition at line 337 of file dl_dispatcher.cc.

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

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

◆ rotate()

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

Definition at line 356 of file dl_dispatcher.cc.

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

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

◆ save()

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

Definition at line 301 of file dl_dispatcher.cc.

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

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 308 of file dl_dispatcher.cc.

313  {
314  AUTO_DEPTH_WATCHER(1u);
315 
316  auto paint = options.renders_with_attributes() ? paint_ : Paint{};
317  auto promise = options.content_is_clipped()
320  std::optional<Rect> impeller_bounds;
321  // If the content is unbounded but has developer specified bounds, we take
322  // the original bounds so that we clip the content as expected.
323  if (!options.content_is_unbounded() || options.bounds_from_caller()) {
324  impeller_bounds = bounds;
325  }
326 
328  paint, impeller_bounds, backdrop, promise, total_content_depth,
329  // Unbounded content can still have user specified bounds that require a
330  // saveLayer to be created to perform the clip.
331  options.can_distribute_opacity() && !options.content_is_unbounded(),
332  backdrop_id //
333  );
334 }
@ 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 349 of file dl_dispatcher.cc.

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

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

◆ setAntiAlias()

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

Definition at line 148 of file dl_dispatcher.cc.

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

References AUTO_DEPTH_WATCHER.

◆ setBlendMode()

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

Definition at line 251 of file dl_dispatcher.cc.

251  {
252  AUTO_DEPTH_WATCHER(0u);
253 
254  paint_.blend_mode = dl_mode;
255 }
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 175 of file dl_dispatcher.cc.

175  {
176  AUTO_DEPTH_WATCHER(0u);
177 
179 }
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 237 of file dl_dispatcher.cc.

237  {
238  AUTO_DEPTH_WATCHER(0u);
239 
240  paint_.color_filter = filter;
241 }
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 230 of file dl_dispatcher.cc.

230  {
231  AUTO_DEPTH_WATCHER(0u);
232 
233  paint_.color_source = source;
234 }
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 168 of file dl_dispatcher.cc.

168  {
169  AUTO_DEPTH_WATCHER(0u);
170 
171  paint_.style = ToStyle(style);
172 }
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 294 of file dl_dispatcher.cc.

294  {
295  AUTO_DEPTH_WATCHER(0u);
296 
297  paint_.image_filter = filter;
298 }
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 244 of file dl_dispatcher.cc.

244  {
245  AUTO_DEPTH_WATCHER(0u);
246 
247  paint_.invert_colors = invert;
248 }
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 271 of file dl_dispatcher.cc.

271  {
272  AUTO_DEPTH_WATCHER(0u);
273 
274  // Needs https://github.com/flutter/flutter/issues/95434
275  if (filter == nullptr) {
276  paint_.mask_blur_descriptor = std::nullopt;
277  return;
278  }
279  switch (filter->type()) {
280  case flutter::DlMaskFilterType::kBlur: {
281  auto blur = filter->asBlur();
282 
284  .style = ToBlurStyle(blur->style()),
285  .sigma = Sigma(blur->sigma()),
286  .respect_ctm = blur->respectCTM(),
287  };
288  break;
289  }
290  }
291 }
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 196 of file dl_dispatcher.cc.

196  {
197  AUTO_DEPTH_WATCHER(0u);
198 
199  switch (cap) {
200  case flutter::DlStrokeCap::kButt:
202  break;
203  case flutter::DlStrokeCap::kRound:
205  break;
206  case flutter::DlStrokeCap::kSquare:
208  break;
209  }
210 }
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 213 of file dl_dispatcher.cc.

213  {
214  AUTO_DEPTH_WATCHER(0u);
215 
216  switch (join) {
217  case flutter::DlStrokeJoin::kMiter:
219  break;
220  case flutter::DlStrokeJoin::kRound:
222  break;
223  case flutter::DlStrokeJoin::kBevel:
225  break;
226  }
227 }

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 182 of file dl_dispatcher.cc.

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

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 596 of file dl_dispatcher.cc.

598  {
599  DlRect rect;
600 
601  // We can't "optimize" a path into a rectangle if it's open.
602  bool closed;
603  if (path.IsRect(&rect, &closed) && closed) {
604  canvas.DrawRect(rect, paint);
605  return;
606  }
607 
608  DlRoundRect rrect;
609  if (path.IsRoundRect(&rrect) && rrect.GetRadii().AreAllCornersSame()) {
610  canvas.DrawRoundRect(rrect, paint);
611  return;
612  }
613 
614  if (path.IsOval(&rect)) {
615  canvas.DrawOval(rect, paint);
616  return;
617  }
618 
619  DlPoint start;
620  DlPoint end;
621  if (path.IsLine(&start, &end)) {
622  canvas.DrawLine(start, end, paint);
623  return;
624  }
625 
626  canvas.DrawPath(path, paint);
627 }
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 363 of file dl_dispatcher.cc.

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

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 371 of file dl_dispatcher.cc.

373  {
374  AUTO_DEPTH_WATCHER(0u);
375 
377  mxx, mxy, 0, mxt,
378  myx, myy, 0, myt,
379  0 , 0, 1, 0,
380  0 , 0, 0, 1
381  );
382 }
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 387 of file dl_dispatcher.cc.

391  {
392  AUTO_DEPTH_WATCHER(0u);
393 
394  // The order of arguments is row-major but Impeller matrices are
395  // column-major.
396  auto transform = Matrix{
397  mxx, myx, mzx, mwx,
398  mxy, myy, mzy, mwy,
399  mxz, myz, mzz, mwz,
400  mxt, myt, mzt, mwt
401  };
403 }
void Transform(const Matrix &transform)
Definition: canvas.cc:268

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 342 of file dl_dispatcher.cc.

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

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

Member Data Documentation

◆ initial_matrix_

Matrix impeller::DlDispatcherBase::initial_matrix_
protected

Definition at line 256 of file dl_dispatcher.h.

Referenced by drawDisplayList(), and transformReset().

◆ paint_


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