KHTML
GraphicsTypes.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
00023
00024
00025
00026 #include "config.h"
00027 #include "GraphicsTypes.h"
00028
00029 #include "PlatformString.h"
00030 #include <wtf/Assertions.h>
00031
00032 namespace WebCore {
00033
00034 static const char* const compositeOperatorNames[] = {
00035 "clear",
00036 "copy",
00037 "source-over",
00038 "source-in",
00039 "source-out",
00040 "source-atop",
00041 "destination-over",
00042 "destination-in",
00043 "destination-out",
00044 "destination-atop",
00045 "xor",
00046 "darker",
00047 "highlight",
00048 "lighter"
00049 };
00050 const int numCompositeOperatorNames = sizeof(compositeOperatorNames) / sizeof(compositeOperatorNames[0]);
00051
00052 bool parseCompositeOperator(const String& s, CompositeOperator& op)
00053 {
00054 for (int i = 0; i < numCompositeOperatorNames; i++)
00055 if (s == compositeOperatorNames[i]) {
00056 op = static_cast<CompositeOperator>(i);
00057 return true;
00058 }
00059 return false;
00060 }
00061
00062 String compositeOperatorName(CompositeOperator op)
00063 {
00064 ASSERT(op >= 0);
00065 ASSERT(op < numCompositeOperatorNames);
00066 return compositeOperatorNames[op];
00067 }
00068
00069 bool parseLineCap(const String& s, LineCap& cap)
00070 {
00071 if (s == "butt") {
00072 cap = ButtCap;
00073 return true;
00074 }
00075 if (s == "round") {
00076 cap = RoundCap;
00077 return true;
00078 }
00079 if (s == "square") {
00080 cap = SquareCap;
00081 return true;
00082 }
00083 return false;
00084 }
00085
00086 String lineCapName(LineCap cap)
00087 {
00088 ASSERT(cap >= 0);
00089 ASSERT(cap < 3);
00090 const char* const names[3] = { "butt", "round", "square" };
00091 return names[cap];
00092 }
00093
00094 bool parseLineJoin(const String& s, LineJoin& join)
00095 {
00096 if (s == "miter") {
00097 join = MiterJoin;
00098 return true;
00099 }
00100 if (s == "round") {
00101 join = RoundJoin;
00102 return true;
00103 }
00104 if (s == "bevel") {
00105 join = BevelJoin;
00106 return true;
00107 }
00108 return false;
00109 }
00110
00111 String lineJoinName(LineJoin join)
00112 {
00113 ASSERT(join >= 0);
00114 ASSERT(join < 3);
00115 const char* const names[3] = { "miter", "round", "bevel" };
00116 return names[join];
00117 }
00118
00119 }