| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 canvas.drawIRect(r, p); | 26 canvas.drawIRect(r, p); |
| 27 SkBitmap dstBitmap; | 27 SkBitmap dstBitmap; |
| 28 srcBitmap.extractSubset(&dstBitmap, r); | 28 srcBitmap.extractSubset(&dstBitmap, r); |
| 29 image.reset(SkImage::NewFromBitmap(dstBitmap)); | 29 image.reset(SkImage::NewFromBitmap(dstBitmap)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 SkBitmap tgt; | 32 SkBitmap tgt; |
| 33 tgt.allocN32Pixels(gWidth, gHeight); | 33 tgt.allocN32Pixels(gWidth, gHeight); |
| 34 SkCanvas canvas(tgt); | 34 SkCanvas canvas(tgt); |
| 35 canvas.clear(SK_ColorTRANSPARENT); | 35 canvas.clear(SK_ColorTRANSPARENT); |
| 36 canvas.drawImage(image, 0, 0, NULL); | 36 canvas.drawImage(image, 0, 0, nullptr); |
| 37 | 37 |
| 38 uint32_t pixel = 0; | 38 uint32_t pixel = 0; |
| 39 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul
_SkAlphaType); | 39 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul
_SkAlphaType); |
| 40 canvas.readPixels(info, &pixel, 4, 0, 0); | 40 canvas.readPixels(info, &pixel, 4, 0, 0); |
| 41 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 41 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 42 canvas.readPixels(info, &pixel, 4, gWidth - 6, gWidth - 6); | 42 canvas.readPixels(info, &pixel, 4, gWidth - 6, gWidth - 6); |
| 43 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 43 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 44 | 44 |
| 45 canvas.readPixels(info, &pixel, 4, gWidth - 5, gWidth - 5); | 45 canvas.readPixels(info, &pixel, 4, gWidth - 5, gWidth - 5); |
| 46 REPORTER_ASSERT(reporter, pixel == SK_ColorTRANSPARENT); | 46 REPORTER_ASSERT(reporter, pixel == SK_ColorTRANSPARENT); |
| 47 } | 47 } |
| OLD | NEW |