Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
tilemodes_alpha.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4#include "gm/gm.h"
13#include "tools/DecodeUtils.h"
14#include "tools/Resources.h"
15
16// http://crbug.com/957275
17DEF_SIMPLE_GM(tilemodes_alpha, canvas, 512, 512) {
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);
31 SkMatrix matrix = SkMatrix::Translate(rect.x(), rect.y());
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
sk_sp< SkImage > image
Definition examples.cpp:29
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition gm.h:50
double y
double x
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