| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkImage.h" | 10 #include "SkImage.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 //-------------- | 83 //-------------- |
| 84 SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlph
aType); | 84 SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlph
aType); |
| 85 | 85 |
| 86 SkAutoTUnref<SkSpecialSurface> surf(img->newSurface(info)); | 86 SkAutoTUnref<SkSpecialSurface> surf(img->newSurface(info)); |
| 87 | 87 |
| 88 SkCanvas* canvas = surf->getCanvas(); | 88 SkCanvas* canvas = surf->getCanvas(); |
| 89 | 89 |
| 90 canvas->clear(SK_ColorBLUE); | 90 canvas->clear(SK_ColorBLUE); |
| 91 img->draw(canvas, kPad, kPad, nullptr); | 91 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); |
| 92 | 92 |
| 93 SkBitmap bm; | 93 SkBitmap bm; |
| 94 bm.allocN32Pixels(kFullSize, kFullSize, true); | 94 bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 95 | 95 |
| 96 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); | 96 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); |
| 97 SkASSERT_RELEASE(result); | 97 SkASSERT_RELEASE(result); |
| 98 | 98 |
| 99 // Only the center (red) portion should've been drawn into the canvas | 99 // Only the center (red) portion should've been drawn into the canvas |
| 100 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); | 100 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); |
| 101 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); | 101 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 144 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
| 145 | 145 |
| 146 SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromGpu(subset, texture)
); | 146 SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromGpu(subset, texture)
); |
| 147 test_image(img, reporter, false, true); | 147 test_image(img, reporter, false, true); |
| 148 } | 148 } |
| 149 | 149 |
| 150 #endif | 150 #endif |
| OLD | NEW |