blob: 08a63d035c241c76486b188586e98728fcef5148 [file] [log] [blame]
Hal Canaryb82ac3662019-05-02 10:47:46 -04001// 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.
Ben Wagner7fde8e12019-05-01 17:28:53 -04003
Hal Canaryb82ac3662019-05-02 10:47:46 -04004#include "gm/gm.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -04005#include "include/core/SkCanvas.h"
6#include "include/core/SkImage.h"
7#include "include/core/SkMatrix.h"
8#include "include/core/SkPaint.h"
9#include "include/core/SkRect.h"
10#include "include/core/SkRefCnt.h"
11#include "include/core/SkShader.h"
12#include "include/core/SkTileMode.h"
Hal Canaryb82ac3662019-05-02 10:47:46 -040013#include "tools/Resources.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040014
Hal Canaryb82ac3662019-05-02 10:47:46 -040015// http://crbug.com/957275
16DEF_SIMPLE_GM(tilemodes_alpha, canvas, 512, 512) {
17 sk_sp<SkImage> image = GetResourceAsImage("images/mandrill_64.png");
18 if (!image) {
19 return;
20 }
21 constexpr SkTileMode kModes[4] = {
22 SkTileMode::kClamp,
23 SkTileMode::kRepeat,
24 SkTileMode::kMirror,
25 SkTileMode::kDecal,
26 };
27 for (int y = 0; y < 4; ++y) {
28 for (int x = 0; x < 4; ++x) {
29 SkRect rect = SkRect::MakeXYWH(128 * x + 1, 128 * y + 1, 126, 126);
Mike Reed1f607332020-05-21 12:11:27 -040030 SkMatrix matrix = SkMatrix::Translate(rect.x(), rect.y());
Hal Canary0a7b3932019-05-02 11:31:28 -040031 SkPaint paint(SkColor4f{0, 0, 0, 0.5f});
Hal Canaryb82ac3662019-05-02 10:47:46 -040032 paint.setShader(image->makeShader(kModes[x], kModes[y], &matrix));
33 canvas->drawRect(rect, paint);
34 }
35 }
36}