Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
convexpolyclip.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkClipOp.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  skiagm::ConvexPolyClip
 

Namespaces

namespace  skiagm
 

Functions

static sk_sp< SkImagemake_img (int w, int h)
 

Function Documentation

◆ make_img()

static sk_sp< SkImage > make_img ( int  w,
int  h 
)
static

Definition at line 31 of file convexpolyclip.cpp.

31 {
33 auto canvas = surf->getCanvas();
34
35 SkScalar wScalar = SkIntToScalar(w);
36 SkScalar hScalar = SkIntToScalar(h);
37
38 SkPoint pt = { wScalar / 2, hScalar / 2 };
39
40 SkScalar radius = 3 * std::max(wScalar, hScalar);
41
43 ToolUtils::color_to_565(0xFF222255),
44 ToolUtils::color_to_565(0xFF331133),
45 ToolUtils::color_to_565(0xFF884422),
46 ToolUtils::color_to_565(0xFF000022),
48 ToolUtils::color_to_565(0xFFAABBCC)};
49
50 SkScalar pos[] = {0,
51 SK_Scalar1 / 6,
52 2 * SK_Scalar1 / 6,
53 3 * SK_Scalar1 / 6,
54 4 * SK_Scalar1 / 6,
55 5 * SK_Scalar1 / 6,
57
59 SkRect rect = SkRect::MakeWH(wScalar, hScalar);
60 SkMatrix mat = SkMatrix::I();
61 for (int i = 0; i < 4; ++i) {
63 pt, radius,
64 colors, pos,
67 0, &mat));
68 canvas->drawRect(rect, paint);
69 rect.inset(wScalar / 8, hScalar / 8);
70 mat.preTranslate(6 * wScalar, 6 * hScalar);
71 mat.postScale(SK_Scalar1 / 3, SK_Scalar1 / 3);
72 }
73
75
76 paint.setShader(nullptr);
77 paint.setColor(SK_ColorLTGRAY);
78 constexpr char kTxt[] = "Skia";
79 SkPoint texPos = { wScalar / 17, hScalar / 2 + font.getSize() / 2.5f };
80 canvas->drawSimpleText(kTxt, std::size(kTxt)-1, SkTextEncoding::kUTF8,
81 texPos.fX, texPos.fY, font, paint);
82 paint.setColor(SK_ColorBLACK);
84 paint.setStrokeWidth(SK_Scalar1);
85 canvas->drawSimpleText(kTxt, std::size(kTxt)-1, SkTextEncoding::kUTF8,
86 texPos.fX, texPos.fY, font, paint);
87 return surf->makeImageSnapshot();
88}
SkPoint pos
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
constexpr SkColor SK_ColorLTGRAY
Definition: SkColor.h:118
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
constexpr SkColor SK_ColorDKGRAY
Definition: SkColor.h:108
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
Definition: SkFont.h:35
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:360
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:263
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkTypeface > DefaultPortableTypeface()
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
font
Font Metadata and Metrics.
SkScalar w
SkScalar h
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609