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

Side by Side Diff: tests/BitmapTest.cpp

Issue 1143173011: use pixmaps for dst in sprites -- NO BITMAPS (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add dox Created 5 years, 6 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
« no previous file with comments | « src/core/SkSpriteBlitter_RGB16.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 "SkMallocPixelRef.h" 9 #include "SkMallocPixelRef.h"
10 #include "Test.h" 10 #include "Test.h"
11 11
12 static void test_peekpixels(skiatest::Reporter* reporter) {
13 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
14
15 SkPixmap pmap;
16 SkBitmap bm;
17
18 // empty should return false
19 REPORTER_ASSERT(reporter, !bm.peekPixels(NULL));
20 REPORTER_ASSERT(reporter, !bm.peekPixels(&pmap));
21
22 // no pixels should return false
23 bm.setInfo(SkImageInfo::MakeN32Premul(10, 10));
24 REPORTER_ASSERT(reporter, !bm.peekPixels(NULL));
25 REPORTER_ASSERT(reporter, !bm.peekPixels(&pmap));
26
27 // real pixels should return true
28 bm.allocPixels(info);
29 REPORTER_ASSERT(reporter, bm.peekPixels(NULL));
30 REPORTER_ASSERT(reporter, bm.peekPixels(&pmap));
31 REPORTER_ASSERT(reporter, pmap.info() == bm.info());
32 REPORTER_ASSERT(reporter, pmap.addr() == bm.getPixels());
33 REPORTER_ASSERT(reporter, pmap.rowBytes() == bm.rowBytes());
34 REPORTER_ASSERT(reporter, pmap.ctable() == bm.getColorTable());
35 }
36
12 // https://code.google.com/p/chromium/issues/detail?id=446164 37 // https://code.google.com/p/chromium/issues/detail?id=446164
13 static void test_bigalloc(skiatest::Reporter* reporter) { 38 static void test_bigalloc(skiatest::Reporter* reporter) {
14 const int width = 0x40000001; 39 const int width = 0x40000001;
15 const int height = 0x00000096; 40 const int height = 0x00000096;
16 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 41 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
17 42
18 SkBitmap bm; 43 SkBitmap bm;
19 REPORTER_ASSERT(reporter, !bm.tryAllocPixels(info)); 44 REPORTER_ASSERT(reporter, !bm.tryAllocPixels(info));
20 45
21 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NUL L); 46 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NUL L);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (setConf) { 113 if (setConf) {
89 bm.allocPixels(); 114 bm.allocPixels();
90 } 115 }
91 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); 116 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
92 } 117 }
93 } 118 }
94 119
95 test_bigwidth(reporter); 120 test_bigwidth(reporter);
96 test_allocpixels(reporter); 121 test_allocpixels(reporter);
97 test_bigalloc(reporter); 122 test_bigalloc(reporter);
123 test_peekpixels(reporter);
98 } 124 }
OLDNEW
« no previous file with comments | « src/core/SkSpriteBlitter_RGB16.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698