Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
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
"
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
}
DecodeUtils.h
Resources.h
SkCanvas.h
SkImage.h
SkMatrix.h
SkPaint.h
SkRect.h
SkRefCnt.h
SkShader.h
SkTileMode.h
SkTileMode
SkTileMode
Definition
SkTileMode.h:13
SkTileMode::kDecal
@ kDecal
SkTileMode::kRepeat
@ kRepeat
SkTileMode::kClamp
@ kClamp
SkTileMode::kMirror
@ kMirror
SkImage::makeShader
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition
SkImage.cpp:179
SkMatrix
Definition
SkMatrix.h:54
SkMatrix::Translate
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition
SkMatrix.h:91
SkPaint
Definition
SkPaint.h:44
sk_sp
Definition
SkRefCnt.h:220
paint
const Paint & paint
Definition
color_source.cc:38
image
sk_sp< SkImage > image
Definition
examples.cpp:29
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
y
double y
Definition
mouse-input-test.cc:83
x
double x
Definition
mouse-input-test.cc:82
ToolUtils::GetResourceAsImage
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition
DecodeUtils.h:25
SkColor4f
SkRect
Definition
extension.cpp:13
SkRect::MakeXYWH
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition
SkRect.h:659
SkSamplingOptions
Definition
SkSamplingOptions.h:58
Generated on Fri Apr 26 2024 06:16:09 for Flutter Engine by
1.9.8