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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #endif | 31 #endif |
32 | 32 |
33 static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
* subsetA, | 33 static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect
* subsetA, |
34 SkImage* b) { | 34 SkImage* b) { |
35 const int widthA = subsetA ? subsetA->width() : a->width(); | 35 const int widthA = subsetA ? subsetA->width() : a->width(); |
36 const int heightA = subsetA ? subsetA->height() : a->height(); | 36 const int heightA = subsetA ? subsetA->height() : a->height(); |
37 | 37 |
38 REPORTER_ASSERT(reporter, widthA == b->width()); | 38 REPORTER_ASSERT(reporter, widthA == b->width()); |
39 REPORTER_ASSERT(reporter, heightA == b->height()); | 39 REPORTER_ASSERT(reporter, heightA == b->height()); |
40 #if 0 | 40 #if 0 |
41 // see skbug.com/3965 | 41 // see https://bug.skia.org/3965 |
42 bool AO = a->isOpaque(); | 42 bool AO = a->isOpaque(); |
43 bool BO = b->isOpaque(); | 43 bool BO = b->isOpaque(); |
44 REPORTER_ASSERT(reporter, AO == BO); | 44 REPORTER_ASSERT(reporter, AO == BO); |
45 #endif | 45 #endif |
46 | 46 |
47 SkImageInfo info = SkImageInfo::MakeN32(widthA, heightA, | 47 SkImageInfo info = SkImageInfo::MakeN32(widthA, heightA, |
48 a->isOpaque() ? kOpaque_SkAlphaType : kP
remul_SkAlphaType); | 48 a->isOpaque() ? kOpaque_SkAlphaType : kP
remul_SkAlphaType); |
49 SkAutoPixmapStorage pmapA, pmapB; | 49 SkAutoPixmapStorage pmapA, pmapB; |
50 pmapA.alloc(info); | 50 pmapA.alloc(info); |
51 pmapB.alloc(info); | 51 pmapB.alloc(info); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 image.reset(nullptr); | 342 image.reset(nullptr); |
343 { | 343 { |
344 SkBitmap cachedBitmap; | 344 SkBitmap cachedBitmap; |
345 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; | 345 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; |
346 } | 346 } |
347 } | 347 } |
348 #endif | 348 #endif |
349 | 349 |
350 // http://skbug.com/4390 | 350 // https://bug.skia.org/4390 |
351 DEF_TEST(ImageFromIndex8Bitmap, r) { | 351 DEF_TEST(ImageFromIndex8Bitmap, r) { |
352 SkPMColor pmColors[1] = {SkPreMultiplyColor(SK_ColorWHITE)}; | 352 SkPMColor pmColors[1] = {SkPreMultiplyColor(SK_ColorWHITE)}; |
353 SkBitmap bm; | 353 SkBitmap bm; |
354 SkAutoTUnref<SkColorTable> ctable( | 354 SkAutoTUnref<SkColorTable> ctable( |
355 new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors))); | 355 new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors))); |
356 SkImageInfo info = | 356 SkImageInfo info = |
357 SkImageInfo::Make(1, 1, kIndex_8_SkColorType, kPremul_SkAlphaType); | 357 SkImageInfo::Make(1, 1, kIndex_8_SkColorType, kPremul_SkAlphaType); |
358 bm.allocPixels(info, nullptr, ctable); | 358 bm.allocPixels(info, nullptr, ctable); |
359 SkAutoLockPixels autoLockPixels(bm); | 359 SkAutoLockPixels autoLockPixels(bm); |
360 *bm.getAddr8(0, 0) = 0; | 360 *bm.getAddr8(0, 0) = 0; |
361 SkAutoTUnref<SkImage> img(SkImage::NewFromBitmap(bm)); | 361 SkAutoTUnref<SkImage> img(SkImage::NewFromBitmap(bm)); |
362 REPORTER_ASSERT(r, img.get() != nullptr); | 362 REPORTER_ASSERT(r, img.get() != nullptr); |
363 } | 363 } |
OLD | NEW |