1 2/* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10#include "SkPathParts.h" 11#include "SkAnimateMaker.h" 12#include "SkDrawMatrix.h" 13#include "SkDrawRectangle.h" 14#include "SkDrawPath.h" 15 16SkPathPart::SkPathPart() : fPath(NULL) { 17} 18 19void SkPathPart::dirty() { 20 fPath->dirty(); 21} 22 23SkDisplayable* SkPathPart::getParent() const { 24 return fPath; 25} 26 27bool SkPathPart::setParent(SkDisplayable* parent) { 28 SkASSERT(parent != NULL); 29 if (parent->isPath() == false) 30 return true; 31 fPath = (SkDrawPath*) parent; 32 return false; 33} 34 35// MoveTo 36#if SK_USE_CONDENSED_INFO == 0 37 38const SkMemberInfo SkMoveTo::fInfo[] = { 39 SK_MEMBER(x, Float), 40 SK_MEMBER(y, Float) 41}; 42 43#endif 44 45DEFINE_GET_MEMBER(SkMoveTo); 46 47SkMoveTo::SkMoveTo() : x(0), y(0) { 48} 49 50bool SkMoveTo::add() { 51 fPath->fPath.moveTo(x, y); 52 return false; 53} 54 55 56// RMoveTo 57#if SK_USE_CONDENSED_INFO == 0 58 59const SkMemberInfo SkRMoveTo::fInfo[] = { 60 SK_MEMBER_INHERITED 61}; 62 63#endif 64 65DEFINE_GET_MEMBER(SkRMoveTo); 66 67bool SkRMoveTo::add() { 68 fPath->fPath.rMoveTo(x, y); 69 return false; 70} 71 72 73// LineTo 74#if SK_USE_CONDENSED_INFO == 0 75 76const SkMemberInfo SkLineTo::fInfo[] = { 77 SK_MEMBER(x, Float), 78 SK_MEMBER(y, Float) 79}; 80 81#endif 82 83DEFINE_GET_MEMBER(SkLineTo); 84 85SkLineTo::SkLineTo() : x(0), y(0) { 86} 87 88bool SkLineTo::add() { 89 fPath->fPath.lineTo(x, y); 90 return false; 91} 92 93 94// RLineTo 95#if SK_USE_CONDENSED_INFO == 0 96 97const SkMemberInfo SkRLineTo::fInfo[] = { 98 SK_MEMBER_INHERITED 99}; 100 101#endif 102 103DEFINE_GET_MEMBER(SkRLineTo); 104 105bool SkRLineTo::add() { 106 fPath->fPath.rLineTo(x, y); 107 return false; 108} 109 110 111// QuadTo 112#if SK_USE_CONDENSED_INFO == 0 113 114const SkMemberInfo SkQuadTo::fInfo[] = { 115 SK_MEMBER(x1, Float), 116 SK_MEMBER(x2, Float), 117 SK_MEMBER(y1, Float), 118 SK_MEMBER(y2, Float) 119}; 120 121#endif 122 123DEFINE_GET_MEMBER(SkQuadTo); 124 125SkQuadTo::SkQuadTo() : x1(0), y1(0), x2(0), y2(0) { 126} 127 128bool SkQuadTo::add() { 129 fPath->fPath.quadTo(x1, y1, x2, y2); 130 return false; 131} 132 133 134// RQuadTo 135#if SK_USE_CONDENSED_INFO == 0 136 137const SkMemberInfo SkRQuadTo::fInfo[] = { 138 SK_MEMBER_INHERITED 139}; 140 141#endif 142 143DEFINE_GET_MEMBER(SkRQuadTo); 144 145bool SkRQuadTo::add() { 146 fPath->fPath.rQuadTo(x1, y1, x2, y2); 147 return false; 148} 149 150 151// CubicTo 152#if SK_USE_CONDENSED_INFO == 0 153 154const SkMemberInfo SkCubicTo::fInfo[] = { 155 SK_MEMBER(x1, Float), 156 SK_MEMBER(x2, Float), 157 SK_MEMBER(x3, Float), 158 SK_MEMBER(y1, Float), 159 SK_MEMBER(y2, Float), 160 SK_MEMBER(y3, Float) 161}; 162 163#endif 164 165DEFINE_GET_MEMBER(SkCubicTo); 166 167SkCubicTo::SkCubicTo() : x1(0), y1(0), x2(0), y2(0), x3(0), y3(0) { 168} 169 170bool SkCubicTo::add() { 171 fPath->fPath.cubicTo(x1, y1, x2, y2, x3, y3); 172 return false; 173} 174 175 176// RCubicTo 177#if SK_USE_CONDENSED_INFO == 0 178 179const SkMemberInfo SkRCubicTo::fInfo[] = { 180 SK_MEMBER_INHERITED 181}; 182 183#endif 184 185DEFINE_GET_MEMBER(SkRCubicTo); 186 187bool SkRCubicTo::add() { 188 fPath->fPath.rCubicTo(x1, y1, x2, y2, x3, y3); 189 return false; 190} 191 192 193// SkClose 194bool SkClose::add() { 195 fPath->fPath.close(); 196 return false; 197} 198 199 200// SkAddGeom 201#if SK_USE_CONDENSED_INFO == 0 202 203const SkMemberInfo SkAddGeom::fInfo[] = { 204 SK_MEMBER(direction, PathDirection) 205}; 206 207#endif 208 209DEFINE_GET_MEMBER(SkAddGeom); 210 211SkAddGeom::SkAddGeom() : direction(SkPath::kCCW_Direction) { 212} 213 214#if SK_USE_CONDENSED_INFO == 0 215 216const SkMemberInfo SkAddRect::fInfo[] = { 217 SK_MEMBER_INHERITED, 218 SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float), 219 SK_MEMBER_ALIAS(left, fRect.fLeft, Float), 220 SK_MEMBER_ALIAS(right, fRect.fRight, Float), 221 SK_MEMBER_ALIAS(top, fRect.fTop, Float) 222}; 223 224#endif 225 226DEFINE_GET_MEMBER(SkAddRect); 227 228SkAddRect::SkAddRect() { 229 fRect.setEmpty(); 230} 231 232bool SkAddRect::add() { 233 fPath->fPath.addRect(fRect, (SkPath::Direction) direction); 234 return false; 235} 236 237 238#if SK_USE_CONDENSED_INFO == 0 239 240const SkMemberInfo SkAddOval::fInfo[] = { 241 SK_MEMBER_INHERITED 242}; 243 244#endif 245 246DEFINE_GET_MEMBER(SkAddOval); 247 248bool SkAddOval::add() { 249 fPath->fPath.addOval(fRect, (SkPath::Direction) direction); 250 return false; 251} 252 253 254#if SK_USE_CONDENSED_INFO == 0 255 256const SkMemberInfo SkAddCircle::fInfo[] = { 257 SK_MEMBER_INHERITED, 258 SK_MEMBER(radius, Float), 259 SK_MEMBER(x, Float), 260 SK_MEMBER(y, Float) 261}; 262 263#endif 264 265DEFINE_GET_MEMBER(SkAddCircle); 266 267SkAddCircle::SkAddCircle() : radius(0), x(0), y(0) { 268} 269 270bool SkAddCircle::add() { 271 fPath->fPath.addCircle(x, y, radius, (SkPath::Direction) direction); 272 return false; 273} 274 275 276#if SK_USE_CONDENSED_INFO == 0 277 278const SkMemberInfo SkAddRoundRect::fInfo[] = { 279 SK_MEMBER_INHERITED, 280 SK_MEMBER(rx, Float), 281 SK_MEMBER(ry, Float) 282}; 283 284#endif 285 286DEFINE_GET_MEMBER(SkAddRoundRect); 287 288SkAddRoundRect::SkAddRoundRect() : rx(0), ry(0) { 289} 290 291bool SkAddRoundRect::add() { 292 fPath->fPath.addRoundRect(fRect, rx, ry, (SkPath::Direction) direction); 293 return false; 294} 295 296 297#if SK_USE_CONDENSED_INFO == 0 298 299const SkMemberInfo SkAddPath::fInfo[] = { 300 SK_MEMBER(matrix, Matrix), 301 SK_MEMBER(path, Path) 302}; 303 304#endif 305 306DEFINE_GET_MEMBER(SkAddPath); 307 308SkAddPath::SkAddPath() : matrix(NULL), path(NULL) { 309} 310 311bool SkAddPath::add() { 312 SkASSERT (path != NULL); 313 if (matrix) 314 fPath->fPath.addPath(path->fPath, matrix->getMatrix()); 315 else 316 fPath->fPath.addPath(path->fPath); 317 return false; 318} 319 320 321