| 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 "SkSwizzler.h" | 8 #include "SkSwizzler.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 SkPMColor* colorTable) { | 22 SkPMColor* colorTable) { |
| 23 | 23 |
| 24 // Calculate the total size of the image in bytes. Use the smallest possibl
e size. | 24 // Calculate the total size of the image in bytes. Use the smallest possibl
e size. |
| 25 // The offset value tells us to adjust the pointer from the memory we alloca
te in order | 25 // The offset value tells us to adjust the pointer from the memory we alloca
te in order |
| 26 // to test on different memory alignments. If offset is nonzero, we need to
increase the | 26 // to test on different memory alignments. If offset is nonzero, we need to
increase the |
| 27 // size of the memory we allocate in order to make sure that we have enough.
We are | 27 // size of the memory we allocate in order to make sure that we have enough.
We are |
| 28 // still allocating the smallest possible size. | 28 // still allocating the smallest possible size. |
| 29 const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset; | 29 const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset; |
| 30 | 30 |
| 31 // Create fake image data where every byte has a value of 0 | 31 // Create fake image data where every byte has a value of 0 |
| 32 SkAutoTDeleteArray<uint8_t> storage(SkNEW_ARRAY(uint8_t, totalBytes)); | 32 SkAutoTDeleteArray<uint8_t> storage(new uint8_t[totalBytes]); |
| 33 memset(storage.get(), 0, totalBytes); | 33 memset(storage.get(), 0, totalBytes); |
| 34 // Adjust the pointer in order to test on different memory alignments | 34 // Adjust the pointer in order to test on different memory alignments |
| 35 uint8_t* imageData = storage.get() + offset; | 35 uint8_t* imageData = storage.get() + offset; |
| 36 uint8_t* imageStart = imageData + rowBytes * startRow; | 36 uint8_t* imageStart = imageData + rowBytes * startRow; |
| 37 | 37 |
| 38 // Fill image with the fill value starting at the indicated row | 38 // Fill image with the fill value starting at the indicated row |
| 39 SkSwizzler::Fill(imageStart, imageInfo, rowBytes, endRow - startRow + 1, col
orOrIndex, | 39 SkSwizzler::Fill(imageStart, imageInfo, rowBytes, endRow - startRow + 1, col
orOrIndex, |
| 40 colorTable); | 40 colorTable); |
| 41 | 41 |
| 42 // Ensure that the pixels are filled properly | 42 // Ensure that the pixels are filled properly |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Fill a grayscale image | 125 // Fill a grayscale image |
| 126 check_fill(r, grayInfo, startRow, endRow, grayRowByt
es, offset, | 126 check_fill(r, grayInfo, startRow, endRow, grayRowByt
es, offset, |
| 127 kFillColor, NULL); | 127 kFillColor, NULL); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 } | 134 } |
| OLD | NEW |