Flutter Engine
The Flutter Engine
RepeatTileSlide.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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 */
11#include "tools/viewer/Slide.h"
12
13static void make_bitmap(SkBitmap* bm) {
14 const int W = 100;
15 const int H = 100;
16 bm->allocN32Pixels(W, H);
17
19 SkCanvas canvas(*bm);
21
22 const SkColor colors[] = {
24 };
25
26 for (int ix = 0; ix < W; ix += 1) {
28 paint.setColor(colors[ix & 3]);
29 canvas.drawLine(x, 0, x, SkIntToScalar(H - 1), paint);
30 }
31 paint.setColor(SK_ColorGRAY);
32 canvas.drawLine(0, 0, SkIntToScalar(W), 0, paint);
33}
34
36 SkBitmap bm;
37 make_bitmap(&bm);
38
39 paint->setShader(bm.makeShader(tm, tm, SkSamplingOptions()));
40}
41
42class RepeatTileSlide : public Slide {
43public:
44 RepeatTileSlide() { fName = "RepeatTile"; }
45
46 void draw(SkCanvas* canvas) override {
47 canvas->clear(SK_ColorGRAY);
50
51// canvas->scale(SK_Scalar1*2, SK_Scalar1);
52 canvas->translate(SkIntToScalar(100), SkIntToScalar(100));
53 canvas->drawPaint(paint);
54 }
55
56};
57
58//////////////////////////////////////////////////////////////////////////////
59
60DEF_SLIDE( return new RepeatTileSlide(); )
static void make_paint(SkPaint *paint, SkTileMode tm)
static void make_bitmap(SkBitmap *bm)
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SK_ScalarHalf
Definition: SkScalar.h:19
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkTileMode
Definition: SkTileMode.h:13
#define DEF_SLIDE(code)
Definition: Slide.h:25
#define W
Definition: aaa.cpp:17
void draw(SkCanvas *canvas) override
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void clear(SkColor color)
Definition: SkCanvas.h:1199
Definition: Slide.h:29
SkString fName
Definition: Slide.h:54
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double x
PODArray< SkColor > colors
Definition: SkRecords.h:276
Definition: SkMD5.cpp:130