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

Side by Side Diff: gm/filltypespersp.cpp

Issue 1776973003: partial switch over to sp usage of shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move into lua container Created 4 years, 9 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
« no previous file with comments | « gm/drawminibitmaprect.cpp ('k') | gm/gamma.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 canvas->translate(-r.centerX(), -r.centerY()); 48 canvas->translate(-r.centerX(), -r.centerY());
49 canvas->drawPath(fPath, paint); 49 canvas->drawPath(fPath, paint);
50 canvas->restore(); 50 canvas->restore();
51 } 51 }
52 52
53 void showFour(SkCanvas* canvas, SkScalar scale, bool aa) { 53 void showFour(SkCanvas* canvas, SkScalar scale, bool aa) {
54 SkPaint paint; 54 SkPaint paint;
55 SkPoint center = SkPoint::Make(SkIntToScalar(100), SkIntToScalar(100)); 55 SkPoint center = SkPoint::Make(SkIntToScalar(100), SkIntToScalar(100));
56 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN}; 56 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
57 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1}; 57 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
58 SkShader* s = SkGradientShader::CreateRadial(center, 58 paint.setShader(SkGradientShader::MakeRadial(center,
59 SkIntToScalar(100), 59 SkIntToScalar(100),
60 colors, 60 colors,
61 pos, 61 pos,
62 SK_ARRAY_COUNT(colors), 62 SK_ARRAY_COUNT(colors),
63 SkShader::kClamp_TileMode); 63 SkShader::kClamp_TileMode)) ;
64 paint.setShader(s)->unref();
65 paint.setAntiAlias(aa); 64 paint.setAntiAlias(aa);
66 65
67 showPath(canvas, 0, 0, SkPath::kWinding_FillType, 66 showPath(canvas, 0, 0, SkPath::kWinding_FillType,
68 scale, paint); 67 scale, paint);
69 showPath(canvas, 200, 0, SkPath::kEvenOdd_FillType, 68 showPath(canvas, 200, 0, SkPath::kEvenOdd_FillType,
70 scale, paint); 69 scale, paint);
71 showPath(canvas, 00, 200, SkPath::kInverseWinding_FillType, 70 showPath(canvas, 00, 200, SkPath::kInverseWinding_FillType,
72 scale, paint); 71 scale, paint);
73 showPath(canvas, 200, 200, SkPath::kInverseEvenOdd_FillType, 72 showPath(canvas, 200, 200, SkPath::kInverseEvenOdd_FillType,
74 scale, paint); 73 scale, paint);
75 } 74 }
76 75
77 void onDraw(SkCanvas* canvas) override { 76 void onDraw(SkCanvas* canvas) override {
78 this->makePath(); 77 this->makePath();
79 78
80 // do perspective drawPaint as the background; 79 // do perspective drawPaint as the background;
81 SkPaint bkgnrd; 80 SkPaint bkgnrd;
82 SkPoint center = SkPoint::Make(SkIntToScalar(100), 81 SkPoint center = SkPoint::Make(SkIntToScalar(100),
83 SkIntToScalar(100)); 82 SkIntToScalar(100));
84 SkColor colors[] = {SK_ColorBLACK, SK_ColorCYAN, 83 SkColor colors[] = {SK_ColorBLACK, SK_ColorCYAN,
85 SK_ColorYELLOW, SK_ColorWHITE}; 84 SK_ColorYELLOW, SK_ColorWHITE};
86 SkScalar pos[] = {0, SK_ScalarHalf / 2, 85 SkScalar pos[] = {0, SK_ScalarHalf / 2,
87 3 * SK_ScalarHalf / 2, SK_Scalar1}; 86 3 * SK_ScalarHalf / 2, SK_Scalar1};
88 SkShader* s = SkGradientShader::CreateRadial(center, 87 bkgnrd.setShader(SkGradientShader::MakeRadial(center,
89 SkIntToScalar(1000), 88 SkIntToScalar(1000),
90 colors, 89 colors,
91 pos, 90 pos,
92 SK_ARRAY_COUNT(colors), 91 SK_ARRAY_COUNT(colors),
93 SkShader::kClamp_TileMode); 92 SkShader::kClamp_TileMode) );
94 bkgnrd.setShader(s)->unref();
95 canvas->save(); 93 canvas->save();
96 canvas->translate(SkIntToScalar(100), SkIntToScalar(100)); 94 canvas->translate(SkIntToScalar(100), SkIntToScalar(100));
97 SkMatrix mat; 95 SkMatrix mat;
98 mat.reset(); 96 mat.reset();
99 mat.setPerspY(SK_Scalar1 / 1000); 97 mat.setPerspY(SK_Scalar1 / 1000);
100 canvas->concat(mat); 98 canvas->concat(mat);
101 canvas->drawPaint(bkgnrd); 99 canvas->drawPaint(bkgnrd);
102 canvas->restore(); 100 canvas->restore();
103 101
104 // draw the paths in perspective 102 // draw the paths in perspective
(...skipping 19 matching lines...) Expand all
124 private: 122 private:
125 typedef GM INHERITED; 123 typedef GM INHERITED;
126 }; 124 };
127 125
128 ////////////////////////////////////////////////////////////////////////////// 126 //////////////////////////////////////////////////////////////////////////////
129 127
130 static GM* MyFactory(void*) { return new FillTypePerspGM; } 128 static GM* MyFactory(void*) { return new FillTypePerspGM; }
131 static GMRegistry reg(MyFactory); 129 static GMRegistry reg(MyFactory);
132 130
133 } 131 }
OLDNEW
« no previous file with comments | « gm/drawminibitmaprect.cpp ('k') | gm/gamma.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698