@@ -564,28 +564,71 @@ void DisplayListDispatcher::drawVertices(const sk_sp<SkVertices> vertices,
564564}
565565
566566// |flutter::Dispatcher|
567- void DisplayListDispatcher::drawImage (const sk_sp<SkImage > image,
567+ void DisplayListDispatcher::drawImage (const sk_sp<flutter::DlImage > image,
568568 const SkPoint point,
569569 const SkSamplingOptions& sampling,
570570 bool render_with_attributes) {
571- // Needs https://github.com/flutter/flutter/issues/95434
572- UNIMPLEMENTED;
571+ if (!image) {
572+ return ;
573+ }
574+
575+ auto texture = image->impeller_texture ();
576+ if (!texture) {
577+ return ;
578+ }
579+
580+ const auto size = texture->GetSize ();
581+ const auto src = SkRect::MakeWH (size.width , size.height );
582+ const auto dest =
583+ SkRect::MakeXYWH (point.fX , point.fY , size.width , size.height );
584+
585+ drawImageRect (
586+ image, // image
587+ src, // source rect
588+ dest, // destination rect
589+ sampling, // sampling options
590+ render_with_attributes, // render with attributes
591+ SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint // constraint
592+ );
593+ }
594+
595+ static impeller::SamplerDescriptor ToSamplerDescriptor (
596+ const SkSamplingOptions& options) {
597+ impeller::SamplerDescriptor desc;
598+ switch (options.filter ) {
599+ case SkFilterMode::kNearest :
600+ desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kNearest ;
601+ desc.label = " Nearest Sampler" ;
602+ break ;
603+ case SkFilterMode::kLinear :
604+ desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear ;
605+ desc.label = " Linear Sampler" ;
606+ break ;
607+ default :
608+ break ;
609+ }
610+ return desc;
573611}
574612
575613// |flutter::Dispatcher|
576614void DisplayListDispatcher::drawImageRect (
577- const sk_sp<SkImage > image,
615+ const sk_sp<flutter::DlImage > image,
578616 const SkRect& src,
579617 const SkRect& dst,
580618 const SkSamplingOptions& sampling,
581619 bool render_with_attributes,
582620 SkCanvas::SrcRectConstraint constraint) {
583- // Needs https://github.com/flutter/flutter/issues/95434
584- UNIMPLEMENTED;
621+ canvas_.DrawImageRect (
622+ std::make_shared<Image>(image->impeller_texture ()), // image
623+ ToRect (src), // source rect
624+ ToRect (dst), // destination rect
625+ paint_, // paint
626+ ToSamplerDescriptor (sampling) // sampling
627+ );
585628}
586629
587630// |flutter::Dispatcher|
588- void DisplayListDispatcher::drawImageNine (const sk_sp<SkImage > image,
631+ void DisplayListDispatcher::drawImageNine (const sk_sp<flutter::DlImage > image,
589632 const SkIRect& center,
590633 const SkRect& dst,
591634 SkFilterMode filter,
@@ -595,17 +638,18 @@ void DisplayListDispatcher::drawImageNine(const sk_sp<SkImage> image,
595638}
596639
597640// |flutter::Dispatcher|
598- void DisplayListDispatcher::drawImageLattice (const sk_sp<SkImage> image,
599- const SkCanvas::Lattice& lattice,
600- const SkRect& dst,
601- SkFilterMode filter,
602- bool render_with_attributes) {
641+ void DisplayListDispatcher::drawImageLattice (
642+ const sk_sp<flutter::DlImage> image,
643+ const SkCanvas::Lattice& lattice,
644+ const SkRect& dst,
645+ SkFilterMode filter,
646+ bool render_with_attributes) {
603647 // Needs https://github.com/flutter/flutter/issues/95434
604648 UNIMPLEMENTED;
605649}
606650
607651// |flutter::Dispatcher|
608- void DisplayListDispatcher::drawAtlas (const sk_sp<SkImage > atlas,
652+ void DisplayListDispatcher::drawAtlas (const sk_sp<flutter::DlImage > atlas,
609653 const SkRSXform xform[],
610654 const SkRect tex[],
611655 const SkColor colors[],
0 commit comments