| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 #if SK_SUPPORT_GPU | 180 #if SK_SUPPORT_GPU |
| 181 | 181 |
| 182 static void test_texture_backed(skiatest::Reporter* reporter, | 182 static void test_texture_backed(skiatest::Reporter* reporter, |
| 183 const sk_sp<SkSpecialImage>& orig, | 183 const sk_sp<SkSpecialImage>& orig, |
| 184 const sk_sp<SkSpecialImage>& gpuBacked) { | 184 const sk_sp<SkSpecialImage>& gpuBacked) { |
| 185 REPORTER_ASSERT(reporter, gpuBacked); | 185 REPORTER_ASSERT(reporter, gpuBacked); |
| 186 REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); | 186 REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); |
| 187 REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); | 187 REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); |
| 188 REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().widt
h() && | 188 REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().widt
h() && |
| 189 gpuBacked->subset().height() == orig->subset().hei
ght()); | 189 gpuBacked->subset().height() == orig->subset().hei
ght()); |
| 190 REPORTER_ASSERT(reporter, gpuBacked->getColorSpace() == orig->getColorSpace(
)); |
| 190 } | 191 } |
| 191 | 192 |
| 192 // Test out the SkSpecialImage::makeTextureImage entry point | 193 // Test out the SkSpecialImage::makeTextureImage entry point |
| 193 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
{ | 194 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
{ |
| 194 GrContext* context = ctxInfo.grContext(); | 195 GrContext* context = ctxInfo.grContext(); |
| 195 SkBitmap bm = create_bm(); | 196 SkBitmap bm = create_bm(); |
| 196 | 197 |
| 197 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 198 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
| 198 | 199 |
| 199 { | 200 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 229 bm.ge
tPixels(), | 230 bm.ge
tPixels(), |
| 230 0)); | 231 0)); |
| 231 if (!texture) { | 232 if (!texture) { |
| 232 return; | 233 return; |
| 233 } | 234 } |
| 234 | 235 |
| 235 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( | 236 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( |
| 236 SkIRect::MakeWH(
kFullSize, | 237 SkIRect::MakeWH(
kFullSize, |
| 237
kFullSize), | 238
kFullSize), |
| 238 kNeedNewImageUni
queID_SpecialImage, | 239 kNeedNewImageUni
queID_SpecialImage, |
| 239 std::move(textur
e))); | 240 std::move(textur
e), nullptr)); |
| 240 | 241 |
| 241 { | 242 { |
| 242 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); | 243 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); |
| 243 test_texture_backed(reporter, gpuImage, fromGPU); | 244 test_texture_backed(reporter, gpuImage, fromGPU); |
| 244 } | 245 } |
| 245 | 246 |
| 246 { | 247 { |
| 247 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); | 248 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); |
| 248 | 249 |
| 249 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte
xt)); | 250 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte
xt)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 265 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, | 266 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
| 266 SkBudgete
d::kNo, | 267 SkBudgete
d::kNo, |
| 267 bm.getPix
els(), 0)); | 268 bm.getPix
els(), 0)); |
| 268 if (!texture) { | 269 if (!texture) { |
| 269 return; | 270 return; |
| 270 } | 271 } |
| 271 | 272 |
| 272 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( | 273 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
| 273 SkIRect::MakeWH(kFul
lSize, kFullSize), | 274 SkIRect::MakeWH(kFul
lSize, kFullSize), |
| 274 kNeedNewImageUniqueI
D_SpecialImage, | 275 kNeedNewImageUniqueI
D_SpecialImage, |
| 275 texture)); | 276 texture, nullptr)); |
| 276 | 277 |
| 277 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 278 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
| 278 | 279 |
| 279 { | 280 { |
| 280 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( | 281 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
| 281 subset, | 282 subset, |
| 282 kNeedNewImageUniq
ueID_SpecialImage, | 283 kNeedNewImageUniq
ueID_SpecialImage, |
| 283 texture)); | 284 texture, nullptr)
); |
| 284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 285 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
| 285 } | 286 } |
| 286 | 287 |
| 287 { | 288 { |
| 288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 289 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
| 289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 290 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
| 290 } | 291 } |
| 291 } | 292 } |
| 292 | 293 |
| 293 #endif | 294 #endif |
| OLD | NEW |