Add one more optimization for an often used case of bitmap rendering.
B_RGBA32 and B_RGB32 in B_OP_OVER no longer go through the generic AGG code path, but have an optimized version now, as long as the bitmap is not scaled. B_RGB32 needs to handle B_TRANSPARENT_MAGIC_RGBA32, while B_RGBA32 works just like regular alpha blending. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1273,6 +1273,21 @@ copy_bitmap_row_bgr32_copy(uint8* dst, const uint8* src, int32 numPixels,
|
|||||||
memcpy(dst, src, numPixels * 4);
|
memcpy(dst, src, numPixels * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy_bitmap_row_bgr32_over
|
||||||
|
static inline void
|
||||||
|
copy_bitmap_row_bgr32_over(uint8* dst, const uint8* src, int32 numPixels,
|
||||||
|
const rgb_color* colorMap)
|
||||||
|
{
|
||||||
|
uint32* d = (uint32*)dst;
|
||||||
|
uint32* s = (uint32*)src;
|
||||||
|
while (numPixels--) {
|
||||||
|
if (*s != B_TRANSPARENT_MAGIC_RGBA32)
|
||||||
|
*(uint32*)d = *(uint32*)s;
|
||||||
|
d++;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// copy_bitmap_row_bgr32_alpha
|
// copy_bitmap_row_bgr32_alpha
|
||||||
static inline void
|
static inline void
|
||||||
copy_bitmap_row_bgr32_alpha(uint8* dst, const uint8* src, int32 numPixels,
|
copy_bitmap_row_bgr32_alpha(uint8* dst, const uint8* src, int32 numPixels,
|
||||||
@@ -1326,8 +1341,7 @@ Painter::_TransparentMagicToAlpha(sourcePixel* buffer, uint32 width,
|
|||||||
// _DrawBitmap
|
// _DrawBitmap
|
||||||
void
|
void
|
||||||
Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format,
|
Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format,
|
||||||
BRect actualBitmapRect, BRect bitmapRect,
|
BRect actualBitmapRect, BRect bitmapRect, BRect viewRect) const
|
||||||
BRect viewRect) const
|
|
||||||
{
|
{
|
||||||
if (!fValidClipping
|
if (!fValidClipping
|
||||||
|| !bitmapRect.IsValid() || !bitmapRect.Intersects(actualBitmapRect)
|
|| !bitmapRect.IsValid() || !bitmapRect.Intersects(actualBitmapRect)
|
||||||
@@ -1392,6 +1406,14 @@ Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format,
|
|||||||
_DrawBitmapNoScale32(copy_bitmap_row_bgr32_copy, 4,
|
_DrawBitmapNoScale32(copy_bitmap_row_bgr32_copy, 4,
|
||||||
srcBuffer, xOffset, yOffset, viewRect);
|
srcBuffer, xOffset, yOffset, viewRect);
|
||||||
return;
|
return;
|
||||||
|
} else if (fDrawingMode == B_OP_OVER) {
|
||||||
|
if (format == B_RGB32)
|
||||||
|
_DrawBitmapNoScale32(copy_bitmap_row_bgr32_over, 4,
|
||||||
|
srcBuffer, xOffset, yOffset, viewRect);
|
||||||
|
else
|
||||||
|
_DrawBitmapNoScale32(copy_bitmap_row_bgr32_alpha, 4,
|
||||||
|
srcBuffer, xOffset, yOffset, viewRect);
|
||||||
|
return;
|
||||||
} else if (fDrawingMode == B_OP_ALPHA
|
} else if (fDrawingMode == B_OP_ALPHA
|
||||||
&& fAlphaSrcMode == B_PIXEL_ALPHA
|
&& fAlphaSrcMode == B_PIXEL_ALPHA
|
||||||
&& fAlphaFncMode == B_ALPHA_OVERLAY) {
|
&& fAlphaFncMode == B_ALPHA_OVERLAY) {
|
||||||
@@ -1404,7 +1426,7 @@ Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format,
|
|||||||
if (format == B_RGBA32 || fDrawingMode == B_OP_COPY) {
|
if (format == B_RGBA32 || fDrawingMode == B_OP_COPY) {
|
||||||
_DrawBitmapGeneric32(srcBuffer, xOffset, yOffset,
|
_DrawBitmapGeneric32(srcBuffer, xOffset, yOffset,
|
||||||
xScale, yScale, viewRect);
|
xScale, yScale, viewRect);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
// otherwise fall through to get proper transparency handling for
|
// otherwise fall through to get proper transparency handling for
|
||||||
// B_RGB32 where a B_TRANSPARENT_MAGIC might be set on pixels
|
// B_RGB32 where a B_TRANSPARENT_MAGIC might be set on pixels
|
||||||
@@ -1431,8 +1453,7 @@ Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format,
|
|||||||
BBitmap temp(actualBitmapRect, B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
BBitmap temp(actualBitmapRect, B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
||||||
status_t err = temp.ImportBits(srcBuffer.buf(),
|
status_t err = temp.ImportBits(srcBuffer.buf(),
|
||||||
srcBuffer.height() * srcBuffer.stride(),
|
srcBuffer.height() * srcBuffer.stride(),
|
||||||
srcBuffer.stride(),
|
srcBuffer.stride(), 0, format);
|
||||||
0, format);
|
|
||||||
|
|
||||||
if (err >= B_OK) {
|
if (err >= B_OK) {
|
||||||
// the original bitmap might have had some of the
|
// the original bitmap might have had some of the
|
||||||
|
|||||||
Reference in New Issue
Block a user