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

Side by Side Diff: gm/aarectmodes.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 | « no previous file | gm/bigmatrix.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 SkScalar offset = SK_Scalar1 / 3; 101 SkScalar offset = SK_Scalar1 / 3;
102 SkRect rect = SkRect::MakeXYWH(W / 4 + offset, 102 SkRect rect = SkRect::MakeXYWH(W / 4 + offset,
103 H / 4 + offset, 103 H / 4 + offset,
104 W / 2, H / 2); 104 W / 2, H / 2);
105 canvas->drawRect(rect, paint); 105 canvas->drawRect(rect, paint);
106 106
107 return H; 107 return H;
108 } 108 }
109 109
110 static SkShader* make_bg_shader() { 110 static sk_sp<SkShader> make_bg_shader() {
111 SkBitmap bm; 111 SkBitmap bm;
112 bm.allocN32Pixels(2, 2); 112 bm.allocN32Pixels(2, 2);
113 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF; 113 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
114 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE, 114 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE,
115 0xCF, 0xCE); 115 0xCF, 0xCE);
116 116
117 const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(6), SkIntToScalar(6)); 117 const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(6), SkIntToScalar(6));
118 SkShader* s = SkShader::CreateBitmapShader(bm, 118 return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader:: kRepeat_TileMode,
119 SkShader::kRepeat_TileMode, 119 &m);
120 SkShader::kRepeat_TileMode,
121 &m);
122
123 return s;
124 } 120 }
125 121
126 namespace skiagm { 122 namespace skiagm {
127 123
128 class AARectModesGM : public GM { 124 class AARectModesGM : public GM {
129 SkPaint fBGPaint; 125 SkPaint fBGPaint;
130 public: 126 public:
131 AARectModesGM () { 127 AARectModesGM () {
132 fBGPaint.setShader(make_bg_shader())->unref(); 128 fBGPaint.setShader(make_bg_shader());
133 } 129 }
134 130
135 protected: 131 protected:
136 132
137 SkString onShortName() override { 133 SkString onShortName() override {
138 return SkString("aarectmodes"); 134 return SkString("aarectmodes");
139 } 135 }
140 136
141 SkISize onISize() override { return SkISize::Make(640, 480); } 137 SkISize onISize() override { return SkISize::Make(640, 480); }
142 138
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 private: 175 private:
180 typedef GM INHERITED; 176 typedef GM INHERITED;
181 }; 177 };
182 178
183 ////////////////////////////////////////////////////////////////////////////// 179 //////////////////////////////////////////////////////////////////////////////
184 180
185 static GM* MyFactory(void*) { return new AARectModesGM; } 181 static GM* MyFactory(void*) { return new AARectModesGM; }
186 static GMRegistry reg(MyFactory); 182 static GMRegistry reg(MyFactory);
187 183
188 } 184 }
OLDNEW
« no previous file with comments | « no previous file | gm/bigmatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698