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

Side by Side Diff: tests/MipMapTest.cpp

Issue 162643002: replace setConfig+allocPixels with single call (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | tests/PDFPrimitivesTest.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 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkMipMap.h" 9 #include "SkMipMap.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 static void make_bitmap(SkBitmap* bm, SkRandom& rand) { 13 static void make_bitmap(SkBitmap* bm, SkRandom& rand) {
14 // for now, Build needs a min size of 2, otherwise it will return NULL. 14 // for now, Build needs a min size of 2, otherwise it will return NULL.
15 // should fix that to support 1 X N, where N > 1 to return non-null. 15 // should fix that to support 1 X N, where N > 1 to return non-null.
16 int w = 2 + rand.nextU() % 1000; 16 int w = 2 + rand.nextU() % 1000;
17 int h = 2 + rand.nextU() % 1000; 17 int h = 2 + rand.nextU() % 1000;
18 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h); 18 bm->allocN32Pixels(w, h);
19 bm->allocPixels();
20 bm->eraseColor(SK_ColorWHITE); 19 bm->eraseColor(SK_ColorWHITE);
21 } 20 }
22 21
23 DEF_TEST(MipMap, reporter) { 22 DEF_TEST(MipMap, reporter) {
24 SkBitmap bm; 23 SkBitmap bm;
25 SkRandom rand; 24 SkRandom rand;
26 25
27 for (int i = 0; i < 500; ++i) { 26 for (int i = 0; i < 500; ++i) {
28 make_bitmap(&bm, rand); 27 make_bitmap(&bm, rand);
29 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm)); 28 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm));
(...skipping 17 matching lines...) Expand all
47 46
48 if (prevLevel.fPixels) { 47 if (prevLevel.fPixels) {
49 REPORTER_ASSERT(reporter, level.fWidth <= prevLevel.fWidth); 48 REPORTER_ASSERT(reporter, level.fWidth <= prevLevel.fWidth);
50 REPORTER_ASSERT(reporter, level.fHeight <= prevLevel.fHeight ); 49 REPORTER_ASSERT(reporter, level.fHeight <= prevLevel.fHeight );
51 } 50 }
52 prevLevel = level; 51 prevLevel = level;
53 } 52 }
54 } 53 }
55 } 54 }
56 } 55 }
OLDNEW
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698