| 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 | 9 |
| 10 #include "Resources.h" | 10 #include "Resources.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // the other references to fSubPicture | 88 // the other references to fSubPicture |
| 89 fSubPicture->unref(); | 89 fSubPicture->unref(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual ~PictureView() { | 92 virtual ~PictureView() { |
| 93 fPicture->unref(); | 93 fPicture->unref(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 // overrides from SkEventSink | 97 // overrides from SkEventSink |
| 98 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 98 bool onQuery(SkEvent* evt) override { |
| 99 if (SampleCode::TitleQ(*evt)) { | 99 if (SampleCode::TitleQ(*evt)) { |
| 100 SampleCode::TitleR(evt, "Picture"); | 100 SampleCode::TitleR(evt, "Picture"); |
| 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 drawSomething(SkCanvas* canvas) { | 106 void drawSomething(SkCanvas* canvas) { |
| 107 SkPaint paint; | 107 SkPaint paint; |
| 108 | 108 |
| 109 canvas->save(); | 109 canvas->save(); |
| 110 canvas->scale(0.5f, 0.5f); | 110 canvas->scale(0.5f, 0.5f); |
| 111 canvas->drawBitmap(fBitmap, 0, 0, NULL); | 111 canvas->drawBitmap(fBitmap, 0, 0, NULL); |
| 112 canvas->restore(); | 112 canvas->restore(); |
| 113 | 113 |
| 114 paint.setAntiAlias(true); | 114 paint.setAntiAlias(true); |
| 115 | 115 |
| 116 paint.setColor(SK_ColorRED); | 116 paint.setColor(SK_ColorRED); |
| 117 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50), | 117 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50), |
| 118 SkIntToScalar(40), paint); | 118 SkIntToScalar(40), paint); |
| 119 paint.setColor(SK_ColorBLACK); | 119 paint.setColor(SK_ColorBLACK); |
| 120 paint.setTextSize(SkIntToScalar(40)); | 120 paint.setTextSize(SkIntToScalar(40)); |
| 121 canvas->drawText("Picture", 7, SkIntToScalar(50), SkIntToScalar(62), | 121 canvas->drawText("Picture", 7, SkIntToScalar(50), SkIntToScalar(62), |
| 122 paint); | 122 paint); |
| 123 | 123 |
| 124 } | 124 } |
| 125 | 125 |
| 126 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 126 void onDrawContent(SkCanvas* canvas) override { |
| 127 this->drawSomething(canvas); | 127 this->drawSomething(canvas); |
| 128 | 128 |
| 129 SkPictureRecorder recorder; | 129 SkPictureRecorder recorder; |
| 130 this->drawSomething(recorder.beginRecording(100, 100, NULL, 0)); | 130 this->drawSomething(recorder.beginRecording(100, 100, NULL, 0)); |
| 131 SkAutoTUnref<SkPicture> pict(recorder.endRecording()); | 131 SkAutoTUnref<SkPicture> pict(recorder.endRecording()); |
| 132 | 132 |
| 133 canvas->save(); | 133 canvas->save(); |
| 134 canvas->translate(SkIntToScalar(300), SkIntToScalar(50)); | 134 canvas->translate(SkIntToScalar(300), SkIntToScalar(50)); |
| 135 canvas->scale(-SK_Scalar1, -SK_Scalar1); | 135 canvas->scale(-SK_Scalar1, -SK_Scalar1); |
| 136 canvas->translate(-SkIntToScalar(100), -SkIntToScalar(50)); | 136 canvas->translate(-SkIntToScalar(100), -SkIntToScalar(50)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 152 canvas->restore(); | 152 canvas->restore(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 #define INVAL_ALL_TYPE "inval-all" | 156 #define INVAL_ALL_TYPE "inval-all" |
| 157 | 157 |
| 158 void delayInval(SkMSec delay) { | 158 void delayInval(SkMSec delay) { |
| 159 (new SkEvent(INVAL_ALL_TYPE, this->getSinkID()))->postDelay(delay); | 159 (new SkEvent(INVAL_ALL_TYPE, this->getSinkID()))->postDelay(delay); |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool onEvent(const SkEvent& evt) SK_OVERRIDE { | 162 bool onEvent(const SkEvent& evt) override { |
| 163 if (evt.isType(INVAL_ALL_TYPE)) { | 163 if (evt.isType(INVAL_ALL_TYPE)) { |
| 164 this->inval(NULL); | 164 this->inval(NULL); |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 return this->INHERITED::onEvent(evt); | 167 return this->INHERITED::onEvent(evt); |
| 168 } | 168 } |
| 169 | 169 |
| 170 SkPicture* fPicture; | 170 SkPicture* fPicture; |
| 171 SkPicture* fSubPicture; | 171 SkPicture* fSubPicture; |
| 172 | 172 |
| 173 typedef SampleView INHERITED; | 173 typedef SampleView INHERITED; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 ////////////////////////////////////////////////////////////////////////////// | 176 ////////////////////////////////////////////////////////////////////////////// |
| 177 | 177 |
| 178 static SkView* MyFactory() { return new PictureView; } | 178 static SkView* MyFactory() { return new PictureView; } |
| 179 static SkViewRegister reg(MyFactory); | 179 static SkViewRegister reg(MyFactory); |
| OLD | NEW |