| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkShader.h" | 10 #include "SkShader.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 createShader(); | 91 createShader(); |
| 92 createMaskFilter(); | 92 createMaskFilter(); |
| 93 | 93 |
| 94 canvas->save(); | 94 canvas->save(); |
| 95 | 95 |
| 96 // draw a letter "M" with a green & red striped texture and a | 96 // draw a letter "M" with a green & red striped texture and a |
| 97 // stipple mask with a round rect soft clip | 97 // stipple mask with a round rect soft clip |
| 98 SkPaint paint; | 98 SkPaint paint; |
| 99 paint.setAntiAlias(true); | 99 paint.setAntiAlias(true); |
| 100 sk_tool_utils::set_portable_typeface(&paint); |
| 100 paint.setTextSize(72); | 101 paint.setTextSize(72); |
| 101 paint.setShader(fShader.get()); | 102 paint.setShader(fShader.get()); |
| 102 paint.setMaskFilter(fMaskFilter.get()); | 103 paint.setMaskFilter(fMaskFilter.get()); |
| 103 | 104 |
| 104 SkRect temp; | 105 SkRect temp; |
| 105 temp.set(SkIntToScalar(115), | 106 temp.set(SkIntToScalar(115), |
| 106 SkIntToScalar(75), | 107 SkIntToScalar(75), |
| 107 SkIntToScalar(144), | 108 SkIntToScalar(144), |
| 108 SkIntToScalar(110)); | 109 SkIntToScalar(110)); |
| 109 | 110 |
| 110 SkPath path; | 111 SkPath path; |
| 111 path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5)); | 112 path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5)); |
| 112 | 113 |
| 113 canvas->clipPath(path, SkRegion::kReplace_Op, true); // AA is on | 114 canvas->clipPath(path, SkRegion::kReplace_Op, true); // AA is on |
| 114 | 115 |
| 115 canvas->drawText("M", 1, | 116 canvas->drawText("M", 1, |
| 116 SkIntToScalar(100), SkIntToScalar(100), | 117 SkIntToScalar(100), SkIntToScalar(100), |
| 117 paint); | 118 paint); |
| 118 | 119 |
| 119 canvas->restore(); | 120 canvas->restore(); |
| 120 | 121 |
| 121 // Now draw stroked versions of the "M" and the round rect so we can | 122 // Now draw stroked versions of the "M" and the round rect so we can |
| 122 // see what is going on | 123 // see what is going on |
| 123 SkPaint paint2; | 124 SkPaint paint2; |
| 124 paint2.setColor(SK_ColorBLACK); | 125 paint2.setColor(SK_ColorBLACK); |
| 125 paint2.setAntiAlias(true); | 126 paint2.setAntiAlias(true); |
| 127 sk_tool_utils::set_portable_typeface(&paint2); |
| 126 paint2.setTextSize(72); | 128 paint2.setTextSize(72); |
| 127 paint2.setStyle(SkPaint::kStroke_Style); | 129 paint2.setStyle(SkPaint::kStroke_Style); |
| 128 paint2.setStrokeWidth(1); | 130 paint2.setStrokeWidth(1); |
| 129 canvas->drawText("M", 1, | 131 canvas->drawText("M", 1, |
| 130 SkIntToScalar(100), SkIntToScalar(100), | 132 SkIntToScalar(100), SkIntToScalar(100), |
| 131 paint2); | 133 paint2); |
| 132 | 134 |
| 133 paint2.setColor(SK_ColorGRAY); | 135 paint2.setColor(SK_ColorGRAY); |
| 134 | 136 |
| 135 canvas->drawPath(path, paint2); | 137 canvas->drawPath(path, paint2); |
| 136 } | 138 } |
| 137 | 139 |
| 138 private: | 140 private: |
| 139 SkBitmap fTexture; | 141 SkBitmap fTexture; |
| 140 bool fTextureCreated; | 142 bool fTextureCreated; |
| 141 SkAutoTUnref<SkShader> fShader; | 143 SkAutoTUnref<SkShader> fShader; |
| 142 SkAutoTUnref<SkMaskFilter> fMaskFilter; | 144 SkAutoTUnref<SkMaskFilter> fMaskFilter; |
| 143 | 145 |
| 144 typedef GM INHERITED; | 146 typedef GM INHERITED; |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 ////////////////////////////////////////////////////////////////////////////// | 149 ////////////////////////////////////////////////////////////////////////////// |
| 148 | 150 |
| 149 static GM* MyFactory(void*) { return new SamplerStressGM; } | 151 static GM* MyFactory(void*) { return new SamplerStressGM; } |
| 150 static GMRegistry reg(MyFactory); | 152 static GMRegistry reg(MyFactory); |
| 151 | 153 |
| 152 } | 154 } |
| OLD | NEW |