| 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" |
| 11 #include "SkView.h" | 11 #include "SkView.h" |
| 12 #include "Sk1DPathEffect.h" | 12 #include "Sk1DPathEffect.h" |
| 13 #include "Sk2DPathEffect.h" | 13 #include "Sk2DPathEffect.h" |
| 14 #include "SkBlurMaskFilter.h" | 14 #include "SkBlurMaskFilter.h" |
| 15 #include "SkColorFilter.h" | 15 #include "SkColorMatrixFilter.h" |
| 16 #include "SkColorPriv.h" | 16 #include "SkColorPriv.h" |
| 17 #include "SkCornerPathEffect.h" | 17 #include "SkCornerPathEffect.h" |
| 18 #include "SkDashPathEffect.h" | 18 #include "SkDashPathEffect.h" |
| 19 #include "SkDiscretePathEffect.h" | 19 #include "SkDiscretePathEffect.h" |
| 20 #include "SkEmbossMaskFilter.h" | 20 #include "SkEmbossMaskFilter.h" |
| 21 #include "SkReadBuffer.h" | 21 #include "SkReadBuffer.h" |
| 22 #include "SkWriteBuffer.h" | 22 #include "SkWriteBuffer.h" |
| 23 #include "SkGradientShader.h" | 23 #include "SkGradientShader.h" |
| 24 #include "SkImageDecoder.h" | 24 #include "SkImageDecoder.h" |
| 25 #include "SkLayerRasterizer.h" | 25 #include "SkLayerRasterizer.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 SkEmbossMaskFilter::Light light; | 378 SkEmbossMaskFilter::Light light; |
| 379 light.fDirection[0] = SK_Scalar1/2; | 379 light.fDirection[0] = SK_Scalar1/2; |
| 380 light.fDirection[1] = SK_Scalar1/2; | 380 light.fDirection[1] = SK_Scalar1/2; |
| 381 light.fDirection[2] = SK_Scalar1/3; | 381 light.fDirection[2] = SK_Scalar1/3; |
| 382 light.fAmbient = 0x48; | 382 light.fAmbient = 0x48; |
| 383 light.fSpecular = 0x80; | 383 light.fSpecular = 0x80; |
| 384 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5); | 384 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5); |
| 385 SkMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, light); | 385 SkMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, light); |
| 386 | 386 |
| 387 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); | 387 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); |
| 388 SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter( | 388 SkColorFilter* lightingFilter = SkColorMatrixFilter::CreateLightingFilte
r( |
| 389 0xff89bc45, 0xff112233); | 389 0xff89bc45, 0xff112233); |
| 390 | 390 |
| 391 canvas->save(); | 391 canvas->save(); |
| 392 canvas->translate(SkIntToScalar(0), SkIntToScalar(5)); | 392 canvas->translate(SkIntToScalar(0), SkIntToScalar(5)); |
| 393 paint.setAntiAlias(true); | 393 paint.setAntiAlias(true); |
| 394 paint.setFilterQuality(kLow_SkFilterQuality); | 394 paint.setFilterQuality(kLow_SkFilterQuality); |
| 395 // !!! draw through a clip | 395 // !!! draw through a clip |
| 396 paint.setColor(SK_ColorLTGRAY); | 396 paint.setColor(SK_ColorLTGRAY); |
| 397 paint.setStyle(SkPaint::kFill_Style); | 397 paint.setStyle(SkPaint::kFill_Style); |
| 398 SkRect clip = {0, 0, SkIntToScalar(320), SkIntToScalar(120)}; | 398 SkRect clip = {0, 0, SkIntToScalar(320), SkIntToScalar(120)}; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 SkString str("GOOGLE"); | 544 SkString str("GOOGLE"); |
| 545 | 545 |
| 546 for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) { | 546 for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) { |
| 547 apply_shader(&paint, (int)i); | 547 apply_shader(&paint, (int)i); |
| 548 | 548 |
| 549 // paint.setMaskFilter(nullptr); | 549 // paint.setMaskFilter(nullptr); |
| 550 // paint.setColor(SK_ColorBLACK); | 550 // paint.setColor(SK_ColorBLACK); |
| 551 | 551 |
| 552 #if 01 | 552 #if 01 |
| 553 int index = i % SK_ARRAY_COUNT(gLightingColors); | 553 int index = i % SK_ARRAY_COUNT(gLightingColors); |
| 554 paint.setColorFilter(SkColorFilter::CreateLightingFilter( | 554 paint.setColorFilter(SkColorMatrixFilter::CreateLightingFilter( |
| 555 gLightingColors[index].fMul, | 555 gLightingColors[index].fMul, |
| 556 gLightingColors[index].fAdd))->unref(); | 556 gLightingColors[index].fAdd))->unref(); |
| 557 #endif | 557 #endif |
| 558 | 558 |
| 559 canvas->drawText(str.c_str(), str.size(), x, y, paint); | 559 canvas->drawText(str.c_str(), str.size(), x, y, paint); |
| 560 SkRect oval = { x, y - SkIntToScalar(40), x + SkIntToScalar(40), y
}; | 560 SkRect oval = { x, y - SkIntToScalar(40), x + SkIntToScalar(40), y
}; |
| 561 paint.setStyle(SkPaint::kStroke_Style); | 561 paint.setStyle(SkPaint::kStroke_Style); |
| 562 canvas->drawOval(oval, paint); | 562 canvas->drawOval(oval, paint); |
| 563 paint.setStyle(SkPaint::kFill_Style); | 563 paint.setStyle(SkPaint::kFill_Style); |
| 564 | 564 |
| 565 y += paint.getFontSpacing(); | 565 y += paint.getFontSpacing(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 canvas->restore(); | 568 canvas->restore(); |
| 569 } | 569 } |
| 570 | 570 |
| 571 private: | 571 private: |
| 572 SkPoint fClickPt; | 572 SkPoint fClickPt; |
| 573 SkBitmap fBug, fTb, fTx; | 573 SkBitmap fBug, fTb, fTx; |
| 574 typedef SampleView INHERITED; | 574 typedef SampleView INHERITED; |
| 575 }; | 575 }; |
| 576 | 576 |
| 577 ////////////////////////////////////////////////////////////////////////////// | 577 ////////////////////////////////////////////////////////////////////////////// |
| 578 | 578 |
| 579 static SkView* MyFactory() { return new DemoView; } | 579 static SkView* MyFactory() { return new DemoView; } |
| 580 static SkViewRegister reg(MyFactory); | 580 static SkViewRegister reg(MyFactory); |
| OLD | NEW |