| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) { | 74 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) { |
| 75 for (int j = 0; j < 2; ++j) { | 75 for (int j = 0; j < 2; ++j) { |
| 76 for (int k = 0; k < 2; ++k) { | 76 for (int k = 0; k < 2; ++k) { |
| 77 this->drawTestPattern(i, (2*j)+k, canvas, flags[i], j, k); | 77 this->drawTestPattern(i, (2*j)+k, canvas, flags[i], j, k); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 virtual uint32_t onGetFlags() SK_OVERRIDE const { return kSkipPicture_Flag;
} | 84 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kSkipPicture_Flag;
} |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 void drawTestPattern(int x, int y, SkCanvas* canvas, | 87 void drawTestPattern(int x, int y, SkCanvas* canvas, |
| 88 SkCanvas::SaveFlags flags, bool doClip, bool doScale) { | 88 SkCanvas::SaveFlags flags, bool doClip, bool doScale) { |
| 89 canvas->save(); | 89 canvas->save(); |
| 90 canvas->translate(x*WIDTH, y*HEIGHT); | 90 canvas->translate(x*WIDTH, y*HEIGHT); |
| 91 | 91 |
| 92 canvas->drawRect(fOutlineRect, fStrokePaint); | 92 canvas->drawRect(fOutlineRect, fStrokePaint); |
| 93 canvas->save(flags); | 93 canvas->save(flags); |
| 94 if(doClip) { | 94 if(doClip) { |
| 95 canvas->clipPath(fPath); | 95 canvas->clipPath(fPath); |
| 96 } | 96 } |
| 97 if (doScale) { | 97 if (doScale) { |
| 98 canvas->scale(0.5, 0.5); | 98 canvas->scale(SkDoubleToScalar(0.5), SkDoubleToScalar(0.5)); |
| 99 } | 99 } |
| 100 canvas->restore(); | 100 canvas->restore(); |
| 101 canvas->drawRect(fFillRect, fFillPaint); | 101 canvas->drawRect(fFillRect, fFillPaint); |
| 102 | 102 |
| 103 canvas->restore(); | 103 canvas->restore(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 typedef GM INHERITED; | 106 typedef GM INHERITED; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 ////////////////////////////////////////////////////////////////////////////// | 109 ////////////////////////////////////////////////////////////////////////////// |
| 110 | 110 |
| 111 DEF_GM( return SkNEW(CanvasStateGM); ) | 111 DEF_GM( return SkNEW(CanvasStateGM); ) |
| 112 | 112 |
| 113 } // end namespace | 113 } // end namespace |
| OLD | NEW |