| Flutter Impeller |

Public Member Functions | List of all members
impeller::NinePatchConverter Class Reference

`#include <nine_patch_converter.h>`

## Public Member Functions
| NinePatchConverter ()
| ~NinePatchConverter ()
void | DrawNinePatch (const std::shared_ptr< Image > &image, Rect center, Rect dst, const SamplerDescriptor &sampler, Canvas *canvas, Paint *paint)

## Detailed Description

Definition at line 18 of file nine_patch_converter.h.

## Constructor & Destructor Documentation

## ◆ NinePatchConverter()

impeller::NinePatchConverter::NinePatchConverter | ( |  | ) |
| default

## ◆ ~NinePatchConverter()

impeller::NinePatchConverter::~NinePatchConverter | ( |  | ) |
| default

## Member Function Documentation

## ◆ DrawNinePatch()

void impeller::NinePatchConverter::DrawNinePatch | ( | const std::shared_ptr< Image > & | image,
|  | Rect | center,
|  | Rect | dst,
|  | const SamplerDescriptor & | sampler,
|  | Canvas * | canvas,
|  | Paint * | paint
| ) |  |

Definition at line 60 of file nine_patch_converter.cc.

65 {
66 if (dst.IsEmpty()) {
67 return;
68 }
69 auto image_size = image->GetSize();
70 auto hSlices = InitSlices(0, center.GetLeft(), center.GetRight(),
71 image_size.width, dst.GetLeft(), dst.GetRight());
72 auto vSlices = InitSlices(0, center.GetTop(), center.GetBottom(),
73 image_size.height, dst.GetTop(), dst.GetBottom());
74
75 for (size_t yi = 0; yi < vSlices.size(); yi += 4) {
76 auto srcY0 = vSlices[yi];
77 auto dstY0 = vSlices[yi + 1];
78 auto srcY1 = vSlices[yi + 2];
79 auto dstY1 = vSlices[yi + 3];
80 for (size_t xi = 0; xi < hSlices.size(); xi += 4) {
81 auto srcX0 = hSlices[xi];
82 auto dstX0 = hSlices[xi + 1];
83 auto srcX1 = hSlices[xi + 2];
84 auto dstX1 = hSlices[xi + 3];
85 // TODO(jonahwilliams): consider converting this into a single call to
86 // DrawImageAtlas.
87 canvas->DrawImageRect(image, Rect::MakeLTRB(srcX0, srcY0, srcX1, srcY1),
88 Rect::MakeLTRB(dstX0, dstY0, dstX1, dstY1), *paint,
89 sampler, SourceRectConstraint::kStrict);
90 }
91 }
92 }

References impeller::Canvas::DrawImageRect(), impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::TRect< T >::IsEmpty(), impeller::kStrict, impeller::TRect< Scalar >::MakeLTRB(), and paint.

Referenced by impeller::DlDispatcherBase::drawImageNine().

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

- impeller/display_list/nine_patch_converter.h
- impeller/display_list/nine_patch_converter.cc

impeller::SourceRectConstraint::kStrict
@ kStrict
Sample only within the source rectangle. May be slower.
paint
const Paint & paint
Definition: color_source.cc:38
impeller::TRect< Scalar >::MakeLTRB
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129