| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (context) { | 78 if (context) { |
| 79 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width()); | 79 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width()); |
| 80 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height()); | 80 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height()); |
| 81 } else { | 81 } else { |
| 82 REPORTER_ASSERT(reporter, size == bitmap.width()); | 82 REPORTER_ASSERT(reporter, size == bitmap.width()); |
| 83 REPORTER_ASSERT(reporter, size == bitmap.height()); | 83 REPORTER_ASSERT(reporter, size == bitmap.height()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 //-------------- | 86 //-------------- |
| 87 // Test that draw restricts itself to the subset | 87 // Test that draw restricts itself to the subset |
| 88 SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlph
aType); | 88 sk_sp<SkSpecialSurface> surf(img->makeSurface(SkIRect::MakeWH(kFullSize, kFu
llSize), |
| 89 | 89 kOpaque_SkAlphaType)); |
| 90 sk_sp<SkSpecialSurface> surf(img->makeSurface(info)); | |
| 91 | 90 |
| 92 SkCanvas* canvas = surf->getCanvas(); | 91 SkCanvas* canvas = surf->getCanvas(); |
| 93 | 92 |
| 94 canvas->clear(SK_ColorBLUE); | 93 canvas->clear(SK_ColorBLUE); |
| 95 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); | 94 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); |
| 96 | 95 |
| 97 SkBitmap bm; | 96 SkBitmap bm; |
| 98 bm.allocN32Pixels(kFullSize, kFullSize, true); | 97 bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 99 | 98 |
| 100 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); | 99 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
| 286 } | 285 } |
| 287 | 286 |
| 288 { | 287 { |
| 289 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
| 290 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
| 291 } | 290 } |
| 292 } | 291 } |
| 293 | 292 |
| 294 #endif | 293 #endif |
| OLD | NEW |