OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 bool get_upper_left_from_offset(SkBitmap::Config config, size_t offset, size_t r
owBytes, | 904 bool get_upper_left_from_offset(SkBitmap::Config config, size_t offset, size_t r
owBytes, |
905 int32_t* x, int32_t* y); | 905 int32_t* x, int32_t* y); |
906 bool get_upper_left_from_offset(SkBitmap::Config config, size_t offset, size_t r
owBytes, | 906 bool get_upper_left_from_offset(SkBitmap::Config config, size_t offset, size_t r
owBytes, |
907 int32_t* x, int32_t* y) { | 907 int32_t* x, int32_t* y) { |
908 SkASSERT(x != NULL && y != NULL); | 908 SkASSERT(x != NULL && y != NULL); |
909 if (0 == offset) { | 909 if (0 == offset) { |
910 *x = *y = 0; | 910 *x = *y = 0; |
911 return true; | 911 return true; |
912 } | 912 } |
913 // Use integer division to find the correct y position. | 913 // Use integer division to find the correct y position. |
914 *y = SkToS32(offset / rowBytes); | |
915 // The remainder will be the x position, after we reverse get_sub_offset. | 914 // The remainder will be the x position, after we reverse get_sub_offset. |
916 *x = SkToS32(offset % rowBytes); | 915 SkTDivMod(offset, rowBytes, y, x); |
917 switch (config) { | 916 switch (config) { |
918 case SkBitmap::kA8_Config: | 917 case SkBitmap::kA8_Config: |
919 // Fall through. | 918 // Fall through. |
920 case SkBitmap::kIndex8_Config: | 919 case SkBitmap::kIndex8_Config: |
921 // x is unmodified | 920 // x is unmodified |
922 break; | 921 break; |
923 | 922 |
924 case SkBitmap::kRGB_565_Config: | 923 case SkBitmap::kRGB_565_Config: |
925 // Fall through. | 924 // Fall through. |
926 case SkBitmap::kARGB_4444_Config: | 925 case SkBitmap::kARGB_4444_Config: |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 if (NULL != uri) { | 1699 if (NULL != uri) { |
1701 str->appendf(" uri:\"%s\"", uri); | 1700 str->appendf(" uri:\"%s\"", uri); |
1702 } else { | 1701 } else { |
1703 str->appendf(" pixelref:%p", pr); | 1702 str->appendf(" pixelref:%p", pr); |
1704 } | 1703 } |
1705 } | 1704 } |
1706 | 1705 |
1707 str->append(")"); | 1706 str->append(")"); |
1708 } | 1707 } |
1709 #endif | 1708 #endif |
OLD | NEW |