OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkRSXform.h" | 10 #include "SkRSXform.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint); | 94 canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint); |
95 canvas->translate(0, 100); | 95 canvas->translate(0, 100); |
96 canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcI
n_Mode, nullptr, &paint); | 96 canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcI
n_Mode, nullptr, &paint); |
97 } | 97 } |
98 | 98 |
99 private: | 99 private: |
100 typedef GM INHERITED; | 100 typedef GM INHERITED; |
101 }; | 101 }; |
102 DEF_GM( return new DrawAtlasGM; ) | 102 DEF_GM( return new DrawAtlasGM; ) |
| 103 |
| 104 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 105 |
| 106 DEF_SIMPLE_GM(drawTextRSXform, canvas, 1000, 1000) { |
| 107 const char text[] = "ABCDFGHJKLMNOPQRSTUVWXYZ"; |
| 108 const int N = sizeof(text) - 1; |
| 109 SkRSXform xform[N]; |
| 110 |
| 111 canvas->translate(0, 30); |
| 112 |
| 113 SkScalar x = 20; |
| 114 SkScalar dx = 20; |
| 115 SkScalar rad = 0; |
| 116 SkScalar drad = 2 * SK_ScalarPI / N; |
| 117 for (int i = 0; i < N; ++i) { |
| 118 xform[i].fSCos = SkScalarCos(rad); |
| 119 xform[i].fSSin = SkScalarSin(rad); |
| 120 xform[i].fTx = x; |
| 121 xform[i].fTy = 0; |
| 122 x += dx; |
| 123 rad += drad; |
| 124 } |
| 125 |
| 126 SkPaint paint; |
| 127 paint.setAntiAlias(true); |
| 128 paint.setTextSize(20); |
| 129 canvas->drawTextRSXform(text, N, xform, paint); |
| 130 } |
| 131 |
| 132 |
OLD | NEW |