| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 p.setXfermodeMode(SkXfermode::kClear_Mode); | 137 p.setXfermodeMode(SkXfermode::kClear_Mode); |
| 138 rast->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); | 138 rast->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); |
| 139 | 139 |
| 140 p.setXfermode(NULL); | 140 p.setXfermode(NULL); |
| 141 rast->addLayer(p); | 141 rast->addLayer(p); |
| 142 } | 142 } |
| 143 | 143 |
| 144 static void r5(SkLayerRasterizer* rast, SkPaint& p) { | 144 static void r5(SkLayerRasterizer* rast, SkPaint& p) { |
| 145 rast->addLayer(p); | 145 rast->addLayer(p); |
| 146 | 146 |
| 147 p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref
(); | 147 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u
nref(); |
| 148 p.setXfermodeMode(SkXfermode::kSrcOut_Mode); | 148 p.setXfermodeMode(SkXfermode::kSrcOut_Mode); |
| 149 rast->addLayer(p); | 149 rast->addLayer(p); |
| 150 } | 150 } |
| 151 | 151 |
| 152 static void r6(SkLayerRasterizer* rast, SkPaint& p) { | 152 static void r6(SkLayerRasterizer* rast, SkPaint& p) { |
| 153 rast->addLayer(p); | 153 rast->addLayer(p); |
| 154 | 154 |
| 155 p.setAntiAlias(false); | 155 p.setAntiAlias(false); |
| 156 SkLayerRasterizer* rast2 = new SkLayerRasterizer; | 156 SkLayerRasterizer* rast2 = new SkLayerRasterizer; |
| 157 r5(rast2, p); | 157 r5(rast2, p); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 p.setStrokeWidth(SK_Scalar1); | 210 p.setStrokeWidth(SK_Scalar1); |
| 211 rast->addLayer(p); | 211 rast->addLayer(p); |
| 212 } | 212 } |
| 213 | 213 |
| 214 static void r9(SkLayerRasterizer* rast, SkPaint& p) { | 214 static void r9(SkLayerRasterizer* rast, SkPaint& p) { |
| 215 rast->addLayer(p); | 215 rast->addLayer(p); |
| 216 | 216 |
| 217 SkMatrix lattice; | 217 SkMatrix lattice; |
| 218 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); | 218 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); |
| 219 lattice.postRotate(SkIntToScalar(30), 0, 0); | 219 lattice.postRotate(SkIntToScalar(30), 0, 0); |
| 220 p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref(); | 220 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref(); |
| 221 p.setXfermodeMode(SkXfermode::kClear_Mode); | 221 p.setXfermodeMode(SkXfermode::kClear_Mode); |
| 222 rast->addLayer(p); | 222 rast->addLayer(p); |
| 223 | 223 |
| 224 p.setPathEffect(NULL); | 224 p.setPathEffect(NULL); |
| 225 p.setXfermode(NULL); | 225 p.setXfermode(NULL); |
| 226 p.setStyle(SkPaint::kStroke_Style); | 226 p.setStyle(SkPaint::kStroke_Style); |
| 227 p.setStrokeWidth(SK_Scalar1); | 227 p.setStrokeWidth(SK_Scalar1); |
| 228 rast->addLayer(p); | 228 rast->addLayer(p); |
| 229 } | 229 } |
| 230 | 230 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 SkPathEffect* pathEffectTest() { | 544 SkPathEffect* pathEffectTest() { |
| 545 static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 }; | 545 static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 }; |
| 546 SkScalar gPhase = 0; | 546 SkScalar gPhase = 0; |
| 547 SkPath path; | 547 SkPath path; |
| 548 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); | 548 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); |
| 549 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) | 549 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) |
| 550 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); | 550 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); |
| 551 path.close(); | 551 path.close(); |
| 552 path.offset(SkIntToScalar(-6), 0); | 552 path.offset(SkIntToScalar(-6), 0); |
| 553 SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), | 553 SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12)
, |
| 554 gPhase, SkPath1DPathEffect::kRotate_Style); | 554 gPhase, SkPath1DPathEffect::kRotate_Style); |
| 555 SkPathEffect* inner = new SkDiscretePathEffect(SkIntToScalar(2), | 555 SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2), |
| 556 SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2)); | 556 SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2)); |
| 557 SkPathEffect* result = new SkComposePathEffect(outer, inner); | 557 SkPathEffect* result = SkComposePathEffect::Create(outer, inner); |
| 558 outer->unref(); | 558 outer->unref(); |
| 559 inner->unref(); | 559 inner->unref(); |
| 560 return result; | 560 return result; |
| 561 } | 561 } |
| 562 | 562 |
| 563 SkShader* shaderTest() { | 563 SkShader* shaderTest() { |
| 564 SkPoint pts[] = { { 0, 0, }, { SkIntToScalar(100), 0 } }; | 564 SkPoint pts[] = { { 0, 0, }, { SkIntToScalar(100), 0 } }; |
| 565 SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; | 565 SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; |
| 566 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, | 566 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, |
| 567 2, SkShader::kClamp_TileMode); | 567 2, SkShader::kClamp_TileMode); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 paint.setStyle(SkPaint::kStroke_Style); | 620 paint.setStyle(SkPaint::kStroke_Style); |
| 621 canvas->drawOval(oval, paint); | 621 canvas->drawOval(oval, paint); |
| 622 paint.setStyle(SkPaint::kFill_Style); | 622 paint.setStyle(SkPaint::kFill_Style); |
| 623 | 623 |
| 624 y += paint.getFontSpacing(); | 624 y += paint.getFontSpacing(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 canvas->restore(); | 627 canvas->restore(); |
| 628 | 628 |
| 629 if (1) { | 629 if (1) { |
| 630 SkAvoidXfermode mode(SK_ColorWHITE, 0xFF, | 630 SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(SK_ColorW
HITE, 0xFF, |
| 631 SkAvoidXfermode::kTargetColor_Mode); | 631 SkAvoidXfermode::kTargetColor_Mode)); |
| 632 SkPaint paint; | 632 SkPaint paint; |
| 633 x += SkIntToScalar(20); | 633 x += SkIntToScalar(20); |
| 634 SkRect r = { x, 0, x + SkIntToScalar(360), SkIntToScalar(700) }; | 634 SkRect r = { x, 0, x + SkIntToScalar(360), SkIntToScalar(700) }; |
| 635 paint.setXfermode(&mode); | 635 paint.setXfermode(mode); |
| 636 paint.setColor(SK_ColorGREEN); | 636 paint.setColor(SK_ColorGREEN); |
| 637 paint.setAntiAlias(true); | 637 paint.setAntiAlias(true); |
| 638 canvas->drawOval(r, paint); | 638 canvas->drawOval(r, paint); |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 | 641 |
| 642 private: | 642 private: |
| 643 SkPoint fClickPt; | 643 SkPoint fClickPt; |
| 644 SkBitmap fBug, fTb, fTx; | 644 SkBitmap fBug, fTb, fTx; |
| 645 typedef SampleView INHERITED; | 645 typedef SampleView INHERITED; |
| 646 }; | 646 }; |
| 647 | 647 |
| 648 ////////////////////////////////////////////////////////////////////////////// | 648 ////////////////////////////////////////////////////////////////////////////// |
| 649 | 649 |
| 650 static SkView* MyFactory() { return new DemoView; } | 650 static SkView* MyFactory() { return new DemoView; } |
| 651 static SkViewRegister reg(MyFactory); | 651 static SkViewRegister reg(MyFactory); |
| OLD | NEW |