OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, ful
lImage)); | 170 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, ful
lImage)); |
171 test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize); | 171 test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize); |
172 } | 172 } |
173 | 173 |
174 { | 174 { |
175 sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); | 175 sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); |
176 test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize); | 176 test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 DEF_TEST(SpecialImage_Pixmap, reporter) { | |
181 SkAutoPixmapStorage pixmap; | |
182 | |
183 const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_
SkAlphaType); | |
184 pixmap.alloc(info); | |
185 pixmap.erase(SK_ColorGREEN); | |
186 | |
187 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | |
188 | |
189 pixmap.erase(SK_ColorRED, subset); | |
190 | |
191 { | |
192 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(subset, pixmap, | |
193 nullptr, nullpt
r)); | |
194 test_image(img, reporter, nullptr, false, kPad, kFullSize); | |
195 } | |
196 } | |
197 | |
198 | |
199 #if SK_SUPPORT_GPU | 180 #if SK_SUPPORT_GPU |
200 | 181 |
201 static void test_texture_backed(skiatest::Reporter* reporter, | 182 static void test_texture_backed(skiatest::Reporter* reporter, |
202 const sk_sp<SkSpecialImage>& orig, | 183 const sk_sp<SkSpecialImage>& orig, |
203 const sk_sp<SkSpecialImage>& gpuBacked) { | 184 const sk_sp<SkSpecialImage>& gpuBacked) { |
204 REPORTER_ASSERT(reporter, gpuBacked); | 185 REPORTER_ASSERT(reporter, gpuBacked); |
205 REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); | 186 REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); |
206 REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); | 187 REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); |
207 REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().widt
h() && | 188 REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().widt
h() && |
208 gpuBacked->subset().height() == orig->subset().hei
ght()); | 189 gpuBacked->subset().height() == orig->subset().hei
ght()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
304 } | 285 } |
305 | 286 |
306 { | 287 { |
307 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
308 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
309 } | 290 } |
310 } | 291 } |
311 | 292 |
312 #endif | 293 #endif |
OLD | NEW |