| 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 25 matching lines...) Expand all Loading... |
| 36 bm.allocN32Pixels(kFullSize, kFullSize, true); | 36 bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 37 | 37 |
| 38 SkCanvas temp(bm); | 38 SkCanvas temp(bm); |
| 39 | 39 |
| 40 temp.clear(SK_ColorGREEN); | 40 temp.clear(SK_ColorGREEN); |
| 41 SkPaint p; | 41 SkPaint p; |
| 42 p.setColor(SK_ColorRED); | 42 p.setColor(SK_ColorRED); |
| 43 p.setAntiAlias(false); | 43 p.setAntiAlias(false); |
| 44 | 44 |
| 45 temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad), | 45 temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad), |
| 46 SkIntToScalar(kSmallerSize), SkIntToScalar(kS
mallerSize)), | 46 SkIntToScalar(kSmallerSize), SkIntToScalar(kS
mallerSize)), |
| 47 p); | 47 p); |
| 48 | 48 |
| 49 return bm; | 49 return bm; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels &
draw) | 52 // Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels &
draw) |
| 53 static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
orter, | 53 static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
orter, |
| 54 bool peekPixelsSucceeds, bool peekTextureSucceeds, | 54 bool peekPixelsSucceeds, bool peekTextureSucceeds, |
| 55 int offset, int size) { | 55 int offset, int size) { |
| 56 const SkIRect subset = TestingSpecialImageAccess::Subset(img.get()); | 56 const SkIRect subset = TestingSpecialImageAccess::Subset(img.get()); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( | 285 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
| 286 nullptr, | 286 nullptr, |
| 287 SkIRect::MakeWH(kFul
lSize, kFullSize), | 287 SkIRect::MakeWH(kFul
lSize, kFullSize), |
| 288 kNeedNewImageUniqueI
D_SpecialImage, | 288 kNeedNewImageUniqueI
D_SpecialImage, |
| 289 texture)); | 289 texture)); |
| 290 | 290 |
| 291 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 291 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
| 292 | 292 |
| 293 { | 293 { |
| 294 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( | 294 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
| 295 nullptr, subset, | 295 nullptr, subset, |
| 296 kNeedNewImageUniq
ueID_SpecialImage, | 296 kNeedNewImageUniq
ueID_SpecialImage, |
| 297 texture)); | 297 texture)); |
| 298 test_image(subSImg1, reporter, false, true, kPad, kFullSize); | 298 test_image(subSImg1, reporter, false, true, kPad, kFullSize); |
| 299 } | 299 } |
| 300 | 300 |
| 301 { | 301 { |
| 302 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 302 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
| 303 test_image(subSImg2, reporter, false, true, kPad, kFullSize); | 303 test_image(subSImg2, reporter, false, true, kPad, kFullSize); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 #endif | 307 #endif |
| OLD | NEW |