diff options
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkMask.h | 16 | ||||
-rw-r--r-- | include/core/SkScalerContext.h | 17 |
2 files changed, 28 insertions, 5 deletions
diff --git a/include/core/SkMask.h b/include/core/SkMask.h index 58a249341f..ebb870feaf 100644 --- a/include/core/SkMask.h +++ b/include/core/SkMask.h @@ -47,6 +47,7 @@ struct SkMask { kHorizontalLCD_Format, //!< 4 bytes/pixel: a/r/g/b kVerticalLCD_Format, //!< 4 bytes/pixel: a/r/g/b kARGB32_Format, //!< SkPMColor + kLCD16_Format //!< 565 alpha for r/g/b }; enum { @@ -96,6 +97,19 @@ struct SkMask { return fImage + x - fBounds.fLeft + (y - fBounds.fTop) * fRowBytes; } + /** + * Return the address of the specified 16bit mask. In the debug build, + * this asserts that the mask's format is kLCD16_Format, and that (x,y) + * are contained in the mask's fBounds. + */ + uint16_t* getAddrLCD16(int x, int y) const { + SkASSERT(kLCD16_Format == fFormat); + SkASSERT(fBounds.contains(x, y)); + SkASSERT(fImage != NULL); + uint16_t* row = (uint16_t*)(fImage + (y - fBounds.fTop) * fRowBytes); + return row + (x - fBounds.fLeft); + } + /** Return an address into the 32-bit plane of an LCD or VerticalLCD mask for the given position. */ @@ -120,7 +134,7 @@ struct SkMask { static uint8_t* AllocImage(size_t bytes); static void FreeImage(void* image); - + enum CreateMode { kJustComputeBounds_CreateMode, //!< compute bounds and return kJustRenderImage_CreateMode, //!< render into preallocate mask diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h index 317658dbd1..584b86bfb6 100644 --- a/include/core/SkScalerContext.h +++ b/include/core/SkScalerContext.h @@ -53,18 +53,27 @@ struct SkGlyph { fMaskFormat = MASK_FORMAT_UNKNOWN; } - unsigned rowBytes() const { - unsigned rb = fWidth; - if (SkMask::kBW_Format == fMaskFormat) { + /** + * Compute the rowbytes for the specified width and mask-format. + */ + static unsigned ComputeRowBytes(unsigned width, SkMask::Format format) { + unsigned rb = width; + if (SkMask::kBW_Format == format) { rb = (rb + 7) >> 3; - } else if (SkMask::kARGB32_Format == fMaskFormat) { + } else if (SkMask::kARGB32_Format == format) { rb <<= 2; + } else if (SkMask::kLCD16_Format == format) { + rb = SkAlign4(rb << 1); } else { rb = SkAlign4(rb); } return rb; } + unsigned rowBytes() const { + return ComputeRowBytes(fWidth, (SkMask::Format)fMaskFormat); + } + bool isJustAdvance() const { return MASK_FORMAT_JUST_ADVANCE == fMaskFormat; } |