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

Side by Side Diff: samplecode/SampleTiling.cpp

Issue 287063009: Revert of remove unused (by clients) SkUnitMapper (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 | « samplecode/SampleSlides.cpp ('k') | samplecode/SampleUnitMapper.cpp » ('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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkPictureRecorder.h" 13 #include "SkPictureRecorder.h"
14 #include "SkRegion.h" 14 #include "SkRegion.h"
15 #include "SkShader.h" 15 #include "SkShader.h"
16 #include "SkUtils.h" 16 #include "SkUtils.h"
17 #include "SkColorPriv.h" 17 #include "SkColorPriv.h"
18 #include "SkColorFilter.h" 18 #include "SkColorFilter.h"
19 #include "SkPicture.h" 19 #include "SkPicture.h"
20 #include "SkTypeface.h" 20 #include "SkTypeface.h"
21 21
22 // effects 22 // effects
23 #include "SkGradientShader.h" 23 #include "SkGradientShader.h"
24 #include "SkUnitMappers.h"
24 #include "SkBlurMask.h" 25 #include "SkBlurMask.h"
25 #include "SkBlurDrawLooper.h" 26 #include "SkBlurDrawLooper.h"
26 27
27 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { 28 static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
28 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); 29 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
29 bm->eraseColor(SK_ColorTRANSPARENT); 30 bm->eraseColor(SK_ColorTRANSPARENT);
30 31
31 SkCanvas canvas(*bm); 32 SkCanvas canvas(*bm);
32 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } }; 33 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } };
33 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 34 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
34 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; 35 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
35 SkPaint paint; 36 SkPaint paint;
36 37
38 SkUnitMapper* um = NULL;
39
40 um = new SkCosineMapper;
41 // um = new SkDiscreteMapper(12);
42
43 SkAutoUnref au(um);
44
37 paint.setDither(true); 45 paint.setDither(true);
38 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, 46 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
39 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); 47 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref() ;
40 canvas.drawPaint(paint); 48 canvas.drawPaint(paint);
41 } 49 }
42 50
43 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, 51 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
44 SkShader::TileMode tmx, SkShader::TileMode tmy) { 52 SkShader::TileMode tmx, SkShader::TileMode tmy) {
45 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); 53 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
46 paint->setShader(shader)->unref(); 54 paint->setShader(shader)->unref();
47 paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi lterLevel); 55 paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_Fi lterLevel);
48 } 56 }
49 57
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 170 }
163 171
164 private: 172 private:
165 typedef SampleView INHERITED; 173 typedef SampleView INHERITED;
166 }; 174 };
167 175
168 ////////////////////////////////////////////////////////////////////////////// 176 //////////////////////////////////////////////////////////////////////////////
169 177
170 static SkView* MyFactory() { return new TilingView; } 178 static SkView* MyFactory() { return new TilingView; }
171 static SkViewRegister reg(MyFactory); 179 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleSlides.cpp ('k') | samplecode/SampleUnitMapper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698