| 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 "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 test_encode(reporter, ctx); | 103 test_encode(reporter, ctx); |
| 104 } | 104 } |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 DEF_TEST(Image_NewRasterCopy, reporter) { | 107 DEF_TEST(Image_NewRasterCopy, reporter) { |
| 108 const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0); | 108 const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0); |
| 109 const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0); | 109 const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0); |
| 110 const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF); | 110 const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF); |
| 111 SkPMColor colors[] = { red, green, blue, 0 }; | 111 SkPMColor colors[] = { red, green, blue, 0 }; |
| 112 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colors, SK_ARRAY
_COUNT(colors)))); | 112 SkAutoTUnref<SkColorTable> ctable(new SkColorTable(colors, SK_ARRAY_COUNT(co
lors))); |
| 113 // The colortable made a copy, so we can trash the original colors | 113 // The colortable made a copy, so we can trash the original colors |
| 114 memset(colors, 0xFF, sizeof(colors)); | 114 memset(colors, 0xFF, sizeof(colors)); |
| 115 | 115 |
| 116 const SkImageInfo srcInfo = SkImageInfo::Make(2, 2, kIndex_8_SkColorType, kP
remul_SkAlphaType); | 116 const SkImageInfo srcInfo = SkImageInfo::Make(2, 2, kIndex_8_SkColorType, kP
remul_SkAlphaType); |
| 117 const size_t srcRowBytes = 2 * sizeof(uint8_t); | 117 const size_t srcRowBytes = 2 * sizeof(uint8_t); |
| 118 uint8_t indices[] = { 0, 1, 2, 3 }; | 118 uint8_t indices[] = { 0, 1, 2, 3 }; |
| 119 SkAutoTUnref<SkImage> image(SkImage::NewRasterCopy(srcInfo, indices, srcRowB
ytes, ctable)); | 119 SkAutoTUnref<SkImage> image(SkImage::NewRasterCopy(srcInfo, indices, srcRowB
ytes, ctable)); |
| 120 // The image made a copy, so we can trash the original indices | 120 // The image made a copy, so we can trash the original indices |
| 121 memset(indices, 0xFF, sizeof(indices)); | 121 memset(indices, 0xFF, sizeof(indices)); |
| 122 | 122 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 image.reset(nullptr); | 311 image.reset(nullptr); |
| 312 { | 312 { |
| 313 SkBitmap cachedBitmap; | 313 SkBitmap cachedBitmap; |
| 314 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; | 314 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 #endif | 317 #endif |
| OLD | NEW |