@@ -564,28 +564,71 @@ void DisplayListDispatcher::drawVertices(const sk_sp<SkVertices> vertices,
564
564
}
565
565
566
566
// |flutter::Dispatcher|
567
- void DisplayListDispatcher::drawImage (const sk_sp<SkImage > image,
567
+ void DisplayListDispatcher::drawImage (const sk_sp<flutter::DlImage > image,
568
568
const SkPoint point,
569
569
const SkSamplingOptions& sampling,
570
570
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;
573
611
}
574
612
575
613
// |flutter::Dispatcher|
576
614
void DisplayListDispatcher::drawImageRect (
577
- const sk_sp<SkImage > image,
615
+ const sk_sp<flutter::DlImage > image,
578
616
const SkRect& src,
579
617
const SkRect& dst,
580
618
const SkSamplingOptions& sampling,
581
619
bool render_with_attributes,
582
620
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
+ );
585
628
}
586
629
587
630
// |flutter::Dispatcher|
588
- void DisplayListDispatcher::drawImageNine (const sk_sp<SkImage > image,
631
+ void DisplayListDispatcher::drawImageNine (const sk_sp<flutter::DlImage > image,
589
632
const SkIRect& center,
590
633
const SkRect& dst,
591
634
SkFilterMode filter,
@@ -595,17 +638,18 @@ void DisplayListDispatcher::drawImageNine(const sk_sp<SkImage> image,
595
638
}
596
639
597
640
// |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) {
603
647
// Needs https://github.com/flutter/flutter/issues/95434
604
648
UNIMPLEMENTED;
605
649
}
606
650
607
651
// |flutter::Dispatcher|
608
- void DisplayListDispatcher::drawAtlas (const sk_sp<SkImage > atlas,
652
+ void DisplayListDispatcher::drawAtlas (const sk_sp<flutter::DlImage > atlas,
609
653
const SkRSXform xform[],
610
654
const SkRect tex[],
611
655
const SkColor colors[],
0 commit comments