OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 scanline[width-1] = kBlue; | 136 scanline[width-1] = kBlue; |
137 | 137 |
138 scanline = result->getAddr32(0, height-1); | 138 scanline = result->getAddr32(0, height-1); |
139 for (int x = 0; x < width; ++x) { | 139 for (int x = 0; x < width; ++x) { |
140 scanline[x] = kBlue; | 140 scanline[x] = kBlue; |
141 } | 141 } |
142 result->setImmutable(); | 142 result->setImmutable(); |
143 } | 143 } |
144 | 144 |
145 /** Makes a alpha bitmap with 1 wide rect/ring of 1s, an inset of 0s, and the in
terior is a 2x2 | 145 /** Makes a alpha bitmap with 1 wide rect/ring of 0s, an inset of 1s, and the in
terior is a 2x2 |
146 checker board of 3/4 and 1/2. The inner checkers are large enough to fill th
e interior with | 146 checker board of 3/4 and 1/2. The inner checkers are large enough to fill th
e interior with |
147 the 2x2 checker grid. */ | 147 the 2x2 checker grid. */ |
148 static void make_ringed_alpha_bitmap(SkBitmap* result, int width, int height) { | 148 static void make_ringed_alpha_bitmap(SkBitmap* result, int width, int height) { |
149 SkASSERT(0 == width % 2 && 0 == height % 2); | 149 SkASSERT(0 == width % 2 && 0 == height % 2); |
150 | 150 |
151 static const SkPMColor kZero = 0x00; | 151 static const SkPMColor kZero = 0x00; |
152 static const SkPMColor kHalf = 0x80; | 152 static const SkPMColor kHalf = 0x80; |
153 static const SkPMColor k3Q = 0xC0; | 153 static const SkPMColor k3Q = 0xC0; |
154 static const SkPMColor kOne = 0xFF; | 154 static const SkPMColor kOne = 0xFF; |
155 SkImageInfo info = SkImageInfo::MakeA8(width, height); | 155 SkImageInfo info = SkImageInfo::MakeA8(width, height); |
156 // The 4 byte alignment seems to be necessary to allow this bmp to be conver
ted | 156 // The 4 byte alignment seems to be necessary to allow this bmp to be conver
ted |
157 // to an image. | 157 // to an image. |
158 result->allocPixels(info, SkAlign4(width)); | 158 result->allocPixels(info, SkAlign4(width)); |
159 | 159 |
160 uint8_t* scanline = result->getAddr8(0, 0); | 160 uint8_t* scanline = result->getAddr8(0, 0); |
161 for (int x = 0; x < width; ++x) { | 161 for (int x = 0; x < width; ++x) { |
162 scanline[x] = kOne; | 162 scanline[x] = kOne; |
163 } | 163 } |
164 scanline = result->getAddr8(0, 1); | 164 scanline = result->getAddr8(0, 1); |
165 scanline[0] = kOne; | 165 scanline[0] = kOne; |
166 for (int x = 1; x < width - 1; ++x) { | 166 for (int x = 1; x < width - 1; ++x) { |
167 scanline[x] = kZero; | 167 scanline[x] = kOne; |
168 } | 168 } |
169 scanline[width - 1] = kOne; | 169 scanline[width - 1] = kZero; |
170 | 170 |
171 for (int y = 2; y < height / 2; ++y) { | 171 for (int y = 2; y < height / 2; ++y) { |
172 scanline = result->getAddr8(0, y); | 172 scanline = result->getAddr8(0, y); |
173 scanline[0] = kOne; | 173 scanline[0] = kZero; |
174 scanline[1] = kZero; | 174 scanline[1] = kOne; |
175 for (int x = 2; x < width / 2; ++x) { | 175 for (int x = 2; x < width / 2; ++x) { |
176 scanline[x] = k3Q; | 176 scanline[x] = k3Q; |
177 } | 177 } |
178 for (int x = width / 2; x < width - 2; ++x) { | 178 for (int x = width / 2; x < width - 2; ++x) { |
179 scanline[x] = kHalf; | 179 scanline[x] = kHalf; |
180 } | 180 } |
181 scanline[width - 2] = kZero; | 181 scanline[width - 2] = kOne; |
182 scanline[width - 1] = kOne; | 182 scanline[width - 1] = kZero; |
183 } | 183 } |
184 | 184 |
185 for (int y = height / 2; y < height - 2; ++y) { | 185 for (int y = height / 2; y < height - 2; ++y) { |
186 scanline = result->getAddr8(0, y); | 186 scanline = result->getAddr8(0, y); |
187 scanline[0] = kOne; | 187 scanline[0] = kZero; |
188 scanline[1] = kZero; | 188 scanline[1] = kOne; |
189 for (int x = 2; x < width / 2; ++x) { | 189 for (int x = 2; x < width / 2; ++x) { |
190 scanline[x] = kHalf; | 190 scanline[x] = kHalf; |
191 } | 191 } |
192 for (int x = width / 2; x < width - 2; ++x) { | 192 for (int x = width / 2; x < width - 2; ++x) { |
193 scanline[x] = k3Q; | 193 scanline[x] = k3Q; |
194 } | 194 } |
195 scanline[width - 2] = kZero; | 195 scanline[width - 2] = kOne; |
196 scanline[width - 1] = kOne; | 196 scanline[width - 1] = kZero; |
197 } | 197 } |
198 | 198 |
199 scanline = result->getAddr8(0, height - 2); | 199 scanline = result->getAddr8(0, height - 2); |
200 scanline[0] = kOne; | 200 scanline[0] = kZero; |
201 for (int x = 1; x < width - 1; ++x) { | 201 for (int x = 1; x < width - 1; ++x) { |
202 scanline[x] = kZero; | 202 scanline[x] = kOne; |
203 } | 203 } |
204 scanline[width - 1] = kOne; | 204 scanline[width - 1] = kZero; |
205 | 205 |
206 scanline = result->getAddr8(0, height - 1); | 206 scanline = result->getAddr8(0, height - 1); |
207 for (int x = 0; x < width; ++x) { | 207 for (int x = 0; x < width; ++x) { |
208 scanline[x] = kOne; | 208 scanline[x] = kZero; |
209 } | 209 } |
210 result->setImmutable(); | 210 result->setImmutable(); |
211 } | 211 } |
212 | 212 |
213 static SkShader* make_shader() { | 213 static SkShader* make_shader() { |
214 static const SkPoint pts[] = { {0, 0}, {20, 20} }; | 214 static const SkPoint pts[] = { {0, 0}, {20, 20} }; |
215 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; | 215 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; |
216 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kMi
rror_TileMode); | 216 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kMi
rror_TileMode); |
217 } | 217 } |
218 | 218 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 471 |
472 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) | 472 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
473 DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) | 473 DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) |
474 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) | 474 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |
475 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) | 475 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) |
476 DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) | 476 DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) |
477 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) | 477 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) |
478 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) | 478 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) |
479 DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) | 479 DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) |
480 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) | 480 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) |
OLD | NEW |