epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 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 | */ |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 7 | |
| 8 | #include "gm.h" |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 9 | #include "SkFlattenableBuffers.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #include "SkLayerRasterizer.h" |
| 11 | #include "SkBlurMaskFilter.h" |
| 12 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 13 | static void r0(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | p.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3), |
| 15 | SkBlurMaskFilter::kNormal_BlurStyle))->unref(); |
| 16 | rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 17 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 18 | p.setMaskFilter(NULL); |
| 19 | p.setStyle(SkPaint::kStroke_Style); |
| 20 | p.setStrokeWidth(SK_Scalar1); |
| 21 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 22 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | p.setAlpha(0x11); |
| 24 | p.setStyle(SkPaint::kFill_Style); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 25 | p.setXfermodeMode(SkXfermode::kSrc_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | rast->addLayer(p); |
| 27 | } |
| 28 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 29 | static void r1(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 31 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 32 | p.setAlpha(0x40); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 33 | p.setXfermodeMode(SkXfermode::kSrc_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | p.setStyle(SkPaint::kStroke_Style); |
| 35 | p.setStrokeWidth(SK_Scalar1*2); |
| 36 | rast->addLayer(p); |
| 37 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 38 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 39 | static void r2(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | p.setStyle(SkPaint::kStrokeAndFill_Style); |
| 41 | p.setStrokeWidth(SK_Scalar1*4); |
| 42 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 43 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | p.setStyle(SkPaint::kStroke_Style); |
| 45 | p.setStrokeWidth(SK_Scalar1*3/2); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 46 | p.setXfermodeMode(SkXfermode::kClear_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 47 | rast->addLayer(p); |
| 48 | } |
| 49 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 50 | static void r3(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | p.setStyle(SkPaint::kStroke_Style); |
| 52 | p.setStrokeWidth(SK_Scalar1*3); |
| 53 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 54 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | p.setAlpha(0x20); |
| 56 | p.setStyle(SkPaint::kFill_Style); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 57 | p.setXfermodeMode(SkXfermode::kSrc_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 58 | rast->addLayer(p); |
| 59 | } |
| 60 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 61 | static void r4(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 62 | p.setAlpha(0x60); |
| 63 | rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 64 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 65 | p.setAlpha(0xFF); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 66 | p.setXfermodeMode(SkXfermode::kClear_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | rast->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 68 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 69 | p.setXfermode(NULL); |
| 70 | rast->addLayer(p); |
| 71 | } |
| 72 | |
| 73 | #include "SkDiscretePathEffect.h" |
| 74 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 75 | static void r5(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 76 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 77 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 78 | p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref(); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 79 | p.setXfermodeMode(SkXfermode::kSrcOut_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 80 | rast->addLayer(p); |
| 81 | } |
| 82 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 83 | static void r6(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 84 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 85 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 86 | p.setAntiAlias(false); |
| 87 | SkLayerRasterizer* rast2 = new SkLayerRasterizer; |
| 88 | r5(rast2, p); |
| 89 | p.setRasterizer(rast2)->unref(); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 90 | p.setXfermodeMode(SkXfermode::kClear_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 91 | rast->addLayer(p); |
| 92 | } |
| 93 | |
| 94 | #include "Sk2DPathEffect.h" |
| 95 | |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 96 | static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { |
| 97 | SkPath path; |
| 98 | path.addCircle(0, 0, radius); |
| 99 | return new SkPath2DPathEffect(matrix, path); |
| 100 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 101 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 102 | static void r7(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 103 | SkMatrix lattice; |
| 104 | lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); |
| 105 | lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 106 | p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 107 | rast->addLayer(p); |
| 108 | } |
| 109 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 110 | static void r8(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 111 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 112 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 113 | SkMatrix lattice; |
| 114 | lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); |
| 115 | lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 116 | p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref(); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 117 | p.setXfermodeMode(SkXfermode::kClear_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 118 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 119 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 120 | p.setPathEffect(NULL); |
| 121 | p.setXfermode(NULL); |
| 122 | p.setStyle(SkPaint::kStroke_Style); |
| 123 | p.setStrokeWidth(SK_Scalar1); |
| 124 | rast->addLayer(p); |
| 125 | } |
| 126 | |
| 127 | class Line2DPathEffect : public Sk2DPathEffect { |
| 128 | public: |
| 129 | Line2DPathEffect(SkScalar width, const SkMatrix& matrix) |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 130 | : Sk2DPathEffect(matrix), fWidth(width) {} |
| 131 | |
reed@google.com | fd4be26 | 2012-05-25 01:04:12 +0000 | [diff] [blame] | 132 | virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec) SK_OVERRIDE { |
| 133 | if (this->INHERITED::filterPath(dst, src, rec)) { |
| 134 | rec->setStrokeStyle(fWidth); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 135 | return true; |
| 136 | } |
| 137 | return false; |
| 138 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 139 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 140 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Line2DPathEffect) |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 141 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 142 | protected: |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 143 | virtual void nextSpan(int u, int v, int ucount, SkPath* dst) { |
| 144 | if (ucount > 1) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 145 | SkPoint src[2], dstP[2]; |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 146 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 147 | src[0].set(SkIntToScalar(u) + SK_ScalarHalf, |
| 148 | SkIntToScalar(v) + SK_ScalarHalf); |
| 149 | src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, |
| 150 | SkIntToScalar(v) + SK_ScalarHalf); |
| 151 | this->getMatrix().mapPoints(dstP, src, 2); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 152 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 153 | dst->moveTo(dstP[0]); |
| 154 | dst->lineTo(dstP[1]); |
| 155 | } |
| 156 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 157 | |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 158 | Line2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 159 | fWidth = buffer.readScalar(); |
| 160 | } |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 161 | virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { |
| 162 | this->INHERITED::flatten(buffer); |
| 163 | buffer.writeScalar(fWidth); |
| 164 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 165 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 166 | private: |
| 167 | SkScalar fWidth; |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 168 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 169 | typedef Sk2DPathEffect INHERITED; |
| 170 | }; |
| 171 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 172 | static void r9(SkLayerRasterizer* rast, SkPaint& p) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 173 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 174 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 175 | SkMatrix lattice; |
| 176 | lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); |
| 177 | lattice.postRotate(SkIntToScalar(30), 0, 0); |
| 178 | p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref(); |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 179 | p.setXfermodeMode(SkXfermode::kClear_Mode); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 180 | rast->addLayer(p); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 181 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 182 | p.setPathEffect(NULL); |
| 183 | p.setXfermode(NULL); |
| 184 | p.setStyle(SkPaint::kStroke_Style); |
| 185 | p.setStrokeWidth(SK_Scalar1); |
| 186 | rast->addLayer(p); |
| 187 | } |
| 188 | |
| 189 | typedef void (*raster_proc)(SkLayerRasterizer*, SkPaint&); |
| 190 | |
| 191 | static const raster_proc gRastProcs[] = { |
| 192 | r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 |
| 193 | }; |
| 194 | |
| 195 | static const struct { |
| 196 | SkColor fMul, fAdd; |
| 197 | } gLightingColors[] = { |
| 198 | { 0x808080, 0x800000 }, // general case |
| 199 | { 0x707070, 0x707070 }, // no-pin case |
| 200 | { 0xFFFFFF, 0x800000 }, // just-add case |
| 201 | { 0x808080, 0x000000 }, // just-mul case |
| 202 | { 0xFFFFFF, 0x000000 } // identity case |
| 203 | }; |
| 204 | |
| 205 | #include "SkXfermode.h" |
| 206 | |
reed@google.com | f218339 | 2011-04-22 14:10:48 +0000 | [diff] [blame] | 207 | static void apply_shader(SkPaint* paint, int index) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 208 | raster_proc proc = gRastProcs[index]; |
| 209 | if (proc) |
| 210 | { |
| 211 | SkPaint p; |
| 212 | SkLayerRasterizer* rast = new SkLayerRasterizer; |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 213 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 214 | p.setAntiAlias(true); |
| 215 | proc(rast, p); |
| 216 | paint->setRasterizer(rast)->unref(); |
| 217 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 218 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 219 | #if 0 |
| 220 | SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 }; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 221 | paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, SK_Scalar1/4, SkIntToScalar(4), SkIntToScalar(3)))->unref(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 222 | #endif |
| 223 | paint->setColor(SK_ColorBLUE); |
| 224 | } |
| 225 | |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 226 | class TextEffectsGM : public skiagm::GM { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 227 | public: |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 228 | TextEffectsGM() {} |
| 229 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 230 | protected: |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 231 | virtual SkString onShortName() SK_OVERRIDE { |
| 232 | return SkString("texteffects"); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 233 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 234 | |
| 235 | virtual SkISize onISize() SK_OVERRIDE { |
| 236 | return SkISize::Make(640, 480); |
| 237 | } |
| 238 | |
| 239 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 240 | canvas->save(); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 241 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 242 | SkPaint paint; |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 243 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 244 | paint.setAntiAlias(true); |
reed@android.com | 0bb6d06 | 2010-05-17 14:50:04 +0000 | [diff] [blame] | 245 | paint.setTextSize(SkIntToScalar(56)); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 246 | |
reed@android.com | 0bb6d06 | 2010-05-17 14:50:04 +0000 | [diff] [blame] | 247 | SkScalar x = SkIntToScalar(20); |
| 248 | SkScalar y = paint.getTextSize(); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 249 | |
| 250 | SkString str("Hamburgefons"); |
| 251 | |
senorblanco@chromium.org | 64cc579 | 2011-05-19 19:58:58 +0000 | [diff] [blame] | 252 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 253 | apply_shader(&paint, i); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 254 | |
| 255 | // paint.setMaskFilter(NULL); |
| 256 | // paint.setColor(SK_ColorBLACK); |
| 257 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 258 | canvas->drawText(str.c_str(), str.size(), x, y, paint); |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 259 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 260 | y += paint.getFontSpacing(); |
| 261 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 262 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 263 | canvas->restore(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 264 | } |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 265 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 266 | private: |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 267 | typedef skiagm::GM INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 268 | }; |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 269 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 270 | ////////////////////////////////////////////////////////////////////////////// |
| 271 | |
mike@reedtribe.org | 3d1cb97 | 2012-08-13 00:52:07 +0000 | [diff] [blame^] | 272 | static skiagm::GM* MyFactory(void*) { return new TextEffectsGM; } |
| 273 | static skiagm::GMRegistry reg(MyFactory); |
| 274 | |