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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: whitespace Created 7 years, 1 month 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/ports/SkDiscardableMemory_none.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 "SkData.h" 10 #include "SkData.h"
11 #include "SkDecodingImageGenerator.h"
11 #include "SkForceLinking.h" 12 #include "SkForceLinking.h"
12 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
13 #include "SkImagePriv.h" 14 #include "SkImagePriv.h"
14 #include "SkLazyCachingPixelRef.h" 15 #include "SkLazyCachingPixelRef.h"
15 #include "SkLazyPixelRef.h" 16 #include "SkLazyPixelRef.h"
16 #include "SkScaledImageCache.h" 17 #include "SkScaledImageCache.h"
17 #include "SkStream.h" 18 #include "SkStream.h"
18 19
19 #include "Test.h" 20 #include "Test.h"
20 #include "TestClassDef.h" 21 #include "TestClassDef.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 DEF_TEST(CachingPixelRef, reporter) { 238 DEF_TEST(CachingPixelRef, reporter) {
238 SkBitmap lazy; 239 SkBitmap lazy;
239 // test the error handling 240 // test the error handling
240 REPORTER_ASSERT(reporter, !TestPixelRef::Install(&lazy, 0)); 241 REPORTER_ASSERT(reporter, !TestPixelRef::Install(&lazy, 0));
241 // onDecodeInfo should succeed, allowing installation 242 // onDecodeInfo should succeed, allowing installation
242 REPORTER_ASSERT(reporter, TestPixelRef::Install(&lazy, 1)); 243 REPORTER_ASSERT(reporter, TestPixelRef::Install(&lazy, 1));
243 SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. 244 SkAutoLockPixels autoLockPixels(lazy); // now pixels are good.
244 // onDecodePixels should fail, so getting pixels will fail. 245 // onDecodePixels should fail, so getting pixels will fail.
245 REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); 246 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
246 } 247 }
248
249 static void compare_with_SkDecodingImageGenerator(skiatest::Reporter* reporter,
250 SkData* encoded,
251 const SkBitmap& original,
252 bool comparePixels) {
253
254 SkBitmap lazy;
255 bool success = SkDecodingImageGenerator::Install(encoded, &lazy);
256 REPORTER_ASSERT(reporter, success);
257 if (!success) {
258 return;
259 }
260
261 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
262 {
263 SkAutoLockPixels autoLockPixels(lazy); // now pixels are good.
264 REPORTER_ASSERT(reporter, NULL != lazy.getPixels());
265 if (NULL == lazy.getPixels()) {
266 return;
267 }
268 }
269 // pixels should be gone!
270 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
271 {
272 SkAutoLockPixels autoLockPixels(lazy); // now pixels are good.
273 REPORTER_ASSERT(reporter, NULL != lazy.getPixels());
274 }
275 compare_bitmaps(reporter, original, lazy, comparePixels);
276 }
277 DEF_TEST(DecodingImageGenerator, reporter) {
278 test_three_encodings(reporter, compare_with_SkDecodingImageGenerator);
279 }
OLDNEW
« no previous file with comments | « src/ports/SkDiscardableMemory_none.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698