• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/SkGradientShader.h"
19 
20 DEF_SIMPLE_GM(bug6643, canvas, 200, 200) {
21     SkColor colors[] = { SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorTRANSPARENT };
22 
23     SkPaint p;
24     p.setAntiAlias(true);
25     p.setShader(SkGradientShader::MakeSweep(100, 100, colors, nullptr, SK_ARRAY_COUNT(colors),
26                                             SkGradientShader::kInterpolateColorsInPremul_Flag,
27                                             nullptr));
28 
29     SkPictureRecorder recorder;
30     recorder.beginRecording(200, 200)->drawPaint(p);
31 
32     p.setShader(recorder.finishRecordingAsPicture()->makeShader(
33                                             SkTileMode::kRepeat, SkTileMode::kRepeat));
34     canvas->drawColor(SK_ColorWHITE);
35     canvas->drawPaint(p);
36 }
37