diff options
Diffstat (limited to 'skia/sgl/SkBlitter_4444.cpp')
-rw-r--r-- | skia/sgl/SkBlitter_4444.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/skia/sgl/SkBlitter_4444.cpp b/skia/sgl/SkBlitter_4444.cpp index de42312..cce94c5 100644 --- a/skia/sgl/SkBlitter_4444.cpp +++ b/skia/sgl/SkBlitter_4444.cpp @@ -1,6 +1,6 @@ /* libs/graphics/sgl/SkBlitter_ARGB32.cpp ** - ** Copyright 2006, Google Inc. + ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -379,11 +379,14 @@ class SkARGB4444_Shader_Blitter : public SkShaderBlitter { SkBlitRow::Proc fOpaqueProc; SkBlitRow::Proc fAlphaProc; SkPMColor* fBuffer; + uint8_t* fAAExpand; public: SkARGB4444_Shader_Blitter(const SkBitmap& device, const SkPaint& paint) : INHERITED(device, paint) { - fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); + const int width = device.width(); + fBuffer = (SkPMColor*)sk_malloc_throw(width * sizeof(SkPMColor) + width); + fAAExpand = (uint8_t*)(fBuffer + width); (fXfermode = paint.getXfermode())->safeRef(); @@ -423,7 +426,8 @@ virtual void blitH(int x, int y, int width) virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) { - SkPMColor* span = fBuffer; + SkPMColor* SK_RESTRICT span = fBuffer; + uint8_t* SK_RESTRICT aaExpand = fAAExpand; SkPMColor16* device = fDevice.getAddr16(x, y); SkShader* shader = fShader; SkXfermode* xfer = fXfermode; @@ -439,10 +443,12 @@ virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t ru if (255 == aa) { xfer->xfer4444(device, span, count, NULL); } else { - // count is almost always 1 - for (int i = count - 1; i >= 0; --i) { - xfer->xfer4444(&device[i], &span[i], count, antialias); + const uint8_t* aaBuffer = antialias; + if (count > 1) { + memset(aaExpand, aa, count); + aaBuffer = aaExpand; } + xfer->xfer4444(device, span, count, aaBuffer); } } device += count; |