Mike Klein | 7e68bc9 | 2017-05-16 12:03:15 -0400 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkColor.h" |
| 11 | #include "include/core/SkPaint.h" |
| 12 | #include "include/core/SkPicture.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/core/SkPictureRecorder.h" |
Ben Wagner | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 14 | #include "include/core/SkRefCnt.h" |
| 15 | #include "include/core/SkShader.h" |
| 16 | #include "include/core/SkTileMode.h" |
| 17 | #include "include/core/SkTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "include/effects/SkGradientShader.h" |
Mike Klein | 7e68bc9 | 2017-05-16 12:03:15 -0400 | [diff] [blame] | 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 | |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 32 | p.setShader(recorder.finishRecordingAsPicture()->makeShader( |
| 33 | SkTileMode::kRepeat, SkTileMode::kRepeat)); |
Mike Klein | 7e68bc9 | 2017-05-16 12:03:15 -0400 | [diff] [blame] | 34 | canvas->drawColor(SK_ColorWHITE); |
| 35 | canvas->drawPaint(p); |
| 36 | } |