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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0 , 0); | 100 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0 , 0); |
101 SkASSERT_RELEASE(result); | 101 SkASSERT_RELEASE(result); |
102 | 102 |
103 // Only the center (red) portion should've been drawn into the canvas | 103 // Only the center (red) portion should've been drawn into the canvas |
104 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); | 104 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); |
105 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); | 105 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); |
106 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1, | 106 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1, |
107 kSmallerSize+kPad-1)); | 107 kSmallerSize+kPad-1)); |
108 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad, | 108 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad, |
109 kSmallerSize+kPad)); | 109 kSmallerSize+kPad)); |
110 | 110 |
robertphillips
2016/07/20 19:44:39
Seems like these is some stuff we need to add here
| |
111 //-------------- | 111 //-------------- |
112 // Test that makeTightSubset & makeTightSurface return appropriately sized o bjects | 112 // Test that makeTightSubset & makeTightSurface return appropriately sized o bjects |
113 // of the correct backing type | 113 // of the correct backing type |
114 SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height()); | 114 SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height()); |
115 { | 115 { |
116 sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); | 116 sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); |
117 | 117 |
118 REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); | 118 REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); |
119 REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); | 119 REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); |
120 REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture( )); | 120 REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture( )); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 bm.ge tPixels(), | 229 bm.ge tPixels(), |
230 0)); | 230 0)); |
231 if (!texture) { | 231 if (!texture) { |
232 return; | 232 return; |
233 } | 233 } |
234 | 234 |
235 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( | 235 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( |
236 SkIRect::MakeWH( kFullSize, | 236 SkIRect::MakeWH( kFullSize, |
237 kFullSize), | 237 kFullSize), |
238 kNeedNewImageUni queID_SpecialImage, | 238 kNeedNewImageUni queID_SpecialImage, |
239 std::move(textur e))); | 239 std::move(textur e), nullptr)); |
240 | 240 |
241 { | 241 { |
242 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); | 242 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); |
243 test_texture_backed(reporter, gpuImage, fromGPU); | 243 test_texture_backed(reporter, gpuImage, fromGPU); |
244 } | 244 } |
245 | 245 |
246 { | 246 { |
247 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); | 247 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); |
248 | 248 |
249 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte xt)); | 249 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte xt)); |
(...skipping 15 matching lines...) Expand all Loading... | |
265 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, | 265 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
266 SkBudgete d::kNo, | 266 SkBudgete d::kNo, |
267 bm.getPix els(), 0)); | 267 bm.getPix els(), 0)); |
268 if (!texture) { | 268 if (!texture) { |
269 return; | 269 return; |
270 } | 270 } |
271 | 271 |
272 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( | 272 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
273 SkIRect::MakeWH(kFul lSize, kFullSize), | 273 SkIRect::MakeWH(kFul lSize, kFullSize), |
274 kNeedNewImageUniqueI D_SpecialImage, | 274 kNeedNewImageUniqueI D_SpecialImage, |
275 texture)); | 275 texture, nullptr)); |
276 | 276 |
277 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size); | 277 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size); |
278 | 278 |
279 { | 279 { |
280 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( | 280 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
281 subset, | 281 subset, |
282 kNeedNewImageUniq ueID_SpecialImage, | 282 kNeedNewImageUniq ueID_SpecialImage, |
283 texture)); | 283 texture, nullptr) ); |
284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
285 } | 285 } |
286 | 286 |
287 { | 287 { |
288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 #endif | 293 #endif |
OLD | NEW |