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

Side by Side Diff: tests/SerializationTest.cpp

Issue 120063003: assert in setPixelRef that the pr matches the bitmap's config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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
« src/core/SkBitmap.cpp ('K') | « src/core/SkBitmap.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 "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 validBitmap.setConfig(SkBitmap::kARGB_8888_Config, 256, 256); 301 validBitmap.setConfig(SkBitmap::kARGB_8888_Config, 256, 256);
302 302
303 // Create a bitmap with a really large height 303 // Create a bitmap with a really large height
304 SkBitmap invalidBitmap; 304 SkBitmap invalidBitmap;
305 invalidBitmap.setConfig(SkBitmap::kARGB_8888_Config, 256, 1000000000); 305 invalidBitmap.setConfig(SkBitmap::kARGB_8888_Config, 256, 1000000000);
306 306
307 // The deserialization should succeed, and the rendering shouldn't crash , 307 // The deserialization should succeed, and the rendering shouldn't crash ,
308 // even when the device fails to initialize, due to its size 308 // even when the device fails to initialize, due to its size
309 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter); 309 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter);
310 310
311 // we assert if the pixelref doesn't agree with the config, so skip this
312 // test (at least for now)
313 #if 0
311 // Create a bitmap with a pixel ref too small 314 // Create a bitmap with a pixel ref too small
312 SkImageInfo info; 315 SkImageInfo info;
313 info.fWidth = 256; 316 info.fWidth = 256;
314 info.fHeight = 256; 317 info.fHeight = 256;
315 info.fColorType = kPMColor_SkColorType; 318 info.fColorType = kPMColor_SkColorType;
316 info.fAlphaType = kPremul_SkAlphaType; 319 info.fAlphaType = kPremul_SkAlphaType;
317 320
318 SkBitmap invalidBitmap2; 321 SkBitmap invalidBitmap2;
319 invalidBitmap2.setConfig(info); 322 invalidBitmap2.setConfig(info);
320 323
321 // Hack to force invalid, by making the pixelref smaller than its 324 // Hack to force invalid, by making the pixelref smaller than its
322 // owning bitmap. 325 // owning bitmap.
323 info.fWidth = 32; 326 info.fWidth = 32;
324 info.fHeight = 1; 327 info.fHeight = 1;
325 328
326 invalidBitmap2.setPixelRef(SkMallocPixelRef::NewAllocate( 329 invalidBitmap2.setPixelRef(SkMallocPixelRef::NewAllocate(
327 info, invalidBitmap2.rowBytes(), NULL))->unref(); 330 info, invalidBitmap2.rowBytes(), NULL))->unref();
328 331
329 // The deserialization should detect the pixel ref being too small and f ail 332 // The deserialization should detect the pixel ref being too small and f ail
330 TestBitmapSerialization(validBitmap, invalidBitmap2, false, reporter); 333 TestBitmapSerialization(validBitmap, invalidBitmap2, false, reporter);
334 #endif
331 } 335 }
332 } 336 }
OLDNEW
« src/core/SkBitmap.cpp ('K') | « src/core/SkBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698