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 size_t xSizeT, ySizeT; |
reed1
2013/09/20 19:02:39
do we really need to have two local vars to call t
mtklein
2013/09/20 19:29:35
We could, but that'd force offset and rowBytes to
| |
916 SkDivMod(offset, rowBytes, &ySizeT, &xSizeT); | |
917 *y = SkToS32(ySizeT); | |
918 *x = SkToS32(xSizeT); | |
917 switch (config) { | 919 switch (config) { |
918 case SkBitmap::kA8_Config: | 920 case SkBitmap::kA8_Config: |
919 // Fall through. | 921 // Fall through. |
920 case SkBitmap::kIndex8_Config: | 922 case SkBitmap::kIndex8_Config: |
921 // x is unmodified | 923 // x is unmodified |
922 break; | 924 break; |
923 | 925 |
924 case SkBitmap::kRGB_565_Config: | 926 case SkBitmap::kRGB_565_Config: |
925 // Fall through. | 927 // Fall through. |
926 case SkBitmap::kARGB_4444_Config: | 928 case SkBitmap::kARGB_4444_Config: |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 if (NULL != uri) { | 1702 if (NULL != uri) { |
1701 str->appendf(" uri:\"%s\"", uri); | 1703 str->appendf(" uri:\"%s\"", uri); |
1702 } else { | 1704 } else { |
1703 str->appendf(" pixelref:%p", pr); | 1705 str->appendf(" pixelref:%p", pr); |
1704 } | 1706 } |
1705 } | 1707 } |
1706 | 1708 |
1707 str->append(")"); | 1709 str->append(")"); |
1708 } | 1710 } |
1709 #endif | 1711 #endif |
OLD | NEW |