KHTML
SVGFEComponentTransfer.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "config.h"
00023
00024 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
00025 #include "SVGFEComponentTransfer.h"
00026 #include "TextStream.h"
00027
00028 namespace WebCore {
00029
00030 SVGFEComponentTransfer::SVGFEComponentTransfer(SVGResourceFilter* filter)
00031 : SVGFilterEffect(filter)
00032 {
00033 }
00034
00035 SVGComponentTransferFunction SVGFEComponentTransfer::redFunction() const
00036 {
00037 return m_redFunc;
00038 }
00039
00040 void SVGFEComponentTransfer::setRedFunction(const SVGComponentTransferFunction& func)
00041 {
00042 m_redFunc = func;
00043 }
00044
00045 SVGComponentTransferFunction SVGFEComponentTransfer::greenFunction() const
00046 {
00047 return m_greenFunc;
00048 }
00049
00050 void SVGFEComponentTransfer::setGreenFunction(const SVGComponentTransferFunction& func)
00051 {
00052 m_greenFunc = func;
00053 }
00054
00055 SVGComponentTransferFunction SVGFEComponentTransfer::blueFunction() const
00056 {
00057 return m_blueFunc;
00058 }
00059
00060 void SVGFEComponentTransfer::setBlueFunction(const SVGComponentTransferFunction& func)
00061 {
00062 m_blueFunc = func;
00063 }
00064
00065 SVGComponentTransferFunction SVGFEComponentTransfer::alphaFunction() const
00066 {
00067 return m_alphaFunc;
00068 }
00069
00070 void SVGFEComponentTransfer::setAlphaFunction(const SVGComponentTransferFunction& func)
00071 {
00072 m_alphaFunc = func;
00073 }
00074
00075 static TextStream& operator<<(TextStream& ts, SVGComponentTransferType t)
00076 {
00077 switch (t)
00078 {
00079 case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
00080 ts << "UNKNOWN"; break;
00081 case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
00082 ts << "IDENTITY"; break;
00083 case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
00084 ts << "TABLE"; break;
00085 case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
00086 ts << "DISCRETE"; break;
00087 case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
00088 ts << "LINEAR"; break;
00089 case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
00090 ts << "GAMMA"; break;
00091 }
00092 return ts;
00093 }
00094
00095 static TextStream& operator<<(TextStream& ts, const SVGComponentTransferFunction &func)
00096 {
00097 ts << "[type=" << func.type << "]";
00098 switch (func.type) {
00099 case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
00100 case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
00101 break;
00102 case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
00103 case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
00104 {
00105 ts << " [table values=";
00106 Vector<float>::const_iterator itr=func.tableValues.begin();
00107 if (itr != func.tableValues.end()) {
00108 ts << *itr++;
00109 for (; itr!=func.tableValues.end(); itr++) {
00110 ts << " " << *itr;
00111 }
00112 }
00113 ts << "]";
00114 break;
00115 }
00116 case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
00117 ts << " [slope=" << func.slope << "]"
00118 << " [intercept=" << func.intercept << "]";
00119 break;
00120 case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
00121 ts << " [amplitude=" << func.amplitude << "]"
00122 << " [exponent=" << func.exponent << "]"
00123 << " [offset=" << func.offset << "]";
00124 break;
00125 }
00126 return ts;
00127 }
00128
00129 TextStream& SVGFEComponentTransfer::externalRepresentation(TextStream& ts) const
00130 {
00131 ts << "[type=COMPONENT-TRANSFER] ";
00132 SVGFilterEffect::externalRepresentation(ts);
00133 ts << " [red func=" << redFunction() << "]"
00134 << " [green func=" << greenFunction() << "]"
00135 << " [blue func=" << blueFunction() << "]"
00136 << " [alpha func=" << alphaFunction() << "]";
00137 return ts;
00138 }
00139
00140 }
00141
00142 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)