| 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 | 9 |
| 10 class SkJSCanvas { | 10 class SkJSCanvas { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 ctx.restore(); | 172 ctx.restore(); |
| 173 | 173 |
| 174 ctx.fillText("As Expected - line width 1", 10, 10); | 174 ctx.fillText("As Expected - line width 1", 10, 10); |
| 175 } | 175 } |
| 176 | 176 |
| 177 class Poly2PolyGM : public skiagm::GM { | 177 class Poly2PolyGM : public skiagm::GM { |
| 178 public: | 178 public: |
| 179 Poly2PolyGM() {} | 179 Poly2PolyGM() {} |
| 180 | 180 |
| 181 protected: | 181 protected: |
| 182 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 182 uint32_t onGetFlags() const SK_OVERRIDE { |
| 183 return kSkipTiled_Flag; | 183 return kSkipTiled_Flag; |
| 184 } | 184 } |
| 185 | 185 |
| 186 virtual SkString onShortName() SK_OVERRIDE { | 186 SkString onShortName() SK_OVERRIDE { |
| 187 return SkString("poly2poly"); | 187 return SkString("poly2poly"); |
| 188 } | 188 } |
| 189 | 189 |
| 190 virtual SkISize onISize() SK_OVERRIDE { | 190 SkISize onISize() SK_OVERRIDE { |
| 191 return SkISize::Make(835, 840); | 191 return SkISize::Make(835, 840); |
| 192 } | 192 } |
| 193 | 193 |
| 194 static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[], | 194 static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[], |
| 195 const int idst[], int count) { | 195 const int idst[], int count) { |
| 196 SkMatrix matrix; | 196 SkMatrix matrix; |
| 197 SkPoint src[4], dst[4]; | 197 SkPoint src[4], dst[4]; |
| 198 | 198 |
| 199 for (int i = 0; i < count; i++) { | 199 for (int i = 0; i < count; i++) { |
| 200 src[i].set(SkIntToScalar(isrc[2*i+0]), SkIntToScalar(isrc[2*i+1])); | 200 src[i].set(SkIntToScalar(isrc[2*i+0]), SkIntToScalar(isrc[2*i+1])); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 218 paint->setStyle(SkPaint::kFill_Style); | 218 paint->setStyle(SkPaint::kFill_Style); |
| 219 SkScalar x = D/2; | 219 SkScalar x = D/2; |
| 220 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2; | 220 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2; |
| 221 SkString str; | 221 SkString str; |
| 222 str.appendS32(count); | 222 str.appendS32(count); |
| 223 canvas->drawText(str.c_str(), str.size(), x, y, *paint); | 223 canvas->drawText(str.c_str(), str.size(), x, y, *paint); |
| 224 | 224 |
| 225 canvas->restore(); | 225 canvas->restore(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 228 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 229 if (false) { test_stroke(canvas); return; } | 229 if (false) { test_stroke(canvas); return; } |
| 230 | 230 |
| 231 SkPaint paint; | 231 SkPaint paint; |
| 232 paint.setAntiAlias(true); | 232 paint.setAntiAlias(true); |
| 233 sk_tool_utils::set_portable_typeface(&paint); | 233 sk_tool_utils::set_portable_typeface(&paint); |
| 234 paint.setStrokeWidth(SkIntToScalar(4)); | 234 paint.setStrokeWidth(SkIntToScalar(4)); |
| 235 paint.setTextSize(SkIntToScalar(40)); | 235 paint.setTextSize(SkIntToScalar(40)); |
| 236 paint.setTextAlign(SkPaint::kCenter_Align); | 236 paint.setTextAlign(SkPaint::kCenter_Align); |
| 237 | 237 |
| 238 canvas->save(); | 238 canvas->save(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 268 canvas->restore(); | 268 canvas->restore(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 private: | 271 private: |
| 272 typedef skiagm::GM INHERITED; | 272 typedef skiagm::GM INHERITED; |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 ////////////////////////////////////////////////////////////////////////////// | 275 ////////////////////////////////////////////////////////////////////////////// |
| 276 | 276 |
| 277 DEF_GM( return new Poly2PolyGM; ) | 277 DEF_GM( return new Poly2PolyGM; ) |
| OLD | NEW |