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:
@@ -1,32 +1,51 @@
|
|||||||
// DrawingModeFactory.h
|
// DrawingModeFactory.h
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "DrawingModeAdd.h"
|
#include "DrawingModeAdd.h"
|
||||||
|
#include "DrawingModeAlphaCC.h"
|
||||||
|
#include "DrawingModeAlphaCO.h"
|
||||||
|
#include "DrawingModeAlphaPC.h"
|
||||||
|
#include "DrawingModeAlphaPO.h"
|
||||||
#include "DrawingModeBlend.h"
|
#include "DrawingModeBlend.h"
|
||||||
#include "DrawingModeCopy.h"
|
#include "DrawingModeCopy.h"
|
||||||
|
#include "DrawingModeErase.h"
|
||||||
#include "DrawingModeInvert.h"
|
#include "DrawingModeInvert.h"
|
||||||
#include "DrawingModeMax.h"
|
#include "DrawingModeMax.h"
|
||||||
#include "DrawingModeMin.h"
|
#include "DrawingModeMin.h"
|
||||||
#include "DrawingModeOver.h"
|
#include "DrawingModeOver.h"
|
||||||
|
#include "DrawingModeSelect.h"
|
||||||
#include "DrawingModeSubtract.h"
|
#include "DrawingModeSubtract.h"
|
||||||
|
|
||||||
#include "DrawingModeFactory.h"
|
#include "DrawingModeFactory.h"
|
||||||
|
|
||||||
// DrawingModeFor
|
// DrawingModeFor
|
||||||
agg::DrawingMode*
|
agg::DrawingMode*
|
||||||
DrawingModeFactory::DrawingModeFor(drawing_mode mode)
|
DrawingModeFactory::DrawingModeFor(drawing_mode mode,
|
||||||
|
source_alpha alphaSrcMode,
|
||||||
|
alpha_function alphaFncMode)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case B_OP_INVERT:
|
// these drawing modes discard source pixels
|
||||||
return new agg::DrawingModeBGRA32Invert();
|
// which have the current low color
|
||||||
break;
|
|
||||||
case B_OP_COPY:
|
|
||||||
return new agg::DrawingModeBGRA32Copy();
|
|
||||||
break;
|
|
||||||
case B_OP_OVER:
|
case B_OP_OVER:
|
||||||
return new agg::DrawingModeBGRA32Over();
|
return new agg::DrawingModeBGRA32Over();
|
||||||
break;
|
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:
|
case B_OP_ADD:
|
||||||
return new agg::DrawingModeBGRA32Add();
|
return new agg::DrawingModeBGRA32Add();
|
||||||
break;
|
break;
|
||||||
@@ -36,7 +55,6 @@ DrawingModeFactory::DrawingModeFor(drawing_mode mode)
|
|||||||
case B_OP_BLEND:
|
case B_OP_BLEND:
|
||||||
return new agg::DrawingModeBGRA32Blend();
|
return new agg::DrawingModeBGRA32Blend();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_OP_MIN:
|
case B_OP_MIN:
|
||||||
return new agg::DrawingModeBGRA32Min();
|
return new agg::DrawingModeBGRA32Min();
|
||||||
break;
|
break;
|
||||||
@@ -44,8 +62,34 @@ DrawingModeFactory::DrawingModeFor(drawing_mode mode)
|
|||||||
return new agg::DrawingModeBGRA32Max();
|
return new agg::DrawingModeBGRA32Max();
|
||||||
break;
|
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:
|
default:
|
||||||
|
fprintf(stderr, "DrawingModeFactory::DrawingModeFor() - drawing_mode not implemented\n");
|
||||||
return new agg::DrawingModeBGRA32Copy();
|
return new agg::DrawingModeBGRA32Copy();
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ class DrawingModeFactory {
|
|||||||
DrawingModeFactory() {}
|
DrawingModeFactory() {}
|
||||||
virtual ~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
|
#endif // DRAWING_MODE_FACTORY_H
|
||||||
|
|||||||
Reference in New Issue
Block a user