support for the rest of the drawing modes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11099 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-01-28 13:05:37 +00:00
parent 3741b755dc
commit 8eca754bfd
2 changed files with 55 additions and 9 deletions

View File

@ -1,32 +1,51 @@
// DrawingModeFactory.h
#include <stdio.h>
#include "DrawingModeAdd.h"
#include "DrawingModeAlphaCC.h"
#include "DrawingModeAlphaCO.h"
#include "DrawingModeAlphaPC.h"
#include "DrawingModeAlphaPO.h"
#include "DrawingModeBlend.h"
#include "DrawingModeCopy.h"
#include "DrawingModeErase.h"
#include "DrawingModeInvert.h"
#include "DrawingModeMax.h"
#include "DrawingModeMin.h"
#include "DrawingModeOver.h"
#include "DrawingModeSelect.h"
#include "DrawingModeSubtract.h"
#include "DrawingModeFactory.h"
// DrawingModeFor
agg::DrawingMode*
DrawingModeFactory::DrawingModeFor(drawing_mode mode)
DrawingModeFactory::DrawingModeFor(drawing_mode mode,
source_alpha alphaSrcMode,
alpha_function alphaFncMode)
{
switch (mode) {
case B_OP_INVERT:
return new agg::DrawingModeBGRA32Invert();
break;
case B_OP_COPY:
return new agg::DrawingModeBGRA32Copy();
break;
// these drawing modes discard source pixels
// which have the current low color
case B_OP_OVER:
return new agg::DrawingModeBGRA32Over();
break;
case B_OP_ERASE:
return new agg::DrawingModeBGRA32Erase();
break;
case B_OP_INVERT:
return new agg::DrawingModeBGRA32Invert();
break;
case B_OP_SELECT:
return new agg::DrawingModeBGRA32Select();
break;
// in these drawing modes, the current high
// and low color are treated equally
case B_OP_COPY:
return new agg::DrawingModeBGRA32Copy();
break;
case B_OP_ADD:
return new agg::DrawingModeBGRA32Add();
break;
@ -36,7 +55,6 @@ DrawingModeFactory::DrawingModeFor(drawing_mode mode)
case B_OP_BLEND:
return new agg::DrawingModeBGRA32Blend();
break;
case B_OP_MIN:
return new agg::DrawingModeBGRA32Min();
break;
@ -44,8 +62,34 @@ DrawingModeFactory::DrawingModeFor(drawing_mode mode)
return new agg::DrawingModeBGRA32Max();
break;
// this drawing mode is the only one considering
// alpha at all. In B_CONSTANT_ALPHA, the alpha
// value from the current high color is used for
// all computations. In B_PIXEL_ALPHA, the alpha
// is considered at every source pixel.
// To simplify the implementation, four separate
// DrawingMode classes are used to cover the
// four possible combinations of alpha enabled drawing.
case B_OP_ALPHA:
if (alphaSrcMode == B_CONSTANT_ALPHA) {
if (alphaFncMode == B_ALPHA_OVERLAY) {
return new agg::DrawingModeBGRA32AlphaCO();
} else if (alphaFncMode == B_ALPHA_COMPOSITE) {
return new agg::DrawingModeBGRA32AlphaCC();
}
} else if (alphaSrcMode == B_PIXEL_ALPHA){
if (alphaFncMode == B_ALPHA_OVERLAY) {
return new agg::DrawingModeBGRA32AlphaPO();
} else if (alphaFncMode == B_ALPHA_COMPOSITE) {
return new agg::DrawingModeBGRA32AlphaPC();
}
}
break;
default:
fprintf(stderr, "DrawingModeFactory::DrawingModeFor() - drawing_mode not implemented\n");
return new agg::DrawingModeBGRA32Copy();
}
return NULL;
}

View File

@ -12,7 +12,9 @@ class DrawingModeFactory {
DrawingModeFactory() {}
virtual ~DrawingModeFactory() {}
static agg::DrawingMode* DrawingModeFor(drawing_mode mode);
static agg::DrawingMode* DrawingModeFor(drawing_mode mode,
source_alpha alphaSrcMode,
alpha_function alphaFncMode);
};
#endif // DRAWING_MODE_FACTORY_H