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 | |
| 8 | #include "SkGradientShader.h" |
| 9 | #include "SkPictureRecorder.h" |
| 10 | #include "gm.h" |
| 11 | |
| 12 | DEF_SIMPLE_GM(bug6643, canvas, 200, 200) { |
| 13 | SkColor colors[] = { SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorTRANSPARENT }; |
| 14 | |
| 15 | SkPaint p; |
| 16 | p.setAntiAlias(true); |
| 17 | p.setShader(SkGradientShader::MakeSweep(100, 100, colors, nullptr, SK_ARRAY_COUNT(colors), |
| 18 | SkGradientShader::kInterpolateColorsInPremul_Flag, |
| 19 | nullptr)); |
| 20 | |
| 21 | SkPictureRecorder recorder; |
| 22 | recorder.beginRecording(200, 200)->drawPaint(p); |
| 23 | |
| 24 | p.setShader(SkShader::MakePictureShader(recorder.finishRecordingAsPicture(), |
| 25 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, |
| 26 | nullptr, nullptr)); |
| 27 | canvas->drawColor(SK_ColorWHITE); |
| 28 | canvas->drawPaint(p); |
| 29 | } |