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

Side by Side Diff: gm/tilemodes_scaled.cpp

Issue 296823008: Revert of Remove unused (by clients) SkUnitMapper (https://codereview.chromium.org/283273002/) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « gm/tilemodes.cpp ('k') | gyp/SampleApp.gyp » ('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"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "SkUtils.h" 12 #include "SkUtils.h"
13 #include "SkColorPriv.h" 13 #include "SkColorPriv.h"
14 #include "SkColorFilter.h" 14 #include "SkColorFilter.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 #include "SkBlurMask.h" 16 #include "SkBlurMask.h"
17 17
18 // effects 18 // effects
19 #include "SkGradientShader.h" 19 #include "SkGradientShader.h"
20 #include "SkUnitMappers.h"
20 #include "SkBlurDrawLooper.h" 21 #include "SkBlurDrawLooper.h"
21 22
22 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { 23 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
23 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); 24 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
24 bm->eraseColor(SK_ColorTRANSPARENT); 25 bm->eraseColor(SK_ColorTRANSPARENT);
25 26
26 SkCanvas canvas(*bm); 27 SkCanvas canvas(*bm);
27 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} }; 28 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} };
28 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 29 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
29 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; 30 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
30 SkPaint paint; 31 SkPaint paint;
31 32
33 SkUnitMapper* um = NULL;
34
35 um = new SkCosineMapper;
36 // um = new SkDiscreteMapper(12);
37
38 SkAutoUnref au(um);
39
32 paint.setDither(true); 40 paint.setDither(true);
33 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, 41 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
34 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); 42 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref() ;
35 canvas.drawPaint(paint); 43 canvas.drawPaint(paint);
36 } 44 }
37 45
38 static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte r_level, 46 static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte r_level,
39 SkShader::TileMode tmx, SkShader::TileMode tmy) { 47 SkShader::TileMode tmx, SkShader::TileMode tmy) {
40 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); 48 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
41 paint->setShader(shader)->unref(); 49 paint->setShader(shader)->unref();
42 paint->setFilterLevel(filter_level); 50 paint->setFilterLevel(filter_level);
43 } 51 }
44 52
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 private: 285 private:
278 typedef skiagm::GM INHERITED; 286 typedef skiagm::GM INHERITED;
279 }; 287 };
280 288
281 ////////////////////////////////////////////////////////////////////////////// 289 //////////////////////////////////////////////////////////////////////////////
282 290
283 DEF_GM( return new ScaledTilingGM(true); ) 291 DEF_GM( return new ScaledTilingGM(true); )
284 DEF_GM( return new ScaledTilingGM(false); ) 292 DEF_GM( return new ScaledTilingGM(false); )
285 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) 293 DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); )
286 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) 294 DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); )
OLDNEW
« no previous file with comments | « gm/tilemodes.cpp ('k') | gyp/SampleApp.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698