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