| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 SkPath path; | 48 SkPath path; |
| 49 path.setFillType(SkPath::kEvenOdd_FillType); | 49 path.setFillType(SkPath::kEvenOdd_FillType); |
| 50 | 50 |
| 51 path.addRect(SkRect::MakeWH(N/2, N)); | 51 path.addRect(SkRect::MakeWH(N/2, N)); |
| 52 path.addRect(SkRect::MakeWH(N, N/2)); | 52 path.addRect(SkRect::MakeWH(N, N/2)); |
| 53 path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close(); | 53 path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close(); |
| 54 | 54 |
| 55 SkPaint paint; | 55 SkPaint paint; |
| 56 paint.setShader(make_shader(SkRect::MakeWH(N, N))); | 56 paint.setShader(make_shader(SkRect::MakeWH(N, N))); |
| 57 | 57 |
| 58 canvas->drawPath(path, paint); | 58 canvas->drawPath(path, paint); |
| 59 return surface->makeImageSnapshot(); | 59 return surface->makeImageSnapshot(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 static sk_sp<SkImage> zoom_up(SkSurface* origSurf, SkImage* orig) { | 62 static sk_sp<SkImage> zoom_up(SkSurface* origSurf, SkImage* orig) { |
| 63 const SkScalar S = 16; // amount to scale up | 63 const SkScalar S = 16; // amount to scale up |
| 64 const int D = 2; // dimension scaling for the offscreen | 64 const int D = 2; // dimension scaling for the offscreen |
| 65 // since we only view the center, don't need to produce the entire thing | 65 // since we only view the center, don't need to produce the entire thing |
| 66 | 66 |
| 67 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() *
D, | 67 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() *
D, |
| 68 kOpaque_SkAlphaType); | 68 kOpaque_SkAlphaType); |
| 69 auto surface(origSurf->makeSurface(info)); | 69 auto surface(origSurf->makeSurface(info)); |
| 70 SkCanvas* canvas = surface->getCanvas(); | 70 SkCanvas* canvas = surface->getCanvas(); |
| 71 canvas->drawColor(SK_ColorWHITE); | 71 canvas->drawColor(SK_ColorWHITE); |
| 72 canvas->scale(S, S); | 72 canvas->scale(S, S); |
| 73 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S, | 73 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S, |
| 74 -SkScalarHalf(orig->height()) * (S - D) / S); | 74 -SkScalarHalf(orig->height()) * (S - D) / S); |
| 75 canvas->drawImage(orig, 0, 0, nullptr); | 75 canvas->drawImage(orig, 0, 0, nullptr); |
| 76 | 76 |
| 77 if (S > 3) { | 77 if (S > 3) { |
| 78 SkPaint paint; | 78 SkPaint paint; |
| 79 paint.setColor(SK_ColorWHITE); | 79 paint.setColor(SK_ColorWHITE); |
| 80 for (int i = 1; i < orig->height(); ++i) { | 80 for (int i = 1; i < orig->height(); ++i) { |
| 81 SkScalar y = SkIntToScalar(i); | 81 SkScalar y = SkIntToScalar(i); |
| 82 canvas->drawLine(0, y, SkIntToScalar(orig->width()), y, paint); | 82 canvas->drawLine(0, y, SkIntToScalar(orig->width()), y, paint); |
| 83 } | 83 } |
| 84 for (int i = 1; i < orig->width(); ++i) { | 84 for (int i = 1; i < orig->width(); ++i) { |
| 85 SkScalar x = SkIntToScalar(i); | 85 SkScalar x = SkIntToScalar(i); |
| 86 canvas->drawLine(x, 0, x, SkIntToScalar(orig->height()), paint); | 86 canvas->drawLine(x, 0, x, SkIntToScalar(orig->height()), paint); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 | 302 |
| 303 private: | 303 private: |
| 304 typedef SampleView INHERITED; | 304 typedef SampleView INHERITED; |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 ////////////////////////////////////////////////////////////////////////////// | 307 ////////////////////////////////////////////////////////////////////////////// |
| 308 | 308 |
| 309 static SkView* MyFactory() { return new FilterQualityView; } | 309 static SkView* MyFactory() { return new FilterQualityView; } |
| 310 static SkViewRegister reg(MyFactory); | 310 static SkViewRegister reg(MyFactory); |
| OLD | NEW |