Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4827dd9b authored by Chris Craik's avatar Chris Craik Committed by Android Git Automerger
Browse files

am 6f30cc2d: am 90eaf92e: am 7e13d1d4: am f6c9c420: Merge "Correct stride for...

am 6f30cc2d: am 90eaf92e: am 7e13d1d4: am f6c9c420: Merge "Correct stride for drawing to cached glyph bitmap"

* commit '6f30cc2db5c483a04a7b65f2fe91d317970e9112':
  Correct stride for drawing to cached glyph bitmap
parents c659d127 f9075798
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -214,19 +214,29 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t*
    int dstY = y + glyph->mBitmapTop;

    CacheTexture* cacheTexture = glyph->mCacheTexture;
    PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();

    uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
    uint32_t cacheWidth = cacheTexture->getWidth();
    uint32_t startY = glyph->mStartY * cacheWidth;
    uint32_t endY = startY + (glyph->mBitmapHeight * cacheWidth);
    uint32_t srcStride = formatSize * cacheWidth;
    uint32_t startY = glyph->mStartY * srcStride;
    uint32_t endY = startY + (glyph->mBitmapHeight * srcStride);

    PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
    const uint8_t* cacheBuffer = pixelBuffer->map();

    for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY;
            cacheY += cacheWidth, bitmapY += bitmapWidth) {
            cacheY += srcStride, bitmapY += bitmapWidth) {

        if (formatSize == 1) {
            memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
        } else {
            for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) {
                bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize];
            }
        }
    }

}

void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset,
        SkPathMeasure& measure, SkPoint* position, SkVector* tangent) {