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 namespace skiagm { | 10 namespace skiagm { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void draw(SkCanvas* canvas, int x, int y, int xSize, int ySize) { | 53 void draw(SkCanvas* canvas, int x, int y, int xSize, int ySize) { |
54 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), | 54 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), |
55 SkIntToScalar(xSize), SkIntToScalar(ySize)); | 55 SkIntToScalar(xSize), SkIntToScalar(ySize)); |
56 SkPaint p; | 56 SkPaint p; |
57 p.setFilterQuality(fFilterQuality); | 57 p.setFilterQuality(fFilterQuality); |
58 canvas->drawBitmapRect(fBM, r, &p); | 58 canvas->drawBitmapRect(fBM, r, &p); |
59 } | 59 } |
60 | 60 |
61 void onDraw(SkCanvas* canvas) override { | 61 void onDraw(SkCanvas* canvas) override { |
62 SkScalar gScales[] = { 0.9f, 0.8f, 0.75f, 0.6f, 0.5f, 0.4f, 0.25f, 0.2f,
0.1f }; | 62 SkScalar gScales[] = { 0.9f, 0.8f, 0.75f, 0.6f, 0.5f, 0.4f, 0.25f, 0.2f,
0.1f }; |
63 | 63 |
64 SkASSERT(kNumVertImages-1 == (int)SK_ARRAY_COUNT(gScales)/2); | 64 SkASSERT(kNumVertImages-1 == (int)SK_ARRAY_COUNT(gScales)/2); |
65 | 65 |
66 // Minimize vertically | 66 // Minimize vertically |
67 for (int i = 0; i < (int)SK_ARRAY_COUNT(gScales); ++i) { | 67 for (int i = 0; i < (int)SK_ARRAY_COUNT(gScales); ++i) { |
68 int height = SkScalarFloorToInt(fBM.height() * gScales[i]); | 68 int height = SkScalarFloorToInt(fBM.height() * gScales[i]); |
69 | 69 |
70 int yOff; | 70 int yOff; |
71 if (i <= (int)SK_ARRAY_COUNT(gScales)/2) { | 71 if (i <= (int)SK_ARRAY_COUNT(gScales)/2) { |
72 yOff = kSpacer + i * (fBM.height() + kSpacer); | 72 yOff = kSpacer + i * (fBM.height() + kSpacer); |
73 } else { | 73 } else { |
(...skipping 30 matching lines...) Expand all Loading... |
104 SkBitmap fBM; | 104 SkBitmap fBM; |
105 SkFilterQuality fFilterQuality; | 105 SkFilterQuality fFilterQuality; |
106 | 106 |
107 typedef GM INHERITED; | 107 typedef GM INHERITED; |
108 }; | 108 }; |
109 | 109 |
110 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
112 DEF_GM(return new AnisotropicGM;) | 112 DEF_GM(return new AnisotropicGM;) |
113 } | 113 } |
OLD | NEW |