Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Side by Side Diff: gm/tilemodes_scaled.cpp

Issue 1014533004: SkPaint::FilterLevel -> SkFilterQuality (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/tilemodes.cpp ('k') | include/core/SkPaint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gm.h" 8 #include "gm.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkRegion.h" 10 #include "SkRegion.h"
(...skipping 17 matching lines...) Expand all
28 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 28 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
29 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; 29 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
30 SkPaint paint; 30 SkPaint paint;
31 31
32 paint.setDither(true); 32 paint.setDither(true);
33 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, 33 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
34 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); 34 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
35 canvas.drawPaint(paint); 35 canvas.drawPaint(paint);
36 } 36 }
37 37
38 static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte r_level, 38 static void setup(SkPaint* paint, const SkBitmap& bm, SkFilterQuality filter_lev el,
39 SkShader::TileMode tmx, SkShader::TileMode tmy) { 39 SkShader::TileMode tmx, SkShader::TileMode tmy) {
40 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); 40 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
41 paint->setShader(shader)->unref(); 41 paint->setShader(shader)->unref();
42 paint->setFilterLevel(filter_level); 42 paint->setFilterQuality(filter_level);
43 } 43 }
44 44
45 static const SkColorType gColorTypes[] = { 45 static const SkColorType gColorTypes[] = {
46 kN32_SkColorType, 46 kN32_SkColorType,
47 kRGB_565_SkColorType, 47 kRGB_565_SkColorType,
48 }; 48 };
49 49
50 class ScaledTilingGM : public skiagm::GM { 50 class ScaledTilingGM : public skiagm::GM {
51 SkAutoTUnref<SkBlurDrawLooper> fLooper; 51 SkAutoTUnref<SkBlurDrawLooper> fLooper;
52 public: 52 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 85 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
86 float scale = 32.f/kPOTSize; 86 float scale = 32.f/kPOTSize;
87 87
88 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; 88 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
89 89
90 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; 90 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
91 91
92 static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; 92 static const char* gColorTypeNames[] = { "8888" , "565", "4444" };
93 93
94 static const SkPaint::FilterLevel gFilterLevels[] = 94 static const SkFilterQuality gFilterQualitys[] =
95 { SkPaint::kNone_FilterLevel, 95 { kNone_SkFilterQuality,
96 SkPaint::kLow_FilterLevel, 96 kLow_SkFilterQuality,
97 SkPaint::kMedium_FilterLevel, 97 kMedium_SkFilterQuality,
98 SkPaint::kHigh_FilterLevel }; 98 kHigh_SkFilterQuality };
99 static const char* gFilterNames[] = { "None", "Low", "Medium", "High" }; 99 static const char* gFilterNames[] = { "None", "Low", "Medium", "High" };
100 100
101 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode }; 101 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
102 static const char* gModeNames[] = { "C", "R", "M" }; 102 static const char* gModeNames[] = { "C", "R", "M" };
103 103
104 SkScalar y = SkIntToScalar(24); 104 SkScalar y = SkIntToScalar(24);
105 SkScalar x = SkIntToScalar(10)/scale; 105 SkScalar x = SkIntToScalar(10)/scale;
106 106
107 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { 107 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
108 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { 108 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
109 SkPaint p; 109 SkPaint p;
110 SkString str; 110 SkString str;
111 p.setAntiAlias(true); 111 p.setAntiAlias(true);
112 sk_tool_utils::set_portable_typeface(&p); 112 sk_tool_utils::set_portable_typeface(&p);
113 p.setDither(true); 113 p.setDither(true);
114 p.setLooper(fLooper); 114 p.setLooper(fLooper);
115 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); 115 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
116 116
117 p.setTextAlign(SkPaint::kCenter_Align); 117 p.setTextAlign(SkPaint::kCenter_Align);
118 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2 ), y, p); 118 canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2 ), y, p);
119 119
120 x += r.width() * 4 / 3; 120 x += r.width() * 4 / 3;
121 } 121 }
122 } 122 }
123 123
124 y = SkIntToScalar(40) / scale; 124 y = SkIntToScalar(40) / scale;
125 125
126 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { 126 for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
127 for (size_t j = 0; j < SK_ARRAY_COUNT(gFilterLevels); j++) { 127 for (size_t j = 0; j < SK_ARRAY_COUNT(gFilterQualitys); j++) {
128 x = SkIntToScalar(10)/scale; 128 x = SkIntToScalar(10)/scale;
129 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { 129 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
130 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { 130 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
131 SkPaint paint; 131 SkPaint paint;
132 #if 1 // Temporary change to regen bitmap before each draw. This may help tracki ng down an issue 132 #if 1 // Temporary change to regen bitmap before each draw. This may help tracki ng down an issue
133 // on SGX where resizing NPOT textures to POT textures exhibits a driver b ug. 133 // on SGX where resizing NPOT textures to POT textures exhibits a driver b ug.
134 if (!fPowerOfTwoSize) { 134 if (!fPowerOfTwoSize) {
135 makebm(&fTexture[i], gColorTypes[i], size, size); 135 makebm(&fTexture[i], gColorTypes[i], size, size);
136 } 136 }
137 #endif 137 #endif
138 setup(&paint, fTexture[i], gFilterLevels[j], gModes[kx], gModes[ky]); 138 setup(&paint, fTexture[i], gFilterQualitys[j], gModes[kx ], gModes[ky]);
139 paint.setDither(true); 139 paint.setDither(true);
140 140
141 canvas->save(); 141 canvas->save();
142 canvas->scale(scale,scale); 142 canvas->scale(scale,scale);
143 canvas->translate(x, y); 143 canvas->translate(x, y);
144 canvas->drawRect(r, paint); 144 canvas->drawRect(r, paint);
145 canvas->restore(); 145 canvas->restore();
146 146
147 x += r.width() * 4 / 3; 147 x += r.width() * 4 / 3;
148 } 148 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 private: 269 private:
270 typedef skiagm::GM INHERITED; 270 typedef skiagm::GM INHERITED;
271 }; 271 };
272 272
273 ////////////////////////////////////////////////////////////////////////////// 273 //////////////////////////////////////////////////////////////////////////////
274 274
275 DEF_GM( return new ScaledTilingGM(true); ) 275 DEF_GM( return new ScaledTilingGM(true); )
276 DEF_GM( return new ScaledTilingGM(false); ) 276 DEF_GM( return new ScaledTilingGM(false); )
277 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) 277 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); )
278 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) 278 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); )
OLDNEW
« no previous file with comments | « gm/tilemodes.cpp ('k') | include/core/SkPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698