| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 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 "SkMask.h" | 8 #include "SkMask.h" |
| 9 | 9 |
| 10 /** returns the product if it is positive and fits in 31 bits. Otherwise this | 10 /** returns the product if it is positive and fits in 31 bits. Otherwise this |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 /////////////////////////////////////////////////////////////////////////////// | 47 /////////////////////////////////////////////////////////////////////////////// |
| 48 | 48 |
| 49 static const int gMaskFormatToShift[] = { | 49 static const int gMaskFormatToShift[] = { |
| 50 ~0, // BW -- not supported | 50 ~0, // BW -- not supported |
| 51 0, // A8 | 51 0, // A8 |
| 52 0, // 3D | 52 0, // 3D |
| 53 2, // ARGB32 | 53 2, // ARGB32 |
| 54 1, // LCD16 | 54 1, // LCD16 |
| 55 2 // LCD32 | |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 static int maskFormatToShift(SkMask::Format format) { | 57 static int maskFormatToShift(SkMask::Format format) { |
| 59 SkASSERT((unsigned)format < SK_ARRAY_COUNT(gMaskFormatToShift)); | 58 SkASSERT((unsigned)format < SK_ARRAY_COUNT(gMaskFormatToShift)); |
| 60 SkASSERT(SkMask::kBW_Format != format); | 59 SkASSERT(SkMask::kBW_Format != format); |
| 61 return gMaskFormatToShift[format]; | 60 return gMaskFormatToShift[format]; |
| 62 } | 61 } |
| 63 | 62 |
| 64 void* SkMask::getAddr(int x, int y) const { | 63 void* SkMask::getAddr(int x, int y) const { |
| 65 SkASSERT(kBW_Format != fFormat); | 64 SkASSERT(kBW_Format != fFormat); |
| 66 SkASSERT(fBounds.contains(x, y)); | 65 SkASSERT(fBounds.contains(x, y)); |
| 67 SkASSERT(fImage); | 66 SkASSERT(fImage); |
| 68 | 67 |
| 69 char* addr = (char*)fImage; | 68 char* addr = (char*)fImage; |
| 70 addr += (y - fBounds.fTop) * fRowBytes; | 69 addr += (y - fBounds.fTop) * fRowBytes; |
| 71 addr += (x - fBounds.fLeft) << maskFormatToShift(fFormat); | 70 addr += (x - fBounds.fLeft) << maskFormatToShift(fFormat); |
| 72 return addr; | 71 return addr; |
| 73 } | 72 } |
| OLD | NEW |