OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return true; | 101 return true; |
102 } | 102 } |
103 return this->INHERITED::onQuery(evt); | 103 return this->INHERITED::onQuery(evt); |
104 } | 104 } |
105 | 105 |
106 void draw_real_circle(SkCanvas* canvas, SkScalar radius) { | 106 void draw_real_circle(SkCanvas* canvas, SkScalar radius) { |
107 int w = SkScalarCeilToInt(radius * 2); | 107 int w = SkScalarCeilToInt(radius * 2); |
108 int h = w; | 108 int h = w; |
109 | 109 |
110 SkBitmap bm; | 110 SkBitmap bm; |
111 bm.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 111 bm.allocN32Pixels(w, h); |
112 bm.allocPixels(); | |
113 bm.eraseColor(0); | 112 bm.eraseColor(0); |
114 | 113 |
115 SkAutoLockPixels alp(bm); | 114 SkAutoLockPixels alp(bm); |
116 | 115 |
117 SkScalar cx = radius; | 116 SkScalar cx = radius; |
118 SkScalar cy = radius; | 117 SkScalar cy = radius; |
119 for (int y = 0; y < h; y += 1) { | 118 for (int y = 0; y < h; y += 1) { |
120 for (int x = 0; x < w; x += 1) { | 119 for (int x = 0; x < w; x += 1) { |
121 float d = sqrtf((x - cx)*(x - cx) + (y - cy)*(y - cy)); | 120 float d = sqrtf((x - cx)*(x - cx) + (y - cy)*(y - cy)); |
122 if (d <= radius) { | 121 if (d <= radius) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 }; | 351 }; |
353 | 352 |
354 /////////////////////////////////////////////////////////////////////////////// | 353 /////////////////////////////////////////////////////////////////////////////// |
355 | 354 |
356 static SkView* F0() { return new RotateCirclesView; } | 355 static SkView* F0() { return new RotateCirclesView; } |
357 static SkViewRegister gR0(F0); | 356 static SkViewRegister gR0(F0); |
358 static SkView* F1() { return new TestCirclesView; } | 357 static SkView* F1() { return new TestCirclesView; } |
359 static SkViewRegister gR1(F1); | 358 static SkViewRegister gR1(F1); |
360 static SkView* F2() { return new TestStrokeView; } | 359 static SkView* F2() { return new TestStrokeView; } |
361 static SkViewRegister gR2(F2); | 360 static SkViewRegister gR2(F2); |
OLD | NEW |