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

Side by Side Diff: samplecode/SampleAll.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 | « include/effects/SkGradientShader.h ('k') | samplecode/SampleGradients.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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 18 matching lines...) Expand all
29 #include "SkPictureRecorder.h" 29 #include "SkPictureRecorder.h"
30 #include "SkRegion.h" 30 #include "SkRegion.h"
31 #include "SkShader.h" 31 #include "SkShader.h"
32 #include "SkComposeShader.h" 32 #include "SkComposeShader.h"
33 #include "SkCornerPathEffect.h" 33 #include "SkCornerPathEffect.h"
34 #include "SkPathMeasure.h" 34 #include "SkPathMeasure.h"
35 #include "SkPicture.h" 35 #include "SkPicture.h"
36 #include "SkRandom.h" 36 #include "SkRandom.h"
37 #include "SkTransparentShader.h" 37 #include "SkTransparentShader.h"
38 #include "SkTypeface.h" 38 #include "SkTypeface.h"
39 #include "SkUnitMappers.h"
39 #include "SkUtils.h" 40 #include "SkUtils.h"
40 #include "SkXfermode.h" 41 #include "SkXfermode.h"
41 42
42 #include <math.h> 43 #include <math.h>
43 44
44 static inline SkPMColor rgb2gray(SkPMColor c) { 45 static inline SkPMColor rgb2gray(SkPMColor c) {
45 unsigned r = SkGetPackedR32(c); 46 unsigned r = SkGetPackedR32(c);
46 unsigned g = SkGetPackedG32(c); 47 unsigned g = SkGetPackedG32(c);
47 unsigned b = SkGetPackedB32(c); 48 unsigned b = SkGetPackedB32(c);
48 49
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 for (index = 0; index < asciiLength; index++) 361 for (index = 0; index < asciiLength; index++)
361 pos2[index].set(SkIntToScalar((unsigned int)index * 10), 362 pos2[index].set(SkIntToScalar((unsigned int)index * 10),
362 SkIntToScalar(20)); 363 SkIntToScalar(20));
363 364
364 // shaders 365 // shaders
365 SkPoint linearPoints[] = { { 0, 0, }, { SkIntToScalar(40), SkIntToScalar (40) } }; 366 SkPoint linearPoints[] = { { 0, 0, }, { SkIntToScalar(40), SkIntToScalar (40) } };
366 SkColor linearColors[] = { SK_ColorRED, SK_ColorBLUE }; 367 SkColor linearColors[] = { SK_ColorRED, SK_ColorBLUE };
367 SkScalar* linearPos = NULL; 368 SkScalar* linearPos = NULL;
368 int linearCount = 2; 369 int linearCount = 2;
369 SkShader::TileMode linearMode = SkShader::kMirror_TileMode; 370 SkShader::TileMode linearMode = SkShader::kMirror_TileMode;
371 SkUnitMapper* linearMapper = new SkDiscreteMapper(3);
372 SkAutoUnref unmapLinearMapper(linearMapper);
370 SkShader* linear = SkGradientShader::CreateLinear(linearPoints, 373 SkShader* linear = SkGradientShader::CreateLinear(linearPoints,
371 linearColors, linearPos, linearCount, linearMode); 374 linearColors, linearPos, linearCount, linearMode, linearMapper);
372 375
373 SkPoint radialCenter = { SkIntToScalar(25), SkIntToScalar(25) }; 376 SkPoint radialCenter = { SkIntToScalar(25), SkIntToScalar(25) };
374 SkScalar radialRadius = SkIntToScalar(25); 377 SkScalar radialRadius = SkIntToScalar(25);
375 SkColor radialColors[] = { SK_ColorGREEN, SK_ColorGRAY, SK_ColorRED }; 378 SkColor radialColors[] = { SK_ColorGREEN, SK_ColorGRAY, SK_ColorRED };
376 SkScalar radialPos[] = { 0, SkIntToScalar(3) / 5, SkIntToScalar(1)}; 379 SkScalar radialPos[] = { 0, SkIntToScalar(3) / 5, SkIntToScalar(1)};
377 int radialCount = 3; 380 int radialCount = 3;
378 SkShader::TileMode radialMode = SkShader::kRepeat_TileMode; 381 SkShader::TileMode radialMode = SkShader::kRepeat_TileMode;
382 SkUnitMapper* radialMapper = new SkCosineMapper();
383 SkAutoUnref unmapRadialMapper(radialMapper);
379 SkShader* radial = SkGradientShader::CreateRadial(radialCenter, 384 SkShader* radial = SkGradientShader::CreateRadial(radialCenter,
380 radialRadius, radialColors, radialPos, radialCount, 385 radialRadius, radialColors, radialPos, radialCount,
381 radialMode); 386 radialMode, radialMapper);
382 387
383 SkTransparentShader* transparentShader = new SkTransparentShader(); 388 SkTransparentShader* transparentShader = new SkTransparentShader();
384 SkEmbossMaskFilter::Light light; 389 SkEmbossMaskFilter::Light light;
385 light.fDirection[0] = SK_Scalar1/2; 390 light.fDirection[0] = SK_Scalar1/2;
386 light.fDirection[1] = SK_Scalar1/2; 391 light.fDirection[1] = SK_Scalar1/2;
387 light.fDirection[2] = SK_Scalar1/3; 392 light.fDirection[2] = SK_Scalar1/3;
388 light.fAmbient = 0x48; 393 light.fAmbient = 0x48;
389 light.fSpecular = 0x80; 394 light.fSpecular = 0x80;
390 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5); 395 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5);
391 SkEmbossMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, lig ht); 396 SkEmbossMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, lig ht);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 private: 598 private:
594 SkPoint fClickPt; 599 SkPoint fClickPt;
595 SkBitmap fBug, fTb, fTx; 600 SkBitmap fBug, fTb, fTx;
596 typedef SampleView INHERITED; 601 typedef SampleView INHERITED;
597 }; 602 };
598 603
599 ////////////////////////////////////////////////////////////////////////////// 604 //////////////////////////////////////////////////////////////////////////////
600 605
601 static SkView* MyFactory() { return new DemoView; } 606 static SkView* MyFactory() { return new DemoView; }
602 static SkViewRegister reg(MyFactory); 607 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/effects/SkGradientShader.h ('k') | samplecode/SampleGradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698