* implemented a lock up table for drawing text in B_OP_COPY,
maybe this is too resource hungry, feel free to critisize... :-) * the speedup is there, but not overwhelming git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21929 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c6811df0c3
commit
8f4f70a56d
@ -1147,6 +1147,8 @@ Painter::_UpdateDrawingMode(bool drawingText)
|
||||
// are up to date for use by the solid drawing mode version.
|
||||
fPixelFormat.SetDrawingMode(fDrawingMode, fAlphaSrcMode,
|
||||
fAlphaFncMode, drawingText);
|
||||
if (drawingText)
|
||||
fPatternHandler.MakeOpCopyColorCache();
|
||||
}
|
||||
|
||||
// _SetRendererColor
|
||||
|
@ -64,19 +64,24 @@ blend_solid_hspan_copy_text(int x, int y, unsigned len,
|
||||
agg_buffer* buffer,
|
||||
const PatternHandler* pattern)
|
||||
{
|
||||
uint8* p = buffer->row_ptr(y) + (x << 2);
|
||||
rgb_color l = pattern->LowColor().GetColor32();
|
||||
//printf("blend_solid_hspan_copy_text(%d, %d)\n", x, len);
|
||||
// uint8* p = buffer->row_ptr(y) + (x << 2);
|
||||
uint32* p = (uint32*)(buffer->row_ptr(y) + (x << 2));
|
||||
const uint32* cache = (const uint32*)pattern->OpCopyColorCache();
|
||||
// rgb_color l = pattern->LowColor().GetColor32();
|
||||
do {
|
||||
if (*covers) {
|
||||
if(*covers == 255) {
|
||||
ASSIGN_COPY(p, c.r, c.g, c.b, c.a);
|
||||
} else {
|
||||
BLEND_COPY(p, c.r, c.g, c.b, *covers,
|
||||
l.red, l.green, l.blue);
|
||||
}
|
||||
}
|
||||
// if (*covers) {
|
||||
*p = cache[*covers];
|
||||
// if(*covers == 255) {
|
||||
// ASSIGN_COPY(p, c.r, c.g, c.b, c.a);
|
||||
// } else {
|
||||
// BLEND_COPY(p, c.r, c.g, c.b, *covers,
|
||||
// l.red, l.green, l.blue);
|
||||
// }
|
||||
// }
|
||||
covers++;
|
||||
p += 4;
|
||||
p++;
|
||||
// p += 4;
|
||||
} while(--len);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "PatternHandler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Point.h>
|
||||
|
||||
@ -30,8 +31,10 @@ PatternHandler::PatternHandler(void)
|
||||
fHighColor(kBlack),
|
||||
fLowColor(kWhite),
|
||||
fXOffset(0),
|
||||
fYOffset(0)
|
||||
fYOffset(0),
|
||||
fColorsWhenCached(ULONGLONG_MAX)
|
||||
{
|
||||
memset(fOpCopyColorCache, 255, 256 * sizeof(rgb_color));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -46,8 +49,10 @@ PatternHandler::PatternHandler(const int8* pat)
|
||||
fHighColor(kBlack),
|
||||
fLowColor(kWhite),
|
||||
fXOffset(0),
|
||||
fYOffset(0)
|
||||
fYOffset(0),
|
||||
fColorsWhenCached(ULONGLONG_MAX)
|
||||
{
|
||||
memset(fOpCopyColorCache, 255, 256 * sizeof(rgb_color));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -62,8 +67,10 @@ PatternHandler::PatternHandler(const uint64& pat)
|
||||
fHighColor(kBlack),
|
||||
fLowColor(kWhite),
|
||||
fXOffset(0),
|
||||
fYOffset(0)
|
||||
fYOffset(0),
|
||||
fColorsWhenCached(ULONGLONG_MAX)
|
||||
{
|
||||
memset(fOpCopyColorCache, 255, 256 * sizeof(rgb_color));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -78,8 +85,10 @@ PatternHandler::PatternHandler(const Pattern& pat)
|
||||
fHighColor(kBlack),
|
||||
fLowColor(kWhite),
|
||||
fXOffset(0),
|
||||
fYOffset(0)
|
||||
fYOffset(0),
|
||||
fColorsWhenCached(ULONGLONG_MAX)
|
||||
{
|
||||
memset(fOpCopyColorCache, 255, 256 * sizeof(rgb_color));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -93,8 +102,10 @@ PatternHandler::PatternHandler(const PatternHandler& other)
|
||||
fHighColor(other.fHighColor),
|
||||
fLowColor(other.fLowColor),
|
||||
fXOffset(other.fXOffset),
|
||||
fYOffset(other.fYOffset)
|
||||
fYOffset(other.fYOffset),
|
||||
fColorsWhenCached(ULONGLONG_MAX)
|
||||
{
|
||||
memset(fOpCopyColorCache, 255, 256 * sizeof(rgb_color));
|
||||
}
|
||||
|
||||
//! Destructor does nothing
|
||||
@ -189,7 +200,6 @@ void
|
||||
PatternHandler::SetColors(const rgb_color& high, const rgb_color& low)
|
||||
{
|
||||
fHighColor = high;
|
||||
fLowColor = low;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -258,3 +268,39 @@ PatternHandler::SetOffsets(int32 x, int32 y)
|
||||
fYOffset = y & 7;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PatternHandler::MakeOpCopyColorCache()
|
||||
{
|
||||
rgb_color highColor = fHighColor.GetColor32();
|
||||
rgb_color lowColor = fLowColor.GetColor32();
|
||||
|
||||
uint64 t1 = *(uint32*)&highColor;
|
||||
uint32 t2 = *(uint32*)&lowColor;
|
||||
|
||||
uint64 colors = (t1 << 32) | t2;
|
||||
|
||||
if (fColorsWhenCached == colors)
|
||||
return;
|
||||
|
||||
fColorsWhenCached = colors;
|
||||
|
||||
// ramp from low color to high color
|
||||
uint8 rA = fLowColor.GetColor32().red;
|
||||
uint8 gA = fLowColor.GetColor32().green;
|
||||
uint8 bA = fLowColor.GetColor32().blue;
|
||||
|
||||
uint8 rB = fHighColor.GetColor32().red;
|
||||
uint8 gB = fHighColor.GetColor32().green;
|
||||
uint8 bB = fHighColor.GetColor32().blue;
|
||||
|
||||
for (int32 i = 0; i < 256; i++) {
|
||||
// NOTE: rgb is twisted around, since this is
|
||||
// only used as uint32 in the end
|
||||
fOpCopyColorCache[i].red = (((bB - bA) * i) + (bA << 8)) >> 8;
|
||||
fOpCopyColorCache[i].green = (((gB - gA) * i) + (gA << 8)) >> 8;
|
||||
fOpCopyColorCache[i].blue = (((rB - rA) * i) + (rA << 8)) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,6 +131,10 @@ class PatternHandler {
|
||||
|
||||
void SetOffsets(int32 x, int32 y);
|
||||
|
||||
void MakeOpCopyColorCache();
|
||||
inline const rgb_color* OpCopyColorCache() const
|
||||
{ return fOpCopyColorCache; }
|
||||
|
||||
private:
|
||||
Pattern fPattern;
|
||||
RGBColor fHighColor;
|
||||
@ -138,6 +142,9 @@ class PatternHandler {
|
||||
|
||||
uint16 fXOffset;
|
||||
uint16 fYOffset;
|
||||
|
||||
rgb_color fOpCopyColorCache[256];
|
||||
uint64 fColorsWhenCached;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user