| 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace skiagm { | 38 namespace skiagm { |
| 39 | 39 |
| 40 // Replicate chrome layout test - clipped pathed gradient-shaded text | 40 // Replicate chrome layout test - clipped pathed gradient-shaded text |
| 41 class ChromeGradTextGM1 : public GM { | 41 class ChromeGradTextGM1 : public GM { |
| 42 public: | 42 public: |
| 43 ChromeGradTextGM1() { } | 43 ChromeGradTextGM1() { } |
| 44 protected: | 44 protected: |
| 45 | 45 |
| 46 virtual SkString onShortName() { return SkString("chrome_gradtext1"); } | 46 virtual SkString onShortName() { return SkString("chrome_gradtext1"); } |
| 47 virtual SkISize onISize() { return make_isize(500, 480); } | 47 virtual SkISize onISize() { return SkISize::Make(500, 480); } |
| 48 virtual void onDraw(SkCanvas* canvas) { | 48 virtual void onDraw(SkCanvas* canvas) { |
| 49 SkPaint paint; | 49 SkPaint paint; |
| 50 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 50 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
| 51 | 51 |
| 52 canvas->clipRect(r); | 52 canvas->clipRect(r); |
| 53 | 53 |
| 54 paint.setColor(SK_ColorRED); | 54 paint.setColor(SK_ColorRED); |
| 55 canvas->drawRect(r, paint); | 55 canvas->drawRect(r, paint); |
| 56 | 56 |
| 57 // Minimal repro doesn't require AA, LCD, or a nondefault typeface | 57 // Minimal repro doesn't require AA, LCD, or a nondefault typeface |
| 58 paint.setShader(make_chrome_solid())->unref(); | 58 paint.setShader(make_chrome_solid())->unref(); |
| 59 paint.setTextSize(SkIntToScalar(500)); | 59 paint.setTextSize(SkIntToScalar(500)); |
| 60 | 60 |
| 61 canvas->drawText("I", 1, 0, 100, paint); | 61 canvas->drawText("I", 1, 0, 100, paint); |
| 62 } | 62 } |
| 63 private: | 63 private: |
| 64 typedef GM INHERITED; | 64 typedef GM INHERITED; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 | 67 |
| 68 // Replicate chrome layout test - switching between solid & gadient text | 68 // Replicate chrome layout test - switching between solid & gadient text |
| 69 class ChromeGradTextGM2 : public GM { | 69 class ChromeGradTextGM2 : public GM { |
| 70 public: | 70 public: |
| 71 ChromeGradTextGM2() { } | 71 ChromeGradTextGM2() { } |
| 72 protected: | 72 protected: |
| 73 | 73 |
| 74 virtual SkString onShortName() { return SkString("chrome_gradtext2"); } | 74 virtual SkString onShortName() { return SkString("chrome_gradtext2"); } |
| 75 virtual SkISize onISize() { return make_isize(500, 480); } | 75 virtual SkISize onISize() { return SkISize::Make(500, 480); } |
| 76 virtual void onDraw(SkCanvas* canvas) { | 76 virtual void onDraw(SkCanvas* canvas) { |
| 77 SkPaint paint; | 77 SkPaint paint; |
| 78 | 78 |
| 79 paint.setStyle(SkPaint::kFill_Style); | 79 paint.setStyle(SkPaint::kFill_Style); |
| 80 canvas->drawText("Normal Fill Text", 16, 0, 50, paint); | 80 canvas->drawText("Normal Fill Text", 16, 0, 50, paint); |
| 81 paint.setStyle(SkPaint::kStroke_Style); | 81 paint.setStyle(SkPaint::kStroke_Style); |
| 82 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); | 82 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); |
| 83 | 83 |
| 84 // Minimal repro doesn't require AA, LCD, or a nondefault typeface | 84 // Minimal repro doesn't require AA, LCD, or a nondefault typeface |
| 85 paint.setShader(make_chrome_solid())->unref(); | 85 paint.setShader(make_chrome_solid())->unref(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 102 protected: | 102 protected: |
| 103 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 103 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 104 return kSkipTiled_Flag; | 104 return kSkipTiled_Flag; |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 virtual SkString onShortName() { | 108 virtual SkString onShortName() { |
| 109 return SkString("gradtext"); | 109 return SkString("gradtext"); |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual SkISize onISize() { return make_isize(500, 480); } | 112 virtual SkISize onISize() { return SkISize::Make(500, 480); } |
| 113 | 113 |
| 114 static void draw_text(SkCanvas* canvas, const SkPaint& paint) { | 114 static void draw_text(SkCanvas* canvas, const SkPaint& paint) { |
| 115 const char* text = "When in the course of human events"; | 115 const char* text = "When in the course of human events"; |
| 116 size_t len = strlen(text); | 116 size_t len = strlen(text); |
| 117 canvas->drawText(text, len, 0, 0, paint); | 117 canvas->drawText(text, len, 0, 0, paint); |
| 118 } | 118 } |
| 119 | 119 |
| 120 static void draw_text3(SkCanvas* canvas, const SkPaint& paint) { | 120 static void draw_text3(SkCanvas* canvas, const SkPaint& paint) { |
| 121 SkPaint p(paint); | 121 SkPaint p(paint); |
| 122 | 122 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 ////////////////////////////////////////////////////////////////////////////// | 161 ////////////////////////////////////////////////////////////////////////////// |
| 162 | 162 |
| 163 static GM* MyFactory(void*) { return new GradTextGM; } | 163 static GM* MyFactory(void*) { return new GradTextGM; } |
| 164 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } | 164 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } |
| 165 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } | 165 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } |
| 166 | 166 |
| 167 static GMRegistry reg(MyFactory); | 167 static GMRegistry reg(MyFactory); |
| 168 static GMRegistry Creg(CMyFactory); | 168 static GMRegistry Creg(CMyFactory); |
| 169 static GMRegistry Creg2(CMyFactory2); | 169 static GMRegistry Creg2(CMyFactory2); |
| 170 } | 170 } |
| OLD | NEW |