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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 return SUB_OFFSET_FAILURE; | 859 return SUB_OFFSET_FAILURE; |
860 } | 860 } |
861 return y * bm.rowBytes() + x; | 861 return y * bm.rowBytes() + x; |
862 } | 862 } |
863 | 863 |
864 /** | 864 /** |
865 * Using the pixelRefOffset(), rowBytes(), and Config of bm, determine the (x,
y) coordinate of the | 865 * Using the pixelRefOffset(), rowBytes(), and Config of bm, determine the (x,
y) coordinate of the |
866 * upper left corner of bm relative to its SkPixelRef. | 866 * upper left corner of bm relative to its SkPixelRef. |
867 * x and y must be non-NULL. | 867 * x and y must be non-NULL. |
868 */ | 868 */ |
869 static bool getUpperLeftFromOffset(const SkBitmap& bm, int32_t* x, int32_t* y) { | 869 bool getUpperLeftFromOffset(const SkBitmap& bm, int32_t* x, int32_t* y) { |
870 SkASSERT(x != NULL && y != NULL); | 870 SkASSERT(x != NULL && y != NULL); |
871 const size_t offset = bm.pixelRefOffset(); | 871 const size_t offset = bm.pixelRefOffset(); |
872 if (0 == offset) { | 872 if (0 == offset) { |
873 *x = *y = 0; | 873 *x = *y = 0; |
874 return true; | 874 return true; |
875 } | 875 } |
876 // Use integer division to find the correct y position. | 876 // Use integer division to find the correct y position. |
877 *y = SkToS32(offset / bm.rowBytes()); | 877 *y = SkToS32(offset / bm.rowBytes()); |
878 // The remainder will be the x position, after we reverse getSubOffset. | 878 // The remainder will be the x position, after we reverse getSubOffset. |
879 *x = SkToS32(offset % bm.rowBytes()); | 879 *x = SkToS32(offset % bm.rowBytes()); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 if (NULL != uri) { | 1669 if (NULL != uri) { |
1670 str->appendf(" uri:\"%s\"", uri); | 1670 str->appendf(" uri:\"%s\"", uri); |
1671 } else { | 1671 } else { |
1672 str->appendf(" pixelref:%p", pr); | 1672 str->appendf(" pixelref:%p", pr); |
1673 } | 1673 } |
1674 } | 1674 } |
1675 | 1675 |
1676 str->append(")"); | 1676 str->append(")"); |
1677 } | 1677 } |
1678 #endif | 1678 #endif |
OLD | NEW |