Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
imageresizetiled.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
gm/gm.h
"
9
#include "
include/core/SkCanvas.h
"
10
#include "
include/core/SkFont.h
"
11
#include "
include/core/SkImageFilter.h
"
12
#include "
include/core/SkMatrix.h
"
13
#include "
include/core/SkPaint.h
"
14
#include "
include/core/SkRect.h
"
15
#include "
include/core/SkScalar.h
"
16
#include "
include/core/SkTypeface.h
"
17
#include "
include/core/SkTypes.h
"
18
#include "
include/effects/SkImageFilters.h
"
19
#include "
tools/ToolUtils.h
"
20
#include "
tools/fonts/FontToolUtils.h
"
21
22
#define WIDTH 640
23
#define HEIGHT 480
24
25
#define RESIZE_FACTOR SkIntToScalar(2)
26
27
DEF_SIMPLE_GM
(imageresizetiled, canvas,
WIDTH
,
HEIGHT
) {
28
SkPaint
paint
;
29
SkMatrix
matrix;
30
matrix.setScale(
RESIZE_FACTOR
,
RESIZE_FACTOR
);
31
paint
.setImageFilter(
SkImageFilters::MatrixTransform
(matrix,
32
SkSamplingOptions
(),
33
nullptr
));
34
35
SkFont
font(
ToolUtils::DefaultPortableTypeface
(), 100);
36
const
SkScalar
tile_size =
SkIntToScalar
(100);
37
for
(
SkScalar
y
= 0;
y
<
HEIGHT
;
y
+= tile_size) {
38
for
(
SkScalar
x
= 0;
x
<
WIDTH
;
x
+= tile_size) {
39
canvas->save();
40
canvas->clipRect(
SkRect::MakeXYWH
(
x
,
y
, tile_size, tile_size));
41
canvas->scale(
SkScalarInvert
(
RESIZE_FACTOR
),
42
SkScalarInvert
(
RESIZE_FACTOR
));
43
canvas->saveLayer(
nullptr
, &
paint
);
44
const
char
* str[] = {
45
"The quick"
,
46
"brown fox"
,
47
"jumped over"
,
48
"the lazy dog."
,
49
};
50
float
posY = 0;
51
for
(
unsigned
i = 0; i < std::size(str); i++) {
52
posY += 100.0f;
53
canvas->drawString(str[i], 0.0f, posY, font,
SkPaint
());
54
}
55
canvas->restore();
56
canvas->restore();
57
}
58
}
59
}
FontToolUtils.h
SkCanvas.h
SkFont.h
SkImageFilter.h
SkImageFilters.h
SkMatrix.h
SkPaint.h
SkRect.h
SkScalar.h
SkScalarInvert
#define SkScalarInvert(x)
Definition
SkScalar.h:73
SkIntToScalar
#define SkIntToScalar(x)
Definition
SkScalar.h:57
SkTypeface.h
SkTypes.h
ToolUtils.h
SkFont
Definition
SkFont.h:35
SkImageFilters::MatrixTransform
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
Definition
SkMatrixTransformImageFilter.cpp:77
SkMatrix
Definition
SkMatrix.h:54
SkPaint
Definition
SkPaint.h:44
paint
const Paint & paint
Definition
color_source.cc:38
SkScalar
float SkScalar
Definition
extension.cpp:12
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
WIDTH
#define WIDTH
Definition
imageresizetiled.cpp:22
RESIZE_FACTOR
#define RESIZE_FACTOR
Definition
imageresizetiled.cpp:25
HEIGHT
#define HEIGHT
Definition
imageresizetiled.cpp:23
y
double y
Definition
mouse-input-test.cc:83
x
double x
Definition
mouse-input-test.cc:82
ToolUtils::DefaultPortableTypeface
sk_sp< SkTypeface > DefaultPortableTypeface()
Definition
FontToolUtils.cpp:195
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:06 for Flutter Engine by
1.9.8