| 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 "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "SkXMLParser.h" | 27 #include "SkXMLParser.h" |
| 28 #include "SkColorPriv.h" | 28 #include "SkColorPriv.h" |
| 29 #include "SkImageDecoder.h" | 29 #include "SkImageDecoder.h" |
| 30 | 30 |
| 31 class LinesView : public SampleView { | 31 class LinesView : public SampleView { |
| 32 public: | 32 public: |
| 33 LinesView() {} | 33 LinesView() {} |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 // overrides from SkEventSink | 36 // overrides from SkEventSink |
| 37 virtual bool onQuery(SkEvent* evt) { | 37 bool onQuery(SkEvent* evt) override { |
| 38 if (SampleCode::TitleQ(*evt)) { | 38 if (SampleCode::TitleQ(*evt)) { |
| 39 SampleCode::TitleR(evt, "Lines"); | 39 SampleCode::TitleR(evt, "Lines"); |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 return this->INHERITED::onQuery(evt); | 42 return this->INHERITED::onQuery(evt); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /* | 45 /* |
| 46 0x1F * x + 0x1F * (32 - x) | 46 0x1F * x + 0x1F * (32 - x) |
| 47 */ | 47 */ |
| 48 void drawRings(SkCanvas* canvas) { | 48 void drawRings(SkCanvas* canvas) { |
| 49 canvas->scale(SkIntToScalar(1)/2, SkIntToScalar(1)/2); | 49 canvas->scale(SkIntToScalar(1)/2, SkIntToScalar(1)/2); |
| 50 | 50 |
| 51 SkRect r; | 51 SkRect r; |
| 52 SkScalar x = SkIntToScalar(10); | 52 SkScalar x = SkIntToScalar(10); |
| 53 SkScalar y = SkIntToScalar(10); | 53 SkScalar y = SkIntToScalar(10); |
| 54 r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100)); | 54 r.set(x, y, x + SkIntToScalar(100), y + SkIntToScalar(100)); |
| 55 | 55 |
| 56 SkPaint paint; | 56 SkPaint paint; |
| 57 // paint.setAntiAlias(true); | 57 // paint.setAntiAlias(true); |
| 58 paint.setStyle(SkPaint::kStroke_Style); | 58 paint.setStyle(SkPaint::kStroke_Style); |
| 59 paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3))); | 59 paint.setStrokeWidth(SkScalarHalf(SkIntToScalar(3))); |
| 60 paint.setColor(0xFFFF8800); | 60 paint.setColor(0xFFFF8800); |
| 61 // paint.setColor(0xFFFFFFFF); | 61 // paint.setColor(0xFFFFFFFF); |
| 62 canvas->drawRect(r, paint); | 62 canvas->drawRect(r, paint); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void onDrawContent(SkCanvas* canvas) { | 65 void onDrawContent(SkCanvas* canvas) override { |
| 66 SkBitmap bm; | 66 SkBitmap bm; |
| 67 SkImageDecoder::DecodeFile("/kill.gif", &bm); | 67 SkImageDecoder::DecodeFile("/kill.gif", &bm); |
| 68 canvas->drawBitmap(bm, 0, 0, NULL); | 68 canvas->drawBitmap(bm, 0, 0, NULL); |
| 69 | 69 |
| 70 this->drawRings(canvas); | 70 this->drawRings(canvas); |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 SkPaint paint; | 73 SkPaint paint; |
| 74 | 74 |
| 75 // fAlpha = 0x80; | 75 // fAlpha = 0x80; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 private: | 104 private: |
| 105 | 105 |
| 106 int fAlpha; | 106 int fAlpha; |
| 107 typedef SampleView INHERITED; | 107 typedef SampleView INHERITED; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
| 111 | 111 |
| 112 static SkView* MyFactory() { return new LinesView; } | 112 static SkView* MyFactory() { return new LinesView; } |
| 113 static SkViewRegister reg(MyFactory); | 113 static SkViewRegister reg(MyFactory); |
| OLD | NEW |