Debian Codegraph @

gm/bug6643.cpp

raw
1 /*
2 * Copyright 2017 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/SkColor.h"
11 #include "include/core/SkPaint.h"
12 #include "include/core/SkPicture.h"
13 #include "include/core/SkPictureRecorder.h"
14 #include "include/core/SkRefCnt.h"
15 #include "include/core/SkShader.h"
16 #include "include/core/SkTileMode.h"
17 #include "include/core/SkTypes.h"
18 #include "include/effects/SkGradient.h"
19
20 DEF_SIMPLE_GM(bug6643, canvas, 200, 200) {
21 const SkColor4f colors[] = {
22 SkColors::kTransparent, SkColors::kGreen, SkColors::kTransparent
23 };
24
25 SkPaint p;
26 p.setAntiAlias(true);
27 p.setShader(SkShaders::SweepGradient({100, 100},
28 {{colors, {}, SkTileMode::kClamp},
29 {SkGradient::Interpolation::InPremul::kYes}}));
30
31 SkPictureRecorder recorder;
32 recorder.beginRecording(200, 200)->drawPaint(p);
33
34 p.setShader(recorder.finishRecordingAsPicture()->makeShader(
35 SkTileMode::kRepeat, SkTileMode::kRepeat,
36 SkFilterMode::kNearest, nullptr, nullptr));
37 canvas->drawColor(SK_ColorWHITE);
38 canvas->drawPaint(p);
39 }