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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { | 38 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
SkScalar dx) { |
39 draw_cell(canvas, bm, mat, 0 * dx, kNone_SkFilterQuality); | 39 draw_cell(canvas, bm, mat, 0 * dx, kNone_SkFilterQuality); |
40 draw_cell(canvas, bm, mat, 1 * dx, kLow_SkFilterQuality); | 40 draw_cell(canvas, bm, mat, 1 * dx, kLow_SkFilterQuality); |
41 draw_cell(canvas, bm, mat, 2 * dx, kMedium_SkFilterQuality); | 41 draw_cell(canvas, bm, mat, 2 * dx, kMedium_SkFilterQuality); |
42 draw_cell(canvas, bm, mat, 3 * dx, kHigh_SkFilterQuality); | 42 draw_cell(canvas, bm, mat, 3 * dx, kHigh_SkFilterQuality); |
43 } | 43 } |
44 | 44 |
45 class FilterIndiaBoxGM : public skiagm::GM { | 45 class FilterIndiaBoxGM : public skiagm::GM { |
46 void onOnceBeforeDraw() SK_OVERRIDE { | 46 void onOnceBeforeDraw() override { |
47 this->makeBitmap(); | 47 this->makeBitmap(); |
48 | 48 |
49 SkScalar cx = SkScalarHalf(fBM.width()); | 49 SkScalar cx = SkScalarHalf(fBM.width()); |
50 SkScalar cy = SkScalarHalf(fBM.height()); | 50 SkScalar cy = SkScalarHalf(fBM.height()); |
51 | 51 |
52 float vertScale = 30.0f/55.0f; | 52 float vertScale = 30.0f/55.0f; |
53 float horizScale = 150.0f/200.0f; | 53 float horizScale = 150.0f/200.0f; |
54 | 54 |
55 fMatrix[0].setScale(horizScale, vertScale); | 55 fMatrix[0].setScale(horizScale, vertScale); |
56 fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertS
cale); | 56 fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertS
cale); |
57 } | 57 } |
58 | 58 |
59 public: | 59 public: |
60 SkBitmap fBM; | 60 SkBitmap fBM; |
61 SkMatrix fMatrix[2]; | 61 SkMatrix fMatrix[2]; |
62 SkString fName; | 62 SkString fName; |
63 | 63 |
64 FilterIndiaBoxGM() { | 64 FilterIndiaBoxGM() { |
65 this->setBGColor(0xFFDDDDDD); | 65 this->setBGColor(0xFFDDDDDD); |
66 } | 66 } |
67 | 67 |
68 FilterIndiaBoxGM(const char filename[]) : fFilename(filename) { | 68 FilterIndiaBoxGM(const char filename[]) : fFilename(filename) { |
69 fName.printf("filterindiabox"); | 69 fName.printf("filterindiabox"); |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 SkString onShortName() SK_OVERRIDE { | 73 SkString onShortName() override { |
74 return fName; | 74 return fName; |
75 } | 75 } |
76 | 76 |
77 SkISize onISize() SK_OVERRIDE { | 77 SkISize onISize() override { |
78 return SkISize::Make(1024, 768); | 78 return SkISize::Make(1024, 768); |
79 } | 79 } |
80 | 80 |
81 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 81 void onDraw(SkCanvas* canvas) override { |
82 canvas->translate(10, 10); | 82 canvas->translate(10, 10); |
83 for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) { | 83 for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) { |
84 SkSize size = computeSize(fBM, fMatrix[i]); | 84 SkSize size = computeSize(fBM, fMatrix[i]); |
85 size.fWidth += 20; | 85 size.fWidth += 20; |
86 size.fHeight += 20; | 86 size.fHeight += 20; |
87 | 87 |
88 draw_row(canvas, fBM, fMatrix[i], size.fWidth); | 88 draw_row(canvas, fBM, fMatrix[i], size.fWidth); |
89 canvas->translate(0, size.fHeight); | 89 canvas->translate(0, size.fHeight); |
90 } | 90 } |
91 } | 91 } |
(...skipping 24 matching lines...) Expand all Loading... |
116 fSize = fBM.height(); | 116 fSize = fBM.height(); |
117 } | 117 } |
118 private: | 118 private: |
119 typedef skiagm::GM INHERITED; | 119 typedef skiagm::GM INHERITED; |
120 }; | 120 }; |
121 | 121 |
122 ////////////////////////////////////////////////////////////////////////////// | 122 ////////////////////////////////////////////////////////////////////////////// |
123 | 123 |
124 | 124 |
125 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) | 125 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) |
OLD | NEW |