OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 #include "SkLinearGradient.h" | 10 #include "SkLinearGradient.h" |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); | 912 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); |
913 } | 913 } |
914 | 914 |
915 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { | 915 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { |
916 draw_many_stops(canvas, 0); | 916 draw_many_stops(canvas, 0); |
917 } | 917 } |
918 | 918 |
919 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { | 919 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { |
920 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); | 920 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); |
921 } | 921 } |
| 922 |
| 923 static void draw_subpixel_gradient(SkCanvas* canvas, uint32_t flags) { |
| 924 const SkPoint pts[] = { {50, 50}, {50.1f, 50.1f}}; |
| 925 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; |
| 926 SkPaint p; |
| 927 p.setShader(SkGradientShader::MakeLinear( |
| 928 pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kRepeat_TileMode
, flags, nullptr)); |
| 929 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); |
| 930 } |
| 931 |
| 932 DEF_SIMPLE_GM(gradient_subpixel, canvas, 500, 500) { |
| 933 draw_subpixel_gradient(canvas, 0); |
| 934 } |
| 935 |
| 936 DEF_SIMPLE_GM(gradient_subpixel_4f, canvas, 500, 500) { |
| 937 draw_subpixel_gradient(canvas, SkLinearGradient::kForce4fContext_PrivateFlag
); |
| 938 } |
OLD | NEW |