| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 paint.setXfermodeMode(SkXfermode::kPlus_Mode); | 32 paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
| 33 canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint); | 33 canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint); |
| 34 | 34 |
| 35 return rec.endRecording(); | 35 return rec.endRecording(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Exercise the optional arguments to drawPicture | 38 // Exercise the optional arguments to drawPicture |
| 39 // | 39 // |
| 40 class PictureGM : public skiagm::GM { | 40 class PictureGM : public skiagm::GM { |
| 41 public: | 41 public: |
| 42 PictureGM() : fPicture(make_picture()) {} | 42 PictureGM() |
| 43 : fPicture(NULL) |
| 44 {} |
| 43 | 45 |
| 44 protected: | 46 protected: |
| 47 virtual void onOnceBeforeDraw() { |
| 48 fPicture.reset(make_picture()); |
| 49 } |
| 50 |
| 45 SkString onShortName() SK_OVERRIDE { | 51 SkString onShortName() SK_OVERRIDE { |
| 46 return SkString("pictures"); | 52 return SkString("pictures"); |
| 47 } | 53 } |
| 48 | 54 |
| 49 SkISize onISize() SK_OVERRIDE { | 55 SkISize onISize() SK_OVERRIDE { |
| 50 return SkISize::Make(450, 120); | 56 return SkISize::Make(450, 120); |
| 51 } | 57 } |
| 52 | 58 |
| 53 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 59 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 54 canvas->translate(10, 10); | 60 canvas->translate(10, 10); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 canvas->drawPicture(fPicture, &matrix, &paint); | 75 canvas->drawPicture(fPicture, &matrix, &paint); |
| 70 } | 76 } |
| 71 | 77 |
| 72 private: | 78 private: |
| 73 SkAutoTUnref<SkPicture> fPicture; | 79 SkAutoTUnref<SkPicture> fPicture; |
| 74 | 80 |
| 75 typedef skiagm::GM INHERITED; | 81 typedef skiagm::GM INHERITED; |
| 76 }; | 82 }; |
| 77 | 83 |
| 78 DEF_GM( return SkNEW(PictureGM); ) | 84 DEF_GM( return SkNEW(PictureGM); ) |
| OLD | NEW |