| 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 "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 SkRect r = constr; | 141 SkRect r = constr; |
| 142 while (r.fRight < SkIntToScalar(4)) { | 142 while (r.fRight < SkIntToScalar(4)) { |
| 143 path.addRect(r); | 143 path.addRect(r); |
| 144 r.offset(dx, 0); | 144 r.offset(dx, 0); |
| 145 } | 145 } |
| 146 test_maskFromPath(path); | 146 test_maskFromPath(path); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 namespace skiagm { | |
| 152 | |
| 153 /** Draw a 2px border around the target, then red behind the target; | 151 /** Draw a 2px border around the target, then red behind the target; |
| 154 set the clip to match the target, then draw >> the target in blue. | 152 set the clip to match the target, then draw >> the target in blue. |
| 155 */ | 153 */ |
| 156 | 154 |
| 157 static void draw (SkCanvas* canvas, SkRect& target, int x, int y) { | 155 static void draw (SkCanvas* canvas, SkRect& target, int x, int y) { |
| 158 SkPaint borderPaint; | 156 SkPaint borderPaint; |
| 159 borderPaint.setColor(SkColorSetRGB(0x0, 0xDD, 0x0)); | 157 borderPaint.setColor(SkColorSetRGB(0x0, 0xDD, 0x0)); |
| 160 borderPaint.setAntiAlias(true); | 158 borderPaint.setAntiAlias(true); |
| 161 SkPaint backgroundPaint; | 159 SkPaint backgroundPaint; |
| 162 backgroundPaint.setColor(SkColorSetRGB(0xDD, 0x0, 0x0)); | 160 backgroundPaint.setColor(SkColorSetRGB(0xDD, 0x0, 0x0)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 draw_bar(canvas, 10, 30); | 196 draw_bar(canvas, 10, 30); |
| 199 } | 197 } |
| 200 | 198 |
| 201 /** | 199 /** |
| 202 Test a set of clipping problems discovered while writing blitAntiRect, | 200 Test a set of clipping problems discovered while writing blitAntiRect, |
| 203 and test all the code paths through the clipping blitters. | 201 and test all the code paths through the clipping blitters. |
| 204 Each region should show as a blue center surrounded by a 2px green | 202 Each region should show as a blue center surrounded by a 2px green |
| 205 border, with no red. | 203 border, with no red. |
| 206 */ | 204 */ |
| 207 | 205 |
| 208 class AAClipGM : public GM { | 206 class AAClipGM : public skiagm::GM { |
| 209 public: | 207 public: |
| 210 AAClipGM() { | 208 AAClipGM() { |
| 211 | 209 |
| 212 } | 210 } |
| 213 | 211 |
| 214 protected: | 212 protected: |
| 215 virtual SkString onShortName() { | 213 virtual SkString onShortName() SK_OVERRIDE { |
| 216 return SkString("aaclip"); | 214 return SkString("aaclip"); |
| 217 } | 215 } |
| 218 | 216 |
| 219 virtual SkISize onISize() { | 217 virtual SkISize onISize() SK_OVERRIDE { |
| 220 return make_isize(640, 480); | 218 return SkISize::Make(640, 480); |
| 221 } | 219 } |
| 222 | 220 |
| 223 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 221 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 224 if (false) { | 222 if (false) { |
| 225 SkRect bounds; | 223 SkRect bounds; |
| 226 canvas->getClipBounds(&bounds); | 224 canvas->getClipBounds(&bounds); |
| 227 test_shallow_gradient(canvas, bounds.width(), bounds.height()); retu
rn; | 225 test_shallow_gradient(canvas, bounds.width(), bounds.height()); retu
rn; |
| 228 } | 226 } |
| 229 if (false) { | 227 if (false) { |
| 230 test_giant_dash(canvas); return; | 228 test_giant_dash(canvas); return; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 253 draw_rect_tests(canvas); | 251 draw_rect_tests(canvas); |
| 254 | 252 |
| 255 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); | 253 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); |
| 256 canvas->translate(SkIntToScalar(50), 0); | 254 canvas->translate(SkIntToScalar(50), 0); |
| 257 draw_rect_tests(canvas); | 255 draw_rect_tests(canvas); |
| 258 } | 256 } |
| 259 | 257 |
| 260 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | 258 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } |
| 261 | 259 |
| 262 private: | 260 private: |
| 263 typedef GM INHERITED; | 261 typedef skiagm::GM INHERITED; |
| 264 }; | 262 }; |
| 265 | 263 |
| 266 ////////////////////////////////////////////////////////////////////////////// | 264 DEF_GM( return SkNEW(AAClipGM); ) |
| 267 | |
| 268 static GM* MyFactory(void*) { return new AAClipGM; } | |
| 269 static GMRegistry reg(MyFactory); | |
| 270 | |
| 271 } | |
| OLD | NEW |