| 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 "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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |