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

Side by Side Diff: tests/DrawBitmapRectTest.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: new convention: require SkImageInfo in constructor Created 7 years 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 // this will deliberately return false if they are asking us to decode 29 // this will deliberately return false if they are asking us to decode
30 // into pixels. 30 // into pixels.
31 return NULL == target; 31 return NULL == target;
32 } 32 }
33 33
34 // crbug.com/295895 34 // crbug.com/295895
35 // Crashing in skia when a pixelref fails in lockPixels 35 // Crashing in skia when a pixelref fails in lockPixels
36 // 36 //
37 static void test_faulty_pixelref(skiatest::Reporter* reporter) { 37 static void test_faulty_pixelref(skiatest::Reporter* reporter) {
38 SkImageInfo info;
39 info.fWidth = 100;
40 info.fHeight = 100;
41 info.fColorType = kPMColor_SkColorType;
42 info.fAlphaType = kPremul_SkAlphaType;
43
38 // need a cache, but don't expect to use it, so the budget is not critical 44 // need a cache, but don't expect to use it, so the budget is not critical
39 SkLruImageCache cache(10 * 1000); 45 SkLruImageCache cache(10 * 1000);
40 // construct a garbage data represent "bad" encoded data. 46 // construct a garbage data represent "bad" encoded data.
41 SkAutoDataUnref data(SkData::NewFromMalloc(malloc(1000), 1000)); 47 SkAutoDataUnref data(SkData::NewFromMalloc(malloc(1000), 1000));
42 SkAutoTUnref<SkPixelRef> pr(new SkLazyPixelRef(data, FailureDecoder, &cache) ); 48 SkAutoTUnref<SkPixelRef> pr(new SkLazyPixelRef(info, data, FailureDecoder, & cache));
43 49
44 SkBitmap bm; 50 SkBitmap bm;
45 bm.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); 51 bm.setConfig(info);
46 bm.setPixelRef(pr); 52 bm.setPixelRef(pr);
47 // now our bitmap has a pixelref, but we know it will fail to lock 53 // now our bitmap has a pixelref, but we know it will fail to lock
48 54
49 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200)); 55 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(200, 200));
50 SkCanvas* canvas = surface->getCanvas(); 56 SkCanvas* canvas = surface->getCanvas();
51 57
52 const SkPaint::FilterLevel levels[] = { 58 const SkPaint::FilterLevel levels[] = {
53 SkPaint::kNone_FilterLevel, 59 SkPaint::kNone_FilterLevel,
54 SkPaint::kLow_FilterLevel, 60 SkPaint::kLow_FilterLevel,
55 SkPaint::kMedium_FilterLevel, 61 SkPaint::kMedium_FilterLevel,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 326
321 test_nan_antihair(); 327 test_nan_antihair();
322 test_giantrepeat_crbug118018(reporter); 328 test_giantrepeat_crbug118018(reporter);
323 329
324 test_treatAsSprite(reporter); 330 test_treatAsSprite(reporter);
325 test_faulty_pixelref(reporter); 331 test_faulty_pixelref(reporter);
326 } 332 }
327 333
328 #include "TestClassDef.h" 334 #include "TestClassDef.h"
329 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) 335 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698