OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // since we only view the center, don't need to produce the entire thing | 52 // since we only view the center, don't need to produce the entire thing |
53 | 53 |
54 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() *
D, | 54 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() *
D, |
55 kOpaque_SkAlphaType); | 55 kOpaque_SkAlphaType); |
56 SkAutoTUnref<SkSurface> surface(orig->newSurface(info)); | 56 SkAutoTUnref<SkSurface> surface(orig->newSurface(info)); |
57 SkCanvas* canvas = surface->getCanvas(); | 57 SkCanvas* canvas = surface->getCanvas(); |
58 canvas->drawColor(SK_ColorWHITE); | 58 canvas->drawColor(SK_ColorWHITE); |
59 canvas->scale(S, S); | 59 canvas->scale(S, S); |
60 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S, | 60 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S, |
61 -SkScalarHalf(orig->height()) * (S - D) / S); | 61 -SkScalarHalf(orig->height()) * (S - D) / S); |
62 canvas->drawImage(orig, 0, 0, NULL); | 62 canvas->drawImage(orig, 0, 0, nullptr); |
63 | 63 |
64 if (S > 3) { | 64 if (S > 3) { |
65 SkPaint paint; | 65 SkPaint paint; |
66 paint.setColor(SK_ColorWHITE); | 66 paint.setColor(SK_ColorWHITE); |
67 for (int i = 1; i < orig->height(); ++i) { | 67 for (int i = 1; i < orig->height(); ++i) { |
68 SkScalar y = SkIntToScalar(i); | 68 SkScalar y = SkIntToScalar(i); |
69 canvas->drawLine(0, y, SkIntToScalar(orig->width()), y, paint); | 69 canvas->drawLine(0, y, SkIntToScalar(orig->width()), y, paint); |
70 } | 70 } |
71 for (int i = 1; i < orig->width(); ++i) { | 71 for (int i = 1; i < orig->width(); ++i) { |
72 SkScalar x = SkIntToScalar(i); | 72 SkScalar x = SkIntToScalar(i); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 protected: | 159 protected: |
160 bool onQuery(SkEvent* evt) override { | 160 bool onQuery(SkEvent* evt) override { |
161 if (SampleCode::TitleQ(*evt)) { | 161 if (SampleCode::TitleQ(*evt)) { |
162 SampleCode::TitleR(evt, "FilterQuality"); | 162 SampleCode::TitleR(evt, "FilterQuality"); |
163 return true; | 163 return true; |
164 } | 164 } |
165 SkUnichar uni; | 165 SkUnichar uni; |
166 if (SampleCode::CharQ(*evt, &uni)) { | 166 if (SampleCode::CharQ(*evt, &uni)) { |
167 switch (uni) { | 167 switch (uni) { |
168 case '1': fAngle.inc(-ANGLE_DELTA); this->inval(NULL); return tr
ue; | 168 case '1': fAngle.inc(-ANGLE_DELTA); this->inval(nullptr); return
true; |
169 case '2': fAngle.inc( ANGLE_DELTA); this->inval(NULL); return tr
ue; | 169 case '2': fAngle.inc( ANGLE_DELTA); this->inval(nullptr); return
true; |
170 case '3': fScale.inc(-SCALE_DELTA); this->inval(NULL); return tr
ue; | 170 case '3': fScale.inc(-SCALE_DELTA); this->inval(nullptr); return
true; |
171 case '4': fScale.inc( SCALE_DELTA); this->inval(NULL); return tr
ue; | 171 case '4': fScale.inc( SCALE_DELTA); this->inval(nullptr); return
true; |
172 case '5': fShowFatBits = !fShowFatBits; this->inval(NULL); retur
n true; | 172 case '5': fShowFatBits = !fShowFatBits; this->inval(nullptr); re
turn true; |
173 default: break; | 173 default: break; |
174 } | 174 } |
175 } | 175 } |
176 return this->INHERITED::onQuery(evt); | 176 return this->INHERITED::onQuery(evt); |
177 } | 177 } |
178 | 178 |
179 void drawTheImage(SkCanvas* canvas, const SkISize& size, SkFilterQuality fil
ter, | 179 void drawTheImage(SkCanvas* canvas, const SkISize& size, SkFilterQuality fil
ter, |
180 SkScalar dx, SkScalar dy) { | 180 SkScalar dx, SkScalar dy) { |
181 SkPaint paint; | 181 SkPaint paint; |
182 paint.setAntiAlias(true); | 182 paint.setAntiAlias(true); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 str.reset(); str.appendScalar(trans[1]); | 276 str.reset(); str.appendScalar(trans[1]); |
277 canvas->drawText(str.c_str(), str.size(), textX, 250, paint); | 277 canvas->drawText(str.c_str(), str.size(), textX, 250, paint); |
278 } | 278 } |
279 | 279 |
280 bool onAnimate(const SkAnimTimer& timer) override { | 280 bool onAnimate(const SkAnimTimer& timer) override { |
281 fCurrTime = timer.msec(); | 281 fCurrTime = timer.msec(); |
282 return true; | 282 return true; |
283 } | 283 } |
284 | 284 |
285 virtual bool handleKey(SkKey key) { | 285 virtual bool handleKey(SkKey key) { |
286 this->inval(NULL); | 286 this->inval(nullptr); |
287 return true; | 287 return true; |
288 } | 288 } |
289 | 289 |
290 private: | 290 private: |
291 typedef SampleView INHERITED; | 291 typedef SampleView INHERITED; |
292 }; | 292 }; |
293 | 293 |
294 ////////////////////////////////////////////////////////////////////////////// | 294 ////////////////////////////////////////////////////////////////////////////// |
295 | 295 |
296 static SkView* MyFactory() { return new FilterQualityView; } | 296 static SkView* MyFactory() { return new FilterQualityView; } |
297 static SkViewRegister reg(MyFactory); | 297 static SkViewRegister reg(MyFactory); |
OLD | NEW |