Flutter Engine
The Flutter Engine
Classes | Functions
ninepatchstretch.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Classes

class  NinePatchStretchGM
 

Functions

static sk_sp< SkSurfacemake_surface (SkCanvas *root, int N)
 
static sk_sp< SkImagemake_image (SkCanvas *root, SkIRect *center)
 

Function Documentation

◆ make_image()

static sk_sp< SkImage > make_image ( SkCanvas root,
SkIRect center 
)
static

Definition at line 27 of file ninepatchstretch.cpp.

27 {
28 const int kFixed = 28;
29 const int kStretchy = 8;
30 const int kSize = 2*kFixed + kStretchy;
31
33 SkCanvas* canvas = surface->getCanvas();
34
37 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2;
38
39 center->setXYWH(kFixed, kFixed, kStretchy, kStretchy);
40
42 paint.setAntiAlias(true);
43
44 paint.setColor(0xFFFF0000);
45 canvas->drawRoundRect(r, radius, radius, paint);
46 r.setXYWH(SkIntToScalar(kFixed), 0, SkIntToScalar(kStretchy), SkIntToScalar(kSize));
47 paint.setColor(0x8800FF00);
48 canvas->drawRect(r, paint);
49 r.setXYWH(0, SkIntToScalar(kFixed), SkIntToScalar(kSize), SkIntToScalar(kStretchy));
50 paint.setColor(0x880000FF);
51 canvas->drawRect(r, paint);
52
53 return surface->makeImageSnapshot();
54}
static const int strokeWidth
Definition: BlurTest.cpp:60
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static SkScalar center(float pos0, float pos1)
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint)
Definition: SkCanvas.cpp:2717
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
float SkScalar
Definition: extension.cpp:12
constexpr int kSize
string root
Definition: scale_cpu.py:20
static sk_sp< SkSurface > make_surface(SkCanvas *root, int N)
void setXYWH(float x, float y, float width, float height)
Definition: SkRect.h:931
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ make_surface()

static sk_sp< SkSurface > make_surface ( SkCanvas root,
int  N 
)
static

Definition at line 22 of file ninepatchstretch.cpp.

22 {
25}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define N
Definition: beziers.cpp:19
sk_sp< SkSurface > makeSurface(SkCanvas *canvas, const SkImageInfo &info, const SkSurfaceProps *props)
Definition: ToolUtils.cpp:512
static SkImageInfo MakeN32Premul(int width, int height)