| 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" |
| 5 |
#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" |
| 13 |
#include "tools/DecodeUtils.h" |
| 14 |
#include "tools/Resources.h" |
| 15 |
|
| 16 |
// http://crbug.com/957275 |
| 17 |
DEF_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] = { |
| 23 |
SkTileMode::kClamp, |
| 24 |
SkTileMode::kRepeat, |
| 25 |
SkTileMode::kMirror, |
| 26 |
SkTileMode::kDecal, |
| 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 |
} |