2019-05-02 14:47:46 +00:00
|
|
|
// Copyright 2019 Google LLC.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
2019-05-01 21:28:53 +00:00
|
|
|
|
2019-05-02 14:47:46 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#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"
|
2019-05-02 14:47:46 +00:00
|
|
|
#include "tools/Resources.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
|
2019-05-02 14:47:46 +00:00
|
|
|
// http://crbug.com/957275
|
|
|
|
DEF_SIMPLE_GM(tilemodes_alpha, canvas, 512, 512) {
|
|
|
|
sk_sp<SkImage> image = GetResourceAsImage("images/mandrill_64.png");
|
|
|
|
if (!image) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
constexpr SkTileMode kModes[4] = {
|
|
|
|
SkTileMode::kClamp,
|
|
|
|
SkTileMode::kRepeat,
|
|
|
|
SkTileMode::kMirror,
|
|
|
|
SkTileMode::kDecal,
|
|
|
|
};
|
|
|
|
for (int y = 0; y < 4; ++y) {
|
|
|
|
for (int x = 0; x < 4; ++x) {
|
|
|
|
SkRect rect = SkRect::MakeXYWH(128 * x + 1, 128 * y + 1, 126, 126);
|
2020-05-21 16:11:27 +00:00
|
|
|
SkMatrix matrix = SkMatrix::Translate(rect.x(), rect.y());
|
2019-05-02 15:31:28 +00:00
|
|
|
SkPaint paint(SkColor4f{0, 0, 0, 0.5f});
|
2019-05-02 14:47:46 +00:00
|
|
|
paint.setShader(image->makeShader(kModes[x], kModes[y], &matrix));
|
|
|
|
canvas->drawRect(rect, paint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|