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

Side by Side Diff: samplecode/SampleTiling.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites 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
OLDNEW
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 17 matching lines...) Expand all
28 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); 28 bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
29 bm->eraseColor(SK_ColorTRANSPARENT); 29 bm->eraseColor(SK_ColorTRANSPARENT);
30 30
31 SkCanvas canvas(*bm); 31 SkCanvas canvas(*bm);
32 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } }; 32 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } };
33 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 33 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
34 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; 34 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
35 SkPaint paint; 35 SkPaint paint;
36 36
37 paint.setDither(true); 37 paint.setDither(true);
38 paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos, 38 paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos,
39 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref(); 39 SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
40 canvas.drawPaint(paint); 40 canvas.drawPaint(paint);
41 } 41 }
42 42
43 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, 43 static void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
44 SkShader::TileMode tmx, SkShader::TileMode tmy) { 44 SkShader::TileMode tmx, SkShader::TileMode tmy) {
45 SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy); 45 paint->setShader(SkShader::MakeBitmapShader(bm, tmx, tmy));
46 paint->setShader(shader)->unref();
47 paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQualit y); 46 paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQualit y);
48 } 47 }
49 48
50 static const SkColorType gColorTypes[] = { 49 static const SkColorType gColorTypes[] = {
51 kN32_SkColorType, 50 kN32_SkColorType,
52 kRGB_565_SkColorType, 51 kRGB_565_SkColorType,
53 }; 52 };
54 static const int gWidth = 32; 53 static const int gWidth = 32;
55 static const int gHeight = 32; 54 static const int gHeight = 32;
56 55
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 161 }
163 162
164 private: 163 private:
165 typedef SampleView INHERITED; 164 typedef SampleView INHERITED;
166 }; 165 };
167 166
168 ////////////////////////////////////////////////////////////////////////////// 167 //////////////////////////////////////////////////////////////////////////////
169 168
170 static SkView* MyFactory() { return new TilingView; } 169 static SkView* MyFactory() { return new TilingView; }
171 static SkViewRegister reg(MyFactory); 170 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698