Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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, CanvasType *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,
CanvasType 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,
90 }
91 }
92}
static SkScalar center(float pos0, float pos1)
const Paint & paint
sk_sp< SkImage > image
Definition examples.cpp:29
dst
Definition cp.py:12
@ kStrict
Sample only within the source rectangle. May be slower.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129

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