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

Side by Side Diff: gm/hairmodes.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/gradtext.cpp ('k') | gm/imagefiltersclipped.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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 for (int angle = 0; angle < 24; ++angle) { 51 for (int angle = 0; angle < 24; ++angle) {
52 SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth; 52 SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth;
53 SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight; 53 SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight;
54 paint.setStrokeWidth(SK_Scalar1 * angle * 2 / 24); 54 paint.setStrokeWidth(SK_Scalar1 * angle * 2 / 24);
55 canvas->drawLine(W/2, H/2, W/2 + x, H/2 + y, paint); 55 canvas->drawLine(W/2, H/2, W/2 + x, H/2 + y, paint);
56 } 56 }
57 57
58 return H; 58 return H;
59 } 59 }
60 60
61 static sk_sp<SkShader> make_bg_shader() { 61 static SkShader* make_bg_shader() {
62 SkBitmap bm; 62 SkBitmap bm;
63 bm.allocN32Pixels(2, 2); 63 bm.allocN32Pixels(2, 2);
64 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF; 64 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
65 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE, 0xCF, 0 xCE); 65 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE, 0xCF, 0 xCE);
66 66
67 SkMatrix m; 67 SkMatrix m;
68 m.setScale(SkIntToScalar(6), SkIntToScalar(6)); 68 m.setScale(SkIntToScalar(6), SkIntToScalar(6));
69 return SkShader::MakeBitmapShader(bm, 69 return SkShader::CreateBitmapShader(bm,
70 SkShader::kRepeat_TileMode, SkShader::kRep eat_TileMode, &m); 70 SkShader::kRepeat_TileMode,
71 SkShader::kRepeat_TileMode,
72 &m);
71 } 73 }
72 74
73 namespace skiagm { 75 namespace skiagm {
74 76
75 class HairModesGM : public GM { 77 class HairModesGM : public GM {
76 SkPaint fBGPaint; 78 SkPaint fBGPaint;
77 79
78 protected: 80 protected:
79 SkString onShortName() override { 81 SkString onShortName() override {
80 return SkString("hairmodes"); 82 return SkString("hairmodes");
81 } 83 }
82 84
83 virtual SkISize onISize() override { return SkISize::Make(640, 480); } 85 virtual SkISize onISize() override { return SkISize::Make(640, 480); }
84 86
85 void onOnceBeforeDraw() override { 87 void onOnceBeforeDraw() override {
86 fBGPaint.setShader(make_bg_shader()); 88 fBGPaint.setShader(make_bg_shader())->unref();
87 } 89 }
88 90
89 void onDraw(SkCanvas* canvas) override { 91 void onDraw(SkCanvas* canvas) override {
90 const SkRect bounds = SkRect::MakeWH(W, H); 92 const SkRect bounds = SkRect::MakeWH(W, H);
91 static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 }; 93 static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };
92 94
93 canvas->translate(SkIntToScalar(4), SkIntToScalar(4)); 95 canvas->translate(SkIntToScalar(4), SkIntToScalar(4));
94 96
95 for (int alpha = 0; alpha < 4; ++alpha) { 97 for (int alpha = 0; alpha < 4; ++alpha) {
96 canvas->save(); 98 canvas->save();
(...skipping 25 matching lines...) Expand all
122 private: 124 private:
123 typedef GM INHERITED; 125 typedef GM INHERITED;
124 }; 126 };
125 127
126 //////////////////////////////////////////////////////////////////////////// // 128 //////////////////////////////////////////////////////////////////////////// //
127 129
128 static GM* MyFactory(void*) { return new HairModesGM; } 130 static GM* MyFactory(void*) { return new HairModesGM; }
129 static GMRegistry reg(MyFactory); 131 static GMRegistry reg(MyFactory);
130 132
131 } 133 }
OLDNEW
« no previous file with comments | « gm/gradtext.cpp ('k') | gm/imagefiltersclipped.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698