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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. Created 7 years, 2 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 | « src/utils/win/SkIStream.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 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 //SkDebugf("about to decode \"%s\"\n", filename.c_str()); 187 //SkDebugf("about to decode \"%s\"\n", filename.c_str());
188 compare_unpremul(reporter, filename); 188 compare_unpremul(reporter, filename);
189 } while (iter.next(&basename)); 189 } while (iter.next(&basename));
190 } else { 190 } else {
191 SkDebugf("Failed to find any files :(\n"); 191 SkDebugf("Failed to find any files :(\n");
192 } 192 }
193 } 193 }
194 194
195 #ifdef SK_DEBUG 195 #ifdef SK_DEBUG
196 // Create a stream containing a bitmap encoded to Type type. 196 // Create a stream containing a bitmap encoded to Type type.
197 static SkStream* create_image_stream(SkImageEncoder::Type type) { 197 static SkMemoryStream* create_image_stream(SkImageEncoder::Type type) {
198 SkBitmap bm; 198 SkBitmap bm;
199 const int size = 50; 199 const int size = 50;
200 bm.setConfig(SkBitmap::kARGB_8888_Config, size, size); 200 bm.setConfig(SkBitmap::kARGB_8888_Config, size, size);
201 bm.allocPixels(); 201 bm.allocPixels();
202 SkCanvas canvas(bm); 202 SkCanvas canvas(bm);
203 SkPoint points[2] = { 203 SkPoint points[2] = {
204 { SkIntToScalar(0), SkIntToScalar(0) }, 204 { SkIntToScalar(0), SkIntToScalar(0) },
205 { SkIntToScalar(size), SkIntToScalar(size) } 205 { SkIntToScalar(size), SkIntToScalar(size) }
206 }; 206 };
207 SkColor colors[2] = { SK_ColorWHITE, SK_ColorBLUE }; 207 SkColor colors[2] = { SK_ColorWHITE, SK_ColorBLUE };
(...skipping 18 matching lines...) Expand all
226 static void test_stream_life() { 226 static void test_stream_life() {
227 const SkImageEncoder::Type gTypes[] = { 227 const SkImageEncoder::Type gTypes[] = {
228 #ifdef SK_BUILD_FOR_ANDROID 228 #ifdef SK_BUILD_FOR_ANDROID
229 SkImageEncoder::kJPEG_Type, 229 SkImageEncoder::kJPEG_Type,
230 SkImageEncoder::kPNG_Type, 230 SkImageEncoder::kPNG_Type,
231 #endif 231 #endif
232 SkImageEncoder::kWEBP_Type, 232 SkImageEncoder::kWEBP_Type,
233 }; 233 };
234 for (size_t i = 0; i < SK_ARRAY_COUNT(gTypes); ++i) { 234 for (size_t i = 0; i < SK_ARRAY_COUNT(gTypes); ++i) {
235 //SkDebugf("encoding to %i\n", i); 235 //SkDebugf("encoding to %i\n", i);
236 SkAutoTUnref<SkStream> stream(create_image_stream(gTypes[i])); 236 SkAutoTUnref<SkMemoryStream> stream(create_image_stream(gTypes[i]));
237 if (NULL == stream.get()) { 237 if (NULL == stream.get()) {
238 SkDebugf("no stream\n"); 238 SkDebugf("no stream\n");
239 continue; 239 continue;
240 } 240 }
241 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); 241 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream));
242 if (NULL == decoder.get()) { 242 if (NULL == decoder.get()) {
243 SkDebugf("no decoder\n"); 243 SkDebugf("no decoder\n");
244 continue; 244 continue;
245 } 245 }
246 int width, height; 246 int width, height;
(...skipping 14 matching lines...) Expand all
261 test_unpremul(reporter); 261 test_unpremul(reporter);
262 test_pref_config_table(reporter); 262 test_pref_config_table(reporter);
263 #ifdef SK_DEBUG 263 #ifdef SK_DEBUG
264 test_stream_life(); 264 test_stream_life();
265 #endif 265 #endif
266 } 266 }
267 267
268 #include "TestClassDef.h" 268 #include "TestClassDef.h"
269 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass, 269 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass,
270 test_imageDecodingTests) 270 test_imageDecodingTests)
OLDNEW
« no previous file with comments | « src/utils/win/SkIStream.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698