Flutter Engine
The Flutter Engine
Functions
tilemodes_alpha.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkShader.h"
#include "include/core/SkTileMode.h"
#include "tools/DecodeUtils.h"
#include "tools/Resources.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (tilemodes_alpha, canvas, 512, 512)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( tilemodes_alpha  ,
canvas  ,
512  ,
512   
)

Definition at line 17 of file tilemodes_alpha.cpp.

17 {
18 sk_sp<SkImage> image = ToolUtils::GetResourceAsImage("images/mandrill_64.png");
19 if (!image) {
20 return;
21 }
22 constexpr SkTileMode kModes[4] = {
27 };
28 for (int y = 0; y < 4; ++y) {
29 for (int x = 0; x < 4; ++x) {
30 SkRect rect = SkRect::MakeXYWH(128 * x + 1, 128 * y + 1, 126, 126);
32 SkPaint paint(SkColor4f{0, 0, 0, 0.5f});
33 paint.setShader(image->makeShader(kModes[x], kModes[y], SkSamplingOptions(), &matrix));
34 canvas->drawRect(rect, paint);
35 }
36 }
37}
SkTileMode
Definition: SkTileMode.h:13
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
const Paint & paint
Definition: color_source.cc:38
double y
double x
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659