| 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 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 p.setAntiAlias(true); | 28 p.setAntiAlias(true); |
| 29 // p.setDither(true); | 29 // p.setDither(true); |
| 30 p.setStrokeWidth(SkIntToScalar(width/10)); | 30 p.setStrokeWidth(SkIntToScalar(width/10)); |
| 31 p.setStyle(SkPaint::kStroke_Style); | 31 p.setStyle(SkPaint::kStroke_Style); |
| 32 | 32 |
| 33 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); | 33 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); |
| 34 | 34 |
| 35 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; | 35 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; |
| 36 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; | 36 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; |
| 37 SkShader* s = SkGradientShader::CreateSweep(r.centerX(), r.centerY(), | 37 SkShader* s = SkGradientShader::CreateSweep(r.centerX(), r.centerY(), |
| 38 colors, NULL, SK_ARRAY_COUNT(col
ors)); | 38 colors, nullptr, SK_ARRAY_COUNT(
colors)); |
| 39 p.setShader(s)->unref(); | 39 p.setShader(s)->unref(); |
| 40 | 40 |
| 41 SkAutoCanvasRestore acr(c, true); | 41 SkAutoCanvasRestore acr(c, true); |
| 42 | 42 |
| 43 c->translate(r.centerX(), r.centerY()); | 43 c->translate(r.centerX(), r.centerY()); |
| 44 c->rotate(angle); | 44 c->rotate(angle); |
| 45 c->translate(-r.centerX(), -r.centerY()); | 45 c->translate(-r.centerX(), -r.centerY()); |
| 46 | 46 |
| 47 SkRect bounds = r; | 47 SkRect bounds = r; |
| 48 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); | 48 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 canvas->translate(DX, DX*2); | 160 canvas->translate(DX, DX*2); |
| 161 draw_sweep(canvas, fBM.width(), fBM.height(), fAngle); | 161 draw_sweep(canvas, fBM.width(), fBM.height(), fAngle); |
| 162 canvas->translate(DX, 0); | 162 canvas->translate(DX, 0); |
| 163 draw_sweep(canvas, fBM.width()>>1, fBM.height()>>1, fAngle); | 163 draw_sweep(canvas, fBM.width()>>1, fBM.height()>>1, fAngle); |
| 164 canvas->translate(DX, 0); | 164 canvas->translate(DX, 0); |
| 165 draw_sweep(canvas, fBM.width()>>2, fBM.height()>>2, fAngle); | 165 draw_sweep(canvas, fBM.width()>>2, fBM.height()>>2, fAngle); |
| 166 | 166 |
| 167 fAngle += SK_Scalar1/2; | 167 fAngle += SK_Scalar1/2; |
| 168 this->inval(NULL); | 168 this->inval(nullptr); |
| 169 } | 169 } |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 typedef SampleView INHERITED; | 172 typedef SampleView INHERITED; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 ////////////////////////////////////////////////////////////////////////////// | 175 ////////////////////////////////////////////////////////////////////////////// |
| 176 | 176 |
| 177 static SkView* MyFactory() { return new DitherView; } | 177 static SkView* MyFactory() { return new DitherView; } |
| 178 static SkViewRegister reg(MyFactory); | 178 static SkViewRegister reg(MyFactory); |
| OLD | NEW |