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

Side by Side Diff: tests/BitmapCopyTest.cpp

Issue 377303002: add readPixels() to SkBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
« src/core/SkConfig8888.cpp ('K') | « src/core/SkConfig8888.cpp ('k') | no next file » | 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkRect.h" 9 #include "SkRect.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 // Writes unique pixel values at locations specified by coords. 179 // Writes unique pixel values at locations specified by coords.
180 static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) { 180 static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) {
181 for (int i = 0; i < coords.length; ++i) 181 for (int i = 0; i < coords.length; ++i)
182 setPixel(coords[i]->fX, coords[i]->fY, i, bm); 182 setPixel(coords[i]->fX, coords[i]->fY, i, bm);
183 } 183 }
184 184
185 static const Pair gPairs[] = { 185 static const Pair gPairs[] = {
186 { kUnknown_SkColorType, "000000" }, 186 { kUnknown_SkColorType, "000000" },
187 { kAlpha_8_SkColorType, "010101" }, 187 { kAlpha_8_SkColorType, "010101" },
188 { kIndex_8_SkColorType, "011101" }, 188 { kIndex_8_SkColorType, "011111" },
189 { kRGB_565_SkColorType, "010101" }, 189 { kRGB_565_SkColorType, "010101" },
190 { kARGB_4444_SkColorType, "010111" }, 190 { kARGB_4444_SkColorType, "010111" },
191 { kN32_SkColorType, "010111" }, 191 { kN32_SkColorType, "010111" },
192 }; 192 };
193 193
194 static const int W = 20; 194 static const int W = 20;
195 static const int H = 33; 195 static const int H = 33;
196 196
197 static void setup_src_bitmaps(SkBitmap* srcOpaque, SkBitmap* srcPremul, 197 static void setup_src_bitmaps(SkBitmap* srcOpaque, SkBitmap* srcPremul,
198 SkColorType ct) { 198 SkColorType ct) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 bitmap = srcPremul; 263 bitmap = srcPremul;
264 bitmap.setIsVolatile(false); 264 bitmap.setIsVolatile(false);
265 if (bitmap.extractSubset(&subset, r)) { 265 if (bitmap.extractSubset(&subset, r)) {
266 REPORTER_ASSERT(reporter, subset.alphaType() == bitmap.alphaType()); 266 REPORTER_ASSERT(reporter, subset.alphaType() == bitmap.alphaType());
267 REPORTER_ASSERT(reporter, subset.isVolatile() == false); 267 REPORTER_ASSERT(reporter, subset.isVolatile() == false);
268 } 268 }
269 } 269 }
270 } 270 }
271 271
272 DEF_TEST(BitmapCopy, reporter) { 272 DEF_TEST(BitmapCopy, reporter) {
scroggo 2014/07/10 15:09:48 Should we add tests that check for copying a subse
reed1 2014/07/10 15:32:16 Done.
273 static const bool isExtracted[] = { 273 static const bool isExtracted[] = {
274 false, true 274 false, true
275 }; 275 };
276 276
277 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) { 277 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
278 SkBitmap srcOpaque, srcPremul; 278 SkBitmap srcOpaque, srcPremul;
279 setup_src_bitmaps(&srcOpaque, &srcPremul, gPairs[i].fColorType); 279 setup_src_bitmaps(&srcOpaque, &srcPremul, gPairs[i].fColorType);
280 280
281 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) { 281 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) {
282 SkBitmap dst; 282 SkBitmap dst;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // for the transfer. 535 // for the transfer.
536 REPORTER_ASSERT(reporter, 536 REPORTER_ASSERT(reporter,
537 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) == 537 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) ==
538 false); 538 false);
539 539
540 #endif 540 #endif
541 } 541 }
542 } // for (size_t copyCase ... 542 } // for (size_t copyCase ...
543 } 543 }
544 } 544 }
OLDNEW
« src/core/SkConfig8888.cpp ('K') | « src/core/SkConfig8888.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698