OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return this->INHERITED::onQuery(evt); | 65 return this->INHERITED::onQuery(evt); |
66 } | 66 } |
67 | 67 |
68 virtual void onDrawContent(SkCanvas* canvas) { | 68 virtual void onDrawContent(SkCanvas* canvas) { |
69 canvas->translate(SkIntToScalar(10), SkIntToScalar(50)); | 69 canvas->translate(SkIntToScalar(10), SkIntToScalar(50)); |
70 | 70 |
71 const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1); | 71 const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1); |
72 const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1); | 72 const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1); |
73 SkPaint paint; | 73 SkPaint paint; |
74 | 74 |
75 const SkScalar scale = SkFloatToScalar(0.897917f); | 75 const SkScalar scale = 0.897917f; |
76 canvas->scale(SK_Scalar1, scale); | 76 canvas->scale(SK_Scalar1, scale); |
77 | 77 |
78 for (int k = 0; k < 2; k++) { | 78 for (int k = 0; k < 2; k++) { |
79 paint.setFilterLevel(k == 1 ? SkPaint::kLow_FilterLevel : SkPaint::k
None_FilterLevel); | 79 paint.setFilterLevel(k == 1 ? SkPaint::kLow_FilterLevel : SkPaint::k
None_FilterLevel); |
80 for (int j = 0; j < 2; j++) { | 80 for (int j = 0; j < 2; j++) { |
81 paint.setDither(j == 1); | 81 paint.setDither(j == 1); |
82 for (int i = 0; i < fBitmapCount; i++) { | 82 for (int i = 0; i < fBitmapCount; i++) { |
83 SkScalar x = (k * fBitmapCount + j) * W; | 83 SkScalar x = (k * fBitmapCount + j) * W; |
84 SkScalar y = i * H; | 84 SkScalar y = i * H; |
85 x = SkIntToScalar(SkScalarRound(x)); | 85 x = SkIntToScalar(SkScalarRound(x)); |
(...skipping 27 matching lines...) Expand all Loading... |
113 } | 113 } |
114 | 114 |
115 private: | 115 private: |
116 typedef SampleView INHERITED; | 116 typedef SampleView INHERITED; |
117 }; | 117 }; |
118 | 118 |
119 ////////////////////////////////////////////////////////////////////////////// | 119 ////////////////////////////////////////////////////////////////////////////// |
120 | 120 |
121 static SkView* MyFactory() { return new Filter2View; } | 121 static SkView* MyFactory() { return new Filter2View; } |
122 static SkViewRegister reg(MyFactory); | 122 static SkViewRegister reg(MyFactory); |
OLD | NEW |