gfx/skia/trunk/src/animator/SkDrawExtraPathEffect.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "SkDrawExtraPathEffect.h"
michael@0 11 #include "SkDrawPath.h"
michael@0 12 #include "Sk1DPathEffect.h"
michael@0 13 #include "Sk2DPathEffect.h"
michael@0 14 #include "SkMemberInfo.h"
michael@0 15 #include "SkPaintParts.h"
michael@0 16 #include "SkPathEffect.h"
michael@0 17 #include "SkCornerPathEffect.h"
michael@0 18
michael@0 19 #include "SkDashPathEffect.h"
michael@0 20
michael@0 21 class SkDrawShapePathEffect : public SkDrawPathEffect {
michael@0 22 DECLARE_PRIVATE_MEMBER_INFO(DrawShapePathEffect);
michael@0 23 SkDrawShapePathEffect();
michael@0 24 virtual ~SkDrawShapePathEffect();
michael@0 25 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE;
michael@0 26 virtual SkPathEffect* getPathEffect();
michael@0 27 protected:
michael@0 28 SkDrawable* addPath;
michael@0 29 SkDrawable* addMatrix;
michael@0 30 SkDrawPath* path;
michael@0 31 SkPathEffect* fPathEffect;
michael@0 32 friend class SkShape1DPathEffect;
michael@0 33 friend class SkShape2DPathEffect;
michael@0 34 };
michael@0 35
michael@0 36 class SkDrawShape1DPathEffect : public SkDrawShapePathEffect {
michael@0 37 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape1DPathEffect);
michael@0 38 SkDrawShape1DPathEffect(SkDisplayTypes );
michael@0 39 virtual ~SkDrawShape1DPathEffect();
michael@0 40 virtual void onEndElement(SkAnimateMaker& );
michael@0 41 private:
michael@0 42 SkString phase;
michael@0 43 SkString spacing;
michael@0 44 friend class SkShape1DPathEffect;
michael@0 45 typedef SkDrawShapePathEffect INHERITED;
michael@0 46 };
michael@0 47
michael@0 48 class SkDrawShape2DPathEffect : public SkDrawShapePathEffect {
michael@0 49 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape2DPathEffect);
michael@0 50 SkDrawShape2DPathEffect(SkDisplayTypes );
michael@0 51 virtual ~SkDrawShape2DPathEffect();
michael@0 52 virtual void onEndElement(SkAnimateMaker& );
michael@0 53 private:
michael@0 54 SkDrawMatrix* matrix;
michael@0 55 friend class SkShape2DPathEffect;
michael@0 56 typedef SkDrawShapePathEffect INHERITED;
michael@0 57 };
michael@0 58
michael@0 59 class SkDrawComposePathEffect : public SkDrawPathEffect {
michael@0 60 DECLARE_EXTRAS_MEMBER_INFO(SkDrawComposePathEffect);
michael@0 61 SkDrawComposePathEffect(SkDisplayTypes );
michael@0 62 virtual ~SkDrawComposePathEffect();
michael@0 63 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE;
michael@0 64 virtual SkPathEffect* getPathEffect();
michael@0 65 virtual bool isPaint() const;
michael@0 66 private:
michael@0 67 SkDrawPathEffect* effect1;
michael@0 68 SkDrawPathEffect* effect2;
michael@0 69 };
michael@0 70
michael@0 71 class SkDrawCornerPathEffect : public SkDrawPathEffect {
michael@0 72 DECLARE_EXTRAS_MEMBER_INFO(SkDrawCornerPathEffect);
michael@0 73 SkDrawCornerPathEffect(SkDisplayTypes );
michael@0 74 virtual ~SkDrawCornerPathEffect();
michael@0 75 virtual SkPathEffect* getPathEffect();
michael@0 76 private:
michael@0 77 SkScalar radius;
michael@0 78 };
michael@0 79
michael@0 80 //////////// SkShape1DPathEffect
michael@0 81
michael@0 82 #include "SkAnimateMaker.h"
michael@0 83 #include "SkAnimatorScript.h"
michael@0 84 #include "SkDisplayApply.h"
michael@0 85 #include "SkDrawMatrix.h"
michael@0 86 #include "SkPaint.h"
michael@0 87
michael@0 88 class SkShape1DPathEffect : public Sk1DPathEffect {
michael@0 89 public:
michael@0 90 SkShape1DPathEffect(SkDrawShape1DPathEffect* draw, SkAnimateMaker* maker) :
michael@0 91 fDraw(draw), fMaker(maker) {
michael@0 92 }
michael@0 93
michael@0 94 SK_DECLARE_UNFLATTENABLE_OBJECT()
michael@0 95
michael@0 96 protected:
michael@0 97 virtual SkScalar begin(SkScalar contourLength) const {
michael@0 98 SkScriptValue value;
michael@0 99 SkAnimatorScript engine(*fMaker, NULL, SkType_Float);
michael@0 100 engine.propertyCallBack(GetContourLength, &contourLength);
michael@0 101 value.fOperand.fScalar = 0;
michael@0 102 engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float);
michael@0 103 return value.fOperand.fScalar;
michael@0 104 }
michael@0 105
michael@0 106 virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const {
michael@0 107 fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance);
michael@0 108 SkDrawPath* drawPath = NULL;
michael@0 109 if (fDraw->addPath->isPath()) {
michael@0 110 drawPath = (SkDrawPath*) fDraw->addPath;
michael@0 111 } else {
michael@0 112 SkApply* apply = (SkApply*) fDraw->addPath;
michael@0 113 apply->refresh(*fMaker);
michael@0 114 apply->activate(*fMaker);
michael@0 115 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
michael@0 116 drawPath = (SkDrawPath*) apply->getScope();
michael@0 117 }
michael@0 118 SkMatrix m;
michael@0 119 m.reset();
michael@0 120 if (fDraw->addMatrix) {
michael@0 121 SkDrawMatrix* matrix;
michael@0 122 if (fDraw->addMatrix->getType() == SkType_Matrix)
michael@0 123 matrix = (SkDrawMatrix*) fDraw->addMatrix;
michael@0 124 else {
michael@0 125 SkApply* apply = (SkApply*) fDraw->addMatrix;
michael@0 126 apply->refresh(*fMaker);
michael@0 127 apply->activate(*fMaker);
michael@0 128 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
michael@0 129 matrix = (SkDrawMatrix*) apply->getScope();
michael@0 130 }
michael@0 131 if (matrix) {
michael@0 132 m = matrix->getMatrix();
michael@0 133 }
michael@0 134 }
michael@0 135 SkScalar result = 0;
michael@0 136 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), &result);
michael@0 137 if (drawPath)
michael@0 138 dst->addPath(drawPath->getPath(), m);
michael@0 139 fMaker->clearExtraPropertyCallBack(fDraw->fType);
michael@0 140 return result;
michael@0 141 }
michael@0 142
michael@0 143 private:
michael@0 144 static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
michael@0 145 if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
michael@0 146 value->fOperand.fScalar = *(SkScalar*) clen;
michael@0 147 value->fType = SkType_Float;
michael@0 148 return true;
michael@0 149 }
michael@0 150 return false;
michael@0 151 }
michael@0 152
michael@0 153 static bool GetDistance(const char* token, size_t len, void* dist, SkScriptValue* value) {
michael@0 154 if (SK_LITERAL_STR_EQUAL("distance", token, len)) {
michael@0 155 value->fOperand.fScalar = *(SkScalar*) dist;
michael@0 156 value->fType = SkType_Float;
michael@0 157 return true;
michael@0 158 }
michael@0 159 return false;
michael@0 160 }
michael@0 161
michael@0 162 SkDrawShape1DPathEffect* fDraw;
michael@0 163 SkAnimateMaker* fMaker;
michael@0 164 };
michael@0 165
michael@0 166 //////////// SkDrawShapePathEffect
michael@0 167
michael@0 168 #if SK_USE_CONDENSED_INFO == 0
michael@0 169
michael@0 170 const SkMemberInfo SkDrawShapePathEffect::fInfo[] = {
michael@0 171 SK_MEMBER(addMatrix, Drawable), // either matrix or apply
michael@0 172 SK_MEMBER(addPath, Drawable), // either path or apply
michael@0 173 SK_MEMBER(path, Path),
michael@0 174 };
michael@0 175
michael@0 176 #endif
michael@0 177
michael@0 178 DEFINE_GET_MEMBER(SkDrawShapePathEffect);
michael@0 179
michael@0 180 SkDrawShapePathEffect::SkDrawShapePathEffect() :
michael@0 181 addPath(NULL), addMatrix(NULL), path(NULL), fPathEffect(NULL) {
michael@0 182 }
michael@0 183
michael@0 184 SkDrawShapePathEffect::~SkDrawShapePathEffect() {
michael@0 185 SkSafeUnref(fPathEffect);
michael@0 186 }
michael@0 187
michael@0 188 bool SkDrawShapePathEffect::addChild(SkAnimateMaker& , SkDisplayable* child) {
michael@0 189 path = (SkDrawPath*) child;
michael@0 190 return true;
michael@0 191 }
michael@0 192
michael@0 193 SkPathEffect* SkDrawShapePathEffect::getPathEffect() {
michael@0 194 fPathEffect->ref();
michael@0 195 return fPathEffect;
michael@0 196 }
michael@0 197
michael@0 198 //////////// SkDrawShape1DPathEffect
michael@0 199
michael@0 200 #if SK_USE_CONDENSED_INFO == 0
michael@0 201
michael@0 202 const SkMemberInfo SkDrawShape1DPathEffect::fInfo[] = {
michael@0 203 SK_MEMBER_INHERITED,
michael@0 204 SK_MEMBER(phase, String),
michael@0 205 SK_MEMBER(spacing, String),
michael@0 206 };
michael@0 207
michael@0 208 #endif
michael@0 209
michael@0 210 DEFINE_GET_MEMBER(SkDrawShape1DPathEffect);
michael@0 211
michael@0 212 SkDrawShape1DPathEffect::SkDrawShape1DPathEffect(SkDisplayTypes type) : fType(type) {
michael@0 213 }
michael@0 214
michael@0 215 SkDrawShape1DPathEffect::~SkDrawShape1DPathEffect() {
michael@0 216 }
michael@0 217
michael@0 218 void SkDrawShape1DPathEffect::onEndElement(SkAnimateMaker& maker) {
michael@0 219 if (addPath == NULL || (addPath->isPath() == false && addPath->isApply() == false))
michael@0 220 maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
michael@0 221 else
michael@0 222 fPathEffect = new SkShape1DPathEffect(this, &maker);
michael@0 223 }
michael@0 224
michael@0 225 ////////// SkShape2DPathEffect
michael@0 226
michael@0 227 class SkShape2DPathEffect : public Sk2DPathEffect {
michael@0 228 public:
michael@0 229 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
michael@0 230 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
michael@0 231 }
michael@0 232
michael@0 233 protected:
michael@0 234 virtual void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE {
michael@0 235 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds);
michael@0 236 }
michael@0 237
michael@0 238 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const SK_OVERRIDE {
michael@0 239 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst);
michael@0 240 }
michael@0 241
michael@0 242 private:
michael@0 243 void setUVBounds(const SkIRect& uvBounds) {
michael@0 244 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop),
michael@0 245 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom));
michael@0 246 }
michael@0 247
michael@0 248 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) {
michael@0 249 fLoc = loc;
michael@0 250 fU = u;
michael@0 251 fV = v;
michael@0 252 SkDrawPath* drawPath;
michael@0 253 fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this);
michael@0 254 if (fDraw->addPath->isPath()) {
michael@0 255 drawPath = (SkDrawPath*) fDraw->addPath;
michael@0 256 } else {
michael@0 257 SkApply* apply = (SkApply*) fDraw->addPath;
michael@0 258 apply->refresh(*fMaker);
michael@0 259 apply->activate(*fMaker);
michael@0 260 apply->interpolate(*fMaker, v);
michael@0 261 drawPath = (SkDrawPath*) apply->getScope();
michael@0 262 }
michael@0 263 if (drawPath == NULL)
michael@0 264 goto clearCallBack;
michael@0 265 if (fDraw->matrix) {
michael@0 266 SkDrawMatrix* matrix;
michael@0 267 if (fDraw->matrix->getType() == SkType_Matrix)
michael@0 268 matrix = (SkDrawMatrix*) fDraw->matrix;
michael@0 269 else {
michael@0 270 SkApply* apply = (SkApply*) fDraw->matrix;
michael@0 271 apply->activate(*fMaker);
michael@0 272 apply->interpolate(*fMaker, v);
michael@0 273 matrix = (SkDrawMatrix*) apply->getScope();
michael@0 274 }
michael@0 275 if (matrix) {
michael@0 276 dst->addPath(drawPath->getPath(), matrix->getMatrix());
michael@0 277 goto clearCallBack;
michael@0 278 }
michael@0 279 }
michael@0 280 dst->addPath(drawPath->getPath());
michael@0 281 clearCallBack:
michael@0 282 fMaker->clearExtraPropertyCallBack(fDraw->fType);
michael@0 283 }
michael@0 284
michael@0 285 static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* value) {
michael@0 286 static const char match[] = "locX|locY|left|top|right|bottom|u|v" ;
michael@0 287 SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D;
michael@0 288 int index;
michael@0 289 if (SkAnimatorScript::MapEnums(match, token, len, &index) == false)
michael@0 290 return false;
michael@0 291 SkASSERT((sizeof(SkPoint) + sizeof(SkRect)) / sizeof(SkScalar) == 6);
michael@0 292 if (index < 6) {
michael@0 293 value->fType = SkType_Float;
michael@0 294 value->fOperand.fScalar = (&shape2D->fLoc.fX)[index];
michael@0 295 } else {
michael@0 296 value->fType = SkType_Int;
michael@0 297 value->fOperand.fS32 = (&shape2D->fU)[index - 6];
michael@0 298 }
michael@0 299 return true;
michael@0 300 }
michael@0 301
michael@0 302 SkPoint fLoc;
michael@0 303 SkRect fUVBounds;
michael@0 304 int32_t fU;
michael@0 305 int32_t fV;
michael@0 306 SkDrawShape2DPathEffect* fDraw;
michael@0 307 SkAnimateMaker* fMaker;
michael@0 308
michael@0 309 // illegal
michael@0 310 SkShape2DPathEffect(const SkShape2DPathEffect&);
michael@0 311 SkShape2DPathEffect& operator=(const SkShape2DPathEffect&);
michael@0 312 };
michael@0 313
michael@0 314 ////////// SkDrawShape2DPathEffect
michael@0 315
michael@0 316 #if SK_USE_CONDENSED_INFO == 0
michael@0 317
michael@0 318 const SkMemberInfo SkDrawShape2DPathEffect::fInfo[] = {
michael@0 319 SK_MEMBER_INHERITED,
michael@0 320 SK_MEMBER(matrix, Matrix)
michael@0 321 };
michael@0 322
michael@0 323 #endif
michael@0 324
michael@0 325 DEFINE_GET_MEMBER(SkDrawShape2DPathEffect);
michael@0 326
michael@0 327 SkDrawShape2DPathEffect::SkDrawShape2DPathEffect(SkDisplayTypes type) : fType(type) {
michael@0 328 }
michael@0 329
michael@0 330 SkDrawShape2DPathEffect::~SkDrawShape2DPathEffect() {
michael@0 331 }
michael@0 332
michael@0 333 void SkDrawShape2DPathEffect::onEndElement(SkAnimateMaker& maker) {
michael@0 334 if (addPath == NULL || (addPath->isPath() == false && addPath->isApply() == false) ||
michael@0 335 matrix == NULL)
michael@0 336 maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
michael@0 337 else
michael@0 338 fPathEffect = new SkShape2DPathEffect(this, &maker, matrix->getMatrix());
michael@0 339 }
michael@0 340
michael@0 341 ////////// SkDrawComposePathEffect
michael@0 342
michael@0 343 #if SK_USE_CONDENSED_INFO == 0
michael@0 344
michael@0 345 const SkMemberInfo SkDrawComposePathEffect::fInfo[] = {
michael@0 346 SK_MEMBER(effect1, PathEffect),
michael@0 347 SK_MEMBER(effect2, PathEffect)
michael@0 348 };
michael@0 349
michael@0 350 #endif
michael@0 351
michael@0 352 DEFINE_GET_MEMBER(SkDrawComposePathEffect);
michael@0 353
michael@0 354 SkDrawComposePathEffect::SkDrawComposePathEffect(SkDisplayTypes type) : fType(type),
michael@0 355 effect1(NULL), effect2(NULL) {
michael@0 356 }
michael@0 357
michael@0 358 SkDrawComposePathEffect::~SkDrawComposePathEffect() {
michael@0 359 delete effect1;
michael@0 360 delete effect2;
michael@0 361 }
michael@0 362
michael@0 363 bool SkDrawComposePathEffect::addChild(SkAnimateMaker& , SkDisplayable* child) {
michael@0 364 if (effect1 == NULL)
michael@0 365 effect1 = (SkDrawPathEffect*) child;
michael@0 366 else
michael@0 367 effect2 = (SkDrawPathEffect*) child;
michael@0 368 return true;
michael@0 369 }
michael@0 370
michael@0 371 SkPathEffect* SkDrawComposePathEffect::getPathEffect() {
michael@0 372 SkPathEffect* e1 = effect1->getPathEffect();
michael@0 373 SkPathEffect* e2 = effect2->getPathEffect();
michael@0 374 SkPathEffect* composite = SkComposePathEffect::Create(e1, e2);
michael@0 375 e1->unref();
michael@0 376 e2->unref();
michael@0 377 return composite;
michael@0 378 }
michael@0 379
michael@0 380 bool SkDrawComposePathEffect::isPaint() const {
michael@0 381 return true;
michael@0 382 }
michael@0 383
michael@0 384 //////////// SkDrawCornerPathEffect
michael@0 385
michael@0 386 #if SK_USE_CONDENSED_INFO == 0
michael@0 387
michael@0 388 const SkMemberInfo SkDrawCornerPathEffect::fInfo[] = {
michael@0 389 SK_MEMBER(radius, Float)
michael@0 390 };
michael@0 391
michael@0 392 #endif
michael@0 393
michael@0 394 DEFINE_GET_MEMBER(SkDrawCornerPathEffect);
michael@0 395
michael@0 396 SkDrawCornerPathEffect::SkDrawCornerPathEffect(SkDisplayTypes type):
michael@0 397 fType(type), radius(0) {
michael@0 398 }
michael@0 399
michael@0 400 SkDrawCornerPathEffect::~SkDrawCornerPathEffect() {
michael@0 401 }
michael@0 402
michael@0 403 SkPathEffect* SkDrawCornerPathEffect::getPathEffect() {
michael@0 404 return SkCornerPathEffect::Create(radius);
michael@0 405 }
michael@0 406
michael@0 407 /////////
michael@0 408
michael@0 409 #include "SkExtras.h"
michael@0 410
michael@0 411 const char kDrawShape1DPathEffectName[] = "pathEffect:shape1D";
michael@0 412 const char kDrawShape2DPathEffectName[] = "pathEffect:shape2D";
michael@0 413 const char kDrawComposePathEffectName[] = "pathEffect:compose";
michael@0 414 const char kDrawCornerPathEffectName[] = "pathEffect:corner";
michael@0 415
michael@0 416 class SkExtraPathEffects : public SkExtras {
michael@0 417 public:
michael@0 418 SkExtraPathEffects() :
michael@0 419 skDrawShape1DPathEffectType(SkType_Unknown),
michael@0 420 skDrawShape2DPathEffectType(SkType_Unknown),
michael@0 421 skDrawComposePathEffectType(SkType_Unknown),
michael@0 422 skDrawCornerPathEffectType(SkType_Unknown) {
michael@0 423 }
michael@0 424
michael@0 425 virtual SkDisplayable* createInstance(SkDisplayTypes type) {
michael@0 426 SkDisplayable* result = NULL;
michael@0 427 if (skDrawShape1DPathEffectType == type)
michael@0 428 result = new SkDrawShape1DPathEffect(type);
michael@0 429 else if (skDrawShape2DPathEffectType == type)
michael@0 430 result = new SkDrawShape2DPathEffect(type);
michael@0 431 else if (skDrawComposePathEffectType == type)
michael@0 432 result = new SkDrawComposePathEffect(type);
michael@0 433 else if (skDrawCornerPathEffectType == type)
michael@0 434 result = new SkDrawCornerPathEffect(type);
michael@0 435 return result;
michael@0 436 }
michael@0 437
michael@0 438 virtual bool definesType(SkDisplayTypes type) {
michael@0 439 return type == skDrawShape1DPathEffectType ||
michael@0 440 type == skDrawShape2DPathEffectType ||
michael@0 441 type == skDrawComposePathEffectType ||
michael@0 442 type == skDrawCornerPathEffectType;
michael@0 443 }
michael@0 444
michael@0 445 #if SK_USE_CONDENSED_INFO == 0
michael@0 446 virtual const SkMemberInfo* getMembers(SkDisplayTypes type, int* infoCountPtr) {
michael@0 447 const SkMemberInfo* info = NULL;
michael@0 448 int infoCount = 0;
michael@0 449 if (skDrawShape1DPathEffectType == type) {
michael@0 450 info = SkDrawShape1DPathEffect::fInfo;
michael@0 451 infoCount = SkDrawShape1DPathEffect::fInfoCount;
michael@0 452 } else if (skDrawShape2DPathEffectType == type) {
michael@0 453 info = SkDrawShape2DPathEffect::fInfo;
michael@0 454 infoCount = SkDrawShape2DPathEffect::fInfoCount;
michael@0 455 } else if (skDrawComposePathEffectType == type) {
michael@0 456 info = SkDrawComposePathEffect::fInfo;
michael@0 457 infoCount = SkDrawShape1DPathEffect::fInfoCount;
michael@0 458 } else if (skDrawCornerPathEffectType == type) {
michael@0 459 info = SkDrawCornerPathEffect::fInfo;
michael@0 460 infoCount = SkDrawCornerPathEffect::fInfoCount;
michael@0 461 }
michael@0 462 if (infoCountPtr)
michael@0 463 *infoCountPtr = infoCount;
michael@0 464 return info;
michael@0 465 }
michael@0 466 #endif
michael@0 467
michael@0 468 #ifdef SK_DEBUG
michael@0 469 virtual const char* getName(SkDisplayTypes type) {
michael@0 470 if (skDrawShape1DPathEffectType == type)
michael@0 471 return kDrawShape1DPathEffectName;
michael@0 472 else if (skDrawShape2DPathEffectType == type)
michael@0 473 return kDrawShape2DPathEffectName;
michael@0 474 else if (skDrawComposePathEffectType == type)
michael@0 475 return kDrawComposePathEffectName;
michael@0 476 else if (skDrawCornerPathEffectType == type)
michael@0 477 return kDrawCornerPathEffectName;
michael@0 478 return NULL;
michael@0 479 }
michael@0 480 #endif
michael@0 481
michael@0 482 virtual SkDisplayTypes getType(const char name[], size_t len ) {
michael@0 483 SkDisplayTypes* type = NULL;
michael@0 484 if (SK_LITERAL_STR_EQUAL(kDrawShape1DPathEffectName, name, len))
michael@0 485 type = &skDrawShape1DPathEffectType;
michael@0 486 else if (SK_LITERAL_STR_EQUAL(kDrawShape2DPathEffectName, name, len))
michael@0 487 type = &skDrawShape2DPathEffectType;
michael@0 488 else if (SK_LITERAL_STR_EQUAL(kDrawComposePathEffectName, name, len))
michael@0 489 type = &skDrawComposePathEffectType;
michael@0 490 else if (SK_LITERAL_STR_EQUAL(kDrawCornerPathEffectName, name, len))
michael@0 491 type = &skDrawCornerPathEffectType;
michael@0 492 if (type) {
michael@0 493 if (*type == SkType_Unknown)
michael@0 494 *type = SkDisplayType::RegisterNewType();
michael@0 495 return *type;
michael@0 496 }
michael@0 497 return SkType_Unknown;
michael@0 498 }
michael@0 499
michael@0 500 private:
michael@0 501 SkDisplayTypes skDrawShape1DPathEffectType;
michael@0 502 SkDisplayTypes skDrawShape2DPathEffectType;
michael@0 503 SkDisplayTypes skDrawComposePathEffectType;
michael@0 504 SkDisplayTypes skDrawCornerPathEffectType;
michael@0 505 };
michael@0 506
michael@0 507 void InitializeSkExtraPathEffects(SkAnimator* animator) {
michael@0 508 animator->addExtras(new SkExtraPathEffects());
michael@0 509 }
michael@0 510
michael@0 511 ////////////////
michael@0 512
michael@0 513
michael@0 514 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) {
michael@0 515 }

mercurial