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 "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 canvas->drawText(text, len, x, y, paint); | 69 canvas->drawText(text, len, x, y, paint); |
70 | 70 |
71 const SkPoint pts[] = { | 71 const SkPoint pts[] = { |
72 { bounds.fLeft, y }, | 72 { bounds.fLeft, y }, |
73 { bounds.fRight, y } | 73 { bounds.fRight, y } |
74 }; | 74 }; |
75 const SkColor colors[] = { SK_ColorBLACK, SK_ColorBLACK, 0 }; | 75 const SkColor colors[] = { SK_ColorBLACK, SK_ColorBLACK, 0 }; |
76 | 76 |
77 // pos[1] value is where we start to fade, relative to the width | 77 // pos[1] value is where we start to fade, relative to the width |
78 // of our pts[] array. | 78 // of our pts[] array. |
79 const SkScalar pos[] = { 0, SkFloatToScalar(0.9f), SK_Scalar1 }; | 79 const SkScalar pos[] = { 0, 0.9f, SK_Scalar1 }; |
80 | 80 |
81 SkShader* s = SkGradientShader::CreateLinear(pts, colors, pos, 3, | 81 SkShader* s = SkGradientShader::CreateLinear(pts, colors, pos, 3, |
82 SkShader::kClamp_TileMode); | 82 SkShader::kClamp_TileMode); |
83 SkPaint p; | 83 SkPaint p; |
84 p.setShader(s)->unref(); | 84 p.setShader(s)->unref(); |
85 p.setXfermodeMode(SkXfermode::kDstIn_Mode); | 85 p.setXfermodeMode(SkXfermode::kDstIn_Mode); |
86 canvas->drawRect(bounds, p); | 86 canvas->drawRect(bounds, p); |
87 | 87 |
88 canvas->restore(); | 88 canvas->restore(); |
89 } | 89 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 private: | 409 private: |
410 SkIRect fBase, fRect; | 410 SkIRect fBase, fRect; |
411 | 411 |
412 typedef SampleView INHERITED; | 412 typedef SampleView INHERITED; |
413 }; | 413 }; |
414 | 414 |
415 ////////////////////////////////////////////////////////////////////////////// | 415 ////////////////////////////////////////////////////////////////////////////// |
416 | 416 |
417 static SkView* MyFactory() { return new RegionView; } | 417 static SkView* MyFactory() { return new RegionView; } |
418 static SkViewRegister reg(MyFactory); | 418 static SkViewRegister reg(MyFactory); |
OLD | NEW |