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

Side by Side Diff: tests/ImageDecodingTest.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/ImageCacheTest.cpp ('k') | tests/ImageFilterTest.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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } else { 161 } else {
162 SkDebugf("Failed to find any files :(\n"); 162 SkDebugf("Failed to find any files :(\n");
163 } 163 }
164 } 164 }
165 165
166 #ifdef SK_DEBUG 166 #ifdef SK_DEBUG
167 // Create a stream containing a bitmap encoded to Type type. 167 // Create a stream containing a bitmap encoded to Type type.
168 static SkMemoryStream* create_image_stream(SkImageEncoder::Type type) { 168 static SkMemoryStream* create_image_stream(SkImageEncoder::Type type) {
169 SkBitmap bm; 169 SkBitmap bm;
170 const int size = 50; 170 const int size = 50;
171 bm.setConfig(SkBitmap::kARGB_8888_Config, size, size); 171 bm.allocN32Pixels(size, size);
172 bm.allocPixels();
173 SkCanvas canvas(bm); 172 SkCanvas canvas(bm);
174 SkPoint points[2] = { 173 SkPoint points[2] = {
175 { SkIntToScalar(0), SkIntToScalar(0) }, 174 { SkIntToScalar(0), SkIntToScalar(0) },
176 { SkIntToScalar(size), SkIntToScalar(size) } 175 { SkIntToScalar(size), SkIntToScalar(size) }
177 }; 176 };
178 SkColor colors[2] = { SK_ColorWHITE, SK_ColorBLUE }; 177 SkColor colors[2] = { SK_ColorWHITE, SK_ColorBLUE };
179 SkShader* shader = SkGradientShader::CreateLinear(points, colors, NULL, 178 SkShader* shader = SkGradientShader::CreateLinear(points, colors, NULL,
180 SK_ARRAY_COUNT(colors), 179 SK_ARRAY_COUNT(colors),
181 SkShader::kClamp_TileMode) ; 180 SkShader::kClamp_TileMode) ;
182 SkPaint paint; 181 SkPaint paint;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 * SkInstallDiscardablePixelRef functions. 355 * SkInstallDiscardablePixelRef functions.
357 */ 356 */
358 DEF_TEST(ImprovedBitmapFactory, reporter) { 357 DEF_TEST(ImprovedBitmapFactory, reporter) {
359 SkString resourcePath = skiatest::Test::GetResourcePath(); 358 SkString resourcePath = skiatest::Test::GetResourcePath();
360 SkString directory = SkOSPath::SkPathJoin(resourcePath.c_str(), "encoding"); 359 SkString directory = SkOSPath::SkPathJoin(resourcePath.c_str(), "encoding");
361 SkString path = SkOSPath::SkPathJoin(directory.c_str(), "randPixels.png"); 360 SkString path = SkOSPath::SkPathJoin(directory.c_str(), "randPixels.png");
362 SkAutoTUnref<SkStreamRewindable> stream( 361 SkAutoTUnref<SkStreamRewindable> stream(
363 SkStream::NewFromFile(path.c_str())); 362 SkStream::NewFromFile(path.c_str()));
364 if (sk_exists(path.c_str())) { 363 if (sk_exists(path.c_str())) {
365 SkBitmap bm; 364 SkBitmap bm;
366 SkAssertResult(bm.setConfig(SkBitmap::kARGB_8888_Config, 1, 1)); 365 SkAssertResult(bm.setConfig(SkImageInfo::MakeN32Premul(1, 1)));
367 REPORTER_ASSERT(reporter, 366 REPORTER_ASSERT(reporter,
368 NULL != install_pixel_ref(&bm, stream.detach(), 1, true)); 367 NULL != install_pixel_ref(&bm, stream.detach(), 1, true));
369 SkAutoLockPixels alp(bm); 368 SkAutoLockPixels alp(bm);
370 REPORTER_ASSERT(reporter, NULL != bm.getPixels()); 369 REPORTER_ASSERT(reporter, NULL != bm.getPixels());
371 } 370 }
372 } 371 }
373 372
374 373
375 //////////////////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////////////////
376 375
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 568 }
570 SkDecodingImageGenerator::Options options(scaleList[i], 569 SkDecodingImageGenerator::Options options(scaleList[i],
571 ditherList[j]); 570 ditherList[j]);
572 test_options(reporter, options, encodedStream, encodedData, 571 test_options(reporter, options, encodedStream, encodedData,
573 useDataList[m], path); 572 useDataList[m], path);
574 } 573 }
575 } 574 }
576 } 575 }
577 } 576 }
578 } 577 }
OLDNEW
« no previous file with comments | « tests/ImageCacheTest.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698