OLD | NEW |
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 "SkDecodingImageGenerator.h" |
12 #include "SkForceLinking.h" | |
13 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
14 #include "SkImagePriv.h" | 13 #include "SkImagePriv.h" |
15 #include "SkLazyPixelRef.h" | 14 #include "SkLazyPixelRef.h" |
16 #include "SkCachingPixelRef.h" | 15 #include "SkCachingPixelRef.h" |
17 #include "SkScaledImageCache.h" | 16 #include "SkScaledImageCache.h" |
18 #include "SkStream.h" | 17 #include "SkStream.h" |
19 | 18 |
20 #include "Test.h" | 19 #include "Test.h" |
21 #include "TestClassDef.h" | 20 #include "TestClassDef.h" |
22 | 21 |
23 __SK_FORCE_IMAGE_DECODER_LINKING; | |
24 | |
25 /** | 22 /** |
26 * Fill this bitmap with some color. | 23 * Fill this bitmap with some color. |
27 */ | 24 */ |
28 static void make_test_image(SkBitmap* bm) { | 25 static void make_test_image(SkBitmap* bm) { |
29 static const int W = 50, H = 50; | 26 static const int W = 50, H = 50; |
30 static const SkBitmap::Config config = SkBitmap::kARGB_8888_Config; | 27 static const SkBitmap::Config config = SkBitmap::kARGB_8888_Config; |
31 bm->setConfig(config, W, H); | 28 bm->setConfig(config, W, H); |
32 bm->allocPixels(); | 29 bm->allocPixels(); |
33 bm->eraseColor(SK_ColorBLACK); | 30 bm->eraseColor(SK_ColorBLACK); |
34 SkCanvas canvas(*bm); | 31 SkCanvas canvas(*bm); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 bool comparePixels = (SkImageEncoder::kPNG_Type == type); | 158 bool comparePixels = (SkImageEncoder::kPNG_Type == type); |
162 compare_bitmaps(reporter, original, lazy, comparePixels); | 159 compare_bitmaps(reporter, original, lazy, comparePixels); |
163 } | 160 } |
164 } | 161 } |
165 | 162 |
166 | 163 |
167 //////////////////////////////////////////////////////////////////////////////// | 164 //////////////////////////////////////////////////////////////////////////////// |
168 /** | 165 /** |
169 * This checks to see that a SkLazyPixelRef works as advertised. | 166 * This checks to see that a SkLazyPixelRef works as advertised. |
170 */ | 167 */ |
171 bool install_skLazyPixelRef(SkData* encoded, SkBitmap* dst) { | 168 static bool install_skLazyPixelRef(SkData* encoded, SkBitmap* dst) { |
172 static const SkBitmapFactory::DecodeProc decoder = | 169 static const SkBitmapFactory::DecodeProc decoder = |
173 &(SkImageDecoder::DecodeMemoryToTarget); | 170 &(SkImageDecoder::DecodeMemoryToTarget); |
174 return simple_bitmap_factory(decoder, encoded, dst); | 171 return simple_bitmap_factory(decoder, encoded, dst); |
175 } | 172 } |
176 DEF_TEST(LazyPixelRef, reporter) { | 173 DEF_TEST(LazyPixelRef, reporter) { |
177 test_three_encodings(reporter, install_skLazyPixelRef); | 174 test_three_encodings(reporter, install_skLazyPixelRef); |
178 } | 175 } |
179 | 176 |
180 //////////////////////////////////////////////////////////////////////////////// | 177 //////////////////////////////////////////////////////////////////////////////// |
181 /** | 178 /** |
182 * This checks to see that a SkCachingPixelRef works as advertised. | 179 * This checks to see that a SkCachingPixelRef works as advertised. |
183 */ | 180 */ |
184 bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { | 181 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { |
185 return SkCachingPixelRef::Install( | 182 return SkCachingPixelRef::Install( |
186 SkNEW_ARGS(SkDecodingImageGenerator, (encoded)), dst); | 183 SkNEW_ARGS(SkDecodingImageGenerator, (encoded)), dst); |
187 } | 184 } |
188 DEF_TEST(CachingPixelRef, reporter) { | 185 DEF_TEST(CachingPixelRef, reporter) { |
189 test_three_encodings(reporter, install_skCachingPixelRef); | 186 test_three_encodings(reporter, install_skCachingPixelRef); |
190 } | 187 } |
191 | 188 |
192 //////////////////////////////////////////////////////////////////////////////// | 189 //////////////////////////////////////////////////////////////////////////////// |
193 /** | 190 /** |
194 * This checks to see that a SkDecodingImageGenerator works as advertised. | 191 * This checks to see that a SkDecodingImageGenerator works as advertised. |
195 */ | 192 */ |
196 DEF_TEST(DecodingImageGenerator, reporter) { | 193 DEF_TEST(DecodingImageGenerator, reporter) { |
197 test_three_encodings(reporter, SkDecodingImageGenerator::Install); | 194 test_three_encodings(reporter, SkDecodingImageGenerator::Install); |
198 } | 195 } |
OLD | NEW |