| OLD | NEW | 
|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3  * Copyright 2011 Google Inc. | 3  * Copyright 2011 Google Inc. | 
| 4  * | 4  * | 
| 5  * Use of this source code is governed by a BSD-style license that can be | 5  * Use of this source code is governed by a BSD-style license that can be | 
| 6  * found in the LICENSE file. | 6  * found in the LICENSE file. | 
| 7  */ | 7  */ | 
| 8 | 8 | 
| 9 | 9 | 
| 10 | 10 | 
| 11 #include "gm.h" | 11 #include "gm.h" | 
| 12 #include "SkRandom.h" | 12 #include "SkRandom.h" | 
| 13 | 13 | 
| 14 #define W   400 | 14 #define W   400 | 
| 15 #define H   400 | 15 #define H   400 | 
| 16 #define N   50 | 16 #define N   50 | 
| 17 | 17 | 
| 18 static const SkScalar SW = SkIntToScalar(W); | 18 static const SkScalar SW = SkIntToScalar(W); | 
| 19 static const SkScalar SH = SkIntToScalar(H); | 19 static const SkScalar SH = SkIntToScalar(H); | 
| 20 | 20 | 
| 21 static void rnd_rect(SkRect* r, SkPaint* paint, SkLCGRandom& rand) { | 21 static void rnd_rect(SkRect* r, SkPaint* paint, SkRandom& rand) { | 
| 22     SkScalar x = rand.nextUScalar1() * W; | 22     SkScalar x = rand.nextUScalar1() * W; | 
| 23     SkScalar y = rand.nextUScalar1() * H; | 23     SkScalar y = rand.nextUScalar1() * H; | 
| 24     SkScalar w = rand.nextUScalar1() * (W >> 2); | 24     SkScalar w = rand.nextUScalar1() * (W >> 2); | 
| 25     SkScalar h = rand.nextUScalar1() * (H >> 2); | 25     SkScalar h = rand.nextUScalar1() * (H >> 2); | 
| 26     SkScalar hoffset = rand.nextSScalar1(); | 26     SkScalar hoffset = rand.nextSScalar1(); | 
| 27     SkScalar woffset = rand.nextSScalar1(); | 27     SkScalar woffset = rand.nextSScalar1(); | 
| 28 | 28 | 
| 29     r->set(x, y, x + w, y + h); | 29     r->set(x, y, x + w, y + h); | 
| 30     r->offset(-w/2 + woffset, -h/2 + hoffset); | 30     r->offset(-w/2 + woffset, -h/2 + hoffset); | 
| 31 | 31 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 58 | 58 | 
| 59         for (int y = 0; y < 2; y++) { | 59         for (int y = 0; y < 2; y++) { | 
| 60             paint.setAntiAlias(!!y); | 60             paint.setAntiAlias(!!y); | 
| 61             SkAutoCanvasRestore acr(canvas, true); | 61             SkAutoCanvasRestore acr(canvas, true); | 
| 62             canvas->translate(0, SH * y); | 62             canvas->translate(0, SH * y); | 
| 63             canvas->clipRect(SkRect::MakeLTRB( | 63             canvas->clipRect(SkRect::MakeLTRB( | 
| 64                                               SkIntToScalar(2), SkIntToScalar(2) | 64                                               SkIntToScalar(2), SkIntToScalar(2) | 
| 65                                               , SW - SkIntToScalar(2), SH - SkIn
     tToScalar(2) | 65                                               , SW - SkIntToScalar(2), SH - SkIn
     tToScalar(2) | 
| 66                                               )); | 66                                               )); | 
| 67 | 67 | 
| 68             SkLCGRandom rand; | 68             SkRandom rand; | 
| 69             for (int i = 0; i < N; i++) { | 69             for (int i = 0; i < N; i++) { | 
| 70                 SkRect r; | 70                 SkRect r; | 
| 71                 rnd_rect(&r, &paint, rand); | 71                 rnd_rect(&r, &paint, rand); | 
| 72                 canvas->drawOval(r, paint); | 72                 canvas->drawOval(r, paint); | 
| 73                 rnd_rect(&r, &paint, rand); | 73                 rnd_rect(&r, &paint, rand); | 
| 74                 canvas->drawRoundRect(r, r.width()/4, r.height()/4, paint); | 74                 canvas->drawRoundRect(r, r.width()/4, r.height()/4, paint); | 
| 75                 rnd_rect(&r, &paint, rand); | 75                 rnd_rect(&r, &paint, rand); | 
| 76             } | 76             } | 
| 77         } | 77         } | 
| 78     } | 78     } | 
| 79 | 79 | 
| 80 private: | 80 private: | 
| 81     typedef skiagm::GM INHERITED; | 81     typedef skiagm::GM INHERITED; | 
| 82 }; | 82 }; | 
| 83 | 83 | 
| 84 class Strokes2GM : public skiagm::GM { | 84 class Strokes2GM : public skiagm::GM { | 
| 85     SkPath fPath; | 85     SkPath fPath; | 
| 86 public: | 86 public: | 
| 87     Strokes2GM() { | 87     Strokes2GM() { | 
| 88         SkLCGRandom rand; | 88         SkRandom rand; | 
| 89         fPath.moveTo(0, 0); | 89         fPath.moveTo(0, 0); | 
| 90         for (int i = 0; i < 13; i++) { | 90         for (int i = 0; i < 13; i++) { | 
| 91             SkScalar x = rand.nextUScalar1() * (W >> 1); | 91             SkScalar x = rand.nextUScalar1() * (W >> 1); | 
| 92             SkScalar y = rand.nextUScalar1() * (H >> 1); | 92             SkScalar y = rand.nextUScalar1() * (H >> 1); | 
| 93             fPath.lineTo(x, y); | 93             fPath.lineTo(x, y); | 
| 94         } | 94         } | 
| 95     } | 95     } | 
| 96 | 96 | 
| 97 protected: | 97 protected: | 
| 98     virtual uint32_t onGetFlags() const SK_OVERRIDE { | 98     virtual uint32_t onGetFlags() const SK_OVERRIDE { | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 122 | 122 | 
| 123         for (int y = 0; y < 2; y++) { | 123         for (int y = 0; y < 2; y++) { | 
| 124             paint.setAntiAlias(!!y); | 124             paint.setAntiAlias(!!y); | 
| 125             SkAutoCanvasRestore acr(canvas, true); | 125             SkAutoCanvasRestore acr(canvas, true); | 
| 126             canvas->translate(0, SH * y); | 126             canvas->translate(0, SH * y); | 
| 127             canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2), | 127             canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2), | 
| 128                                               SkIntToScalar(2), | 128                                               SkIntToScalar(2), | 
| 129                                               SW - SkIntToScalar(2), | 129                                               SW - SkIntToScalar(2), | 
| 130                                               SH - SkIntToScalar(2))); | 130                                               SH - SkIntToScalar(2))); | 
| 131 | 131 | 
| 132             SkLCGRandom rand; | 132             SkRandom rand; | 
| 133             for (int i = 0; i < N/2; i++) { | 133             for (int i = 0; i < N/2; i++) { | 
| 134                 SkRect r; | 134                 SkRect r; | 
| 135                 rnd_rect(&r, &paint, rand); | 135                 rnd_rect(&r, &paint, rand); | 
| 136                 rotate(SkIntToScalar(15), SW/2, SH/2, canvas); | 136                 rotate(SkIntToScalar(15), SW/2, SH/2, canvas); | 
| 137                 canvas->drawPath(fPath, paint); | 137                 canvas->drawPath(fPath, paint); | 
| 138             } | 138             } | 
| 139         } | 139         } | 
| 140     } | 140     } | 
| 141 | 141 | 
| 142 private: | 142 private: | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 253 | 253 | 
| 254 ////////////////////////////////////////////////////////////////////////////// | 254 ////////////////////////////////////////////////////////////////////////////// | 
| 255 | 255 | 
| 256 static skiagm::GM* F0(void*) { return new StrokesGM; } | 256 static skiagm::GM* F0(void*) { return new StrokesGM; } | 
| 257 static skiagm::GM* F1(void*) { return new Strokes2GM; } | 257 static skiagm::GM* F1(void*) { return new Strokes2GM; } | 
| 258 static skiagm::GM* F2(void*) { return new Strokes3GM; } | 258 static skiagm::GM* F2(void*) { return new Strokes3GM; } | 
| 259 | 259 | 
| 260 static skiagm::GMRegistry R0(F0); | 260 static skiagm::GMRegistry R0(F0); | 
| 261 static skiagm::GMRegistry R1(F1); | 261 static skiagm::GMRegistry R1(F1); | 
| 262 static skiagm::GMRegistry R2(F2); | 262 static skiagm::GMRegistry R2(F2); | 
| OLD | NEW | 
|---|