| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2006 The Android Open Source Project | 2  * Copyright 2006 The Android Open Source Project | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #include "SkDrawPaint.h" | 8 #include "SkDrawPaint.h" | 
| 9 #include "SkAnimateMaker.h" | 9 #include "SkAnimateMaker.h" | 
| 10 #include "SkDrawColor.h" | 10 #include "SkDrawColor.h" | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57     SK_MEMBER(textSkewX, Float), | 57     SK_MEMBER(textSkewX, Float), | 
| 58     SK_MEMBER(typeface, Typeface), | 58     SK_MEMBER(typeface, Typeface), | 
| 59     SK_MEMBER(underline, Boolean), | 59     SK_MEMBER(underline, Boolean), | 
| 60     SK_MEMBER(xfermode, Xfermode) | 60     SK_MEMBER(xfermode, Xfermode) | 
| 61 }; | 61 }; | 
| 62 | 62 | 
| 63 #endif | 63 #endif | 
| 64 | 64 | 
| 65 DEFINE_GET_MEMBER(SkDrawPaint); | 65 DEFINE_GET_MEMBER(SkDrawPaint); | 
| 66 | 66 | 
| 67 SkDrawPaint::SkDrawPaint() : antiAlias(-1), color(NULL), fakeBold(-1), filterBit
     map(-1), | 67 SkDrawPaint::SkDrawPaint() : antiAlias(-1), color(nullptr), fakeBold(-1), filter
     Bitmap(-1), | 
| 68     linearText(-1), maskFilter((SkDrawMaskFilter*) -1), pathEffect((SkDrawPathEf
     fect*) -1), | 68     linearText(-1), maskFilter((SkDrawMaskFilter*) -1), pathEffect((SkDrawPathEf
     fect*) -1), | 
| 69     shader((SkDrawShader*) -1), strikeThru(-1), stroke(-1), | 69     shader((SkDrawShader*) -1), strikeThru(-1), stroke(-1), | 
| 70     strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK
     _ScalarNaN), | 70     strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK
     _ScalarNaN), | 
| 71     strokeWidth(SK_ScalarNaN), style((SkPaint::Style) -1), | 71     strokeWidth(SK_ScalarNaN), style((SkPaint::Style) -1), | 
| 72     textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_Scalar
     NaN), | 72     textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_Scalar
     NaN), | 
| 73     textSkewX(SK_ScalarNaN), typeface((SkDrawTypeface*) -1), | 73     textSkewX(SK_ScalarNaN), typeface((SkDrawTypeface*) -1), | 
| 74     underline(-1), xfermode((SkXfermode::Mode) -1), fOwnsColor(false), fOwnsMask
     Filter(false), | 74     underline(-1), xfermode((SkXfermode::Mode) -1), fOwnsColor(false), fOwnsMask
     Filter(false), | 
| 75     fOwnsPathEffect(false), fOwnsShader(false), fOwnsTypeface(false) { | 75     fOwnsPathEffect(false), fOwnsShader(false), fOwnsTypeface(false) { | 
| 76 } | 76 } | 
| 77 | 77 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 91 bool SkDrawPaint::add(SkAnimateMaker* maker, SkDisplayable* child) { | 91 bool SkDrawPaint::add(SkAnimateMaker* maker, SkDisplayable* child) { | 
| 92     SkASSERT(child && child->isPaintPart()); | 92     SkASSERT(child && child->isPaintPart()); | 
| 93     SkPaintPart* part = (SkPaintPart*) child; | 93     SkPaintPart* part = (SkPaintPart*) child; | 
| 94     if (part->add() && maker) | 94     if (part->add() && maker) | 
| 95         maker->setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); | 95         maker->setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); | 
| 96     return true; | 96     return true; | 
| 97 } | 97 } | 
| 98 | 98 | 
| 99 SkDisplayable* SkDrawPaint::deepCopy(SkAnimateMaker* maker) { | 99 SkDisplayable* SkDrawPaint::deepCopy(SkAnimateMaker* maker) { | 
| 100     SkDrawColor* tempColor = color; | 100     SkDrawColor* tempColor = color; | 
| 101     color = NULL; | 101     color = nullptr; | 
| 102     SkDrawPaint* copy = (SkDrawPaint*) INHERITED::deepCopy(maker); | 102     SkDrawPaint* copy = (SkDrawPaint*) INHERITED::deepCopy(maker); | 
| 103     color = tempColor; | 103     color = tempColor; | 
| 104     tempColor = (SkDrawColor*) color->deepCopy(maker); | 104     tempColor = (SkDrawColor*) color->deepCopy(maker); | 
| 105     tempColor->setParent(copy); | 105     tempColor->setParent(copy); | 
| 106     tempColor->add(); | 106     tempColor->add(); | 
| 107     copy->fOwnsColor = true; | 107     copy->fOwnsColor = true; | 
| 108     return copy; | 108     return copy; | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 bool SkDrawPaint::draw(SkAnimateMaker& maker) { | 111 bool SkDrawPaint::draw(SkAnimateMaker& maker) { | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 141         typeface->dump(maker); | 141         typeface->dump(maker); | 
| 142     } | 142     } | 
| 143     SkDisplayList::fIndent -= 4; | 143     SkDisplayList::fIndent -= 4; | 
| 144     dumpChildren(maker, closedYet); | 144     dumpChildren(maker, closedYet); | 
| 145 } | 145 } | 
| 146 #endif | 146 #endif | 
| 147 | 147 | 
| 148 void SkDrawPaint::executeFunction(SkDisplayable* target, int index, | 148 void SkDrawPaint::executeFunction(SkDisplayable* target, int index, | 
| 149         SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type, | 149         SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type, | 
| 150         SkScriptValue* scriptValue) { | 150         SkScriptValue* scriptValue) { | 
| 151         if (scriptValue == NULL) | 151         if (scriptValue == nullptr) | 
| 152             return; | 152             return; | 
| 153     SkASSERT(target == this); | 153     SkASSERT(target == this); | 
| 154     switch (index) { | 154     switch (index) { | 
| 155         case SK_FUNCTION(measureText): { | 155         case SK_FUNCTION(measureText): { | 
| 156             SkASSERT(parameters.count() == 1); | 156             SkASSERT(parameters.count() == 1); | 
| 157             SkASSERT(type == SkType_Float); | 157             SkASSERT(type == SkType_Float); | 
| 158             SkPaint paint; | 158             SkPaint paint; | 
| 159             setupPaint(&paint); | 159             setupPaint(&paint); | 
| 160             scriptValue->fType = SkType_Float; | 160             scriptValue->fType = SkType_Float; | 
| 161             SkASSERT(parameters[0].fType == SkType_String); | 161             SkASSERT(parameters[0].fType == SkType_String); | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 206     if (fOwnsShader && maker.resolveID(shader, original->shader) == false) | 206     if (fOwnsShader && maker.resolveID(shader, original->shader) == false) | 
| 207         return true; | 207         return true; | 
| 208     if (fOwnsTypeface && maker.resolveID(typeface, original->typeface) == false) | 208     if (fOwnsTypeface && maker.resolveID(typeface, original->typeface) == false) | 
| 209         return true; | 209         return true; | 
| 210     return false; // succeeded | 210     return false; // succeeded | 
| 211 } | 211 } | 
| 212 | 212 | 
| 213 void SkDrawPaint::setupPaint(SkPaint* paint) const { | 213 void SkDrawPaint::setupPaint(SkPaint* paint) const { | 
| 214     if (antiAlias != -1) | 214     if (antiAlias != -1) | 
| 215         paint->setAntiAlias(SkToBool(antiAlias)); | 215         paint->setAntiAlias(SkToBool(antiAlias)); | 
| 216     if (color != NULL) | 216     if (color != nullptr) | 
| 217         paint->setColor(color->getColor()); | 217         paint->setColor(color->getColor()); | 
| 218     if (fakeBold != -1) | 218     if (fakeBold != -1) | 
| 219         paint->setFakeBoldText(SkToBool(fakeBold)); | 219         paint->setFakeBoldText(SkToBool(fakeBold)); | 
| 220     if (filterBitmap != -1) | 220     if (filterBitmap != -1) | 
| 221         paint->setFilterQuality(filterBitmap ? kLow_SkFilterQuality : kNone_SkFi
     lterQuality); | 221         paint->setFilterQuality(filterBitmap ? kLow_SkFilterQuality : kNone_SkFi
     lterQuality); | 
| 222     //  stroke is legacy; style setting if present overrides stroke | 222     //  stroke is legacy; style setting if present overrides stroke | 
| 223     if (stroke != -1) | 223     if (stroke != -1) | 
| 224         paint->setStyle(SkToBool(stroke) ? SkPaint::kStroke_Style : SkPaint::kFi
     ll_Style); | 224         paint->setStyle(SkToBool(stroke) ? SkPaint::kStroke_Style : SkPaint::kFi
     ll_Style); | 
| 225     if (style != -1) | 225     if (style != -1) | 
| 226         paint->setStyle((SkPaint::Style) style); | 226         paint->setStyle((SkPaint::Style) style); | 
| 227     if (linearText != -1) | 227     if (linearText != -1) | 
| 228         paint->setLinearText(SkToBool(linearText)); | 228         paint->setLinearText(SkToBool(linearText)); | 
| 229     if (maskFilter == NULL) | 229     if (maskFilter == nullptr) | 
| 230         paint->setMaskFilter(NULL); | 230         paint->setMaskFilter(nullptr); | 
| 231     else if (maskFilter != (SkDrawMaskFilter*) -1) | 231     else if (maskFilter != (SkDrawMaskFilter*) -1) | 
| 232         SkSafeUnref(paint->setMaskFilter(maskFilter->getMaskFilter())); | 232         SkSafeUnref(paint->setMaskFilter(maskFilter->getMaskFilter())); | 
| 233     if (pathEffect == NULL) | 233     if (pathEffect == nullptr) | 
| 234         paint->setPathEffect(NULL); | 234         paint->setPathEffect(nullptr); | 
| 235     else if (pathEffect != (SkDrawPathEffect*) -1) | 235     else if (pathEffect != (SkDrawPathEffect*) -1) | 
| 236         SkSafeUnref(paint->setPathEffect(pathEffect->getPathEffect())); | 236         SkSafeUnref(paint->setPathEffect(pathEffect->getPathEffect())); | 
| 237     if (shader == NULL) | 237     if (shader == nullptr) | 
| 238         paint->setShader(NULL); | 238         paint->setShader(nullptr); | 
| 239     else if (shader != (SkDrawShader*) -1) | 239     else if (shader != (SkDrawShader*) -1) | 
| 240         SkSafeUnref(paint->setShader(shader->getShader())); | 240         SkSafeUnref(paint->setShader(shader->getShader())); | 
| 241     if (strikeThru != -1) | 241     if (strikeThru != -1) | 
| 242         paint->setStrikeThruText(SkToBool(strikeThru)); | 242         paint->setStrikeThruText(SkToBool(strikeThru)); | 
| 243     if (strokeCap != -1) | 243     if (strokeCap != -1) | 
| 244         paint->setStrokeCap((SkPaint::Cap) strokeCap); | 244         paint->setStrokeCap((SkPaint::Cap) strokeCap); | 
| 245     if (strokeJoin != -1) | 245     if (strokeJoin != -1) | 
| 246         paint->setStrokeJoin((SkPaint::Join) strokeJoin); | 246         paint->setStrokeJoin((SkPaint::Join) strokeJoin); | 
| 247     if (SkScalarIsNaN(strokeMiter) == false) | 247     if (SkScalarIsNaN(strokeMiter) == false) | 
| 248         paint->setStrokeMiter(strokeMiter); | 248         paint->setStrokeMiter(strokeMiter); | 
| 249     if (SkScalarIsNaN(strokeWidth) == false) | 249     if (SkScalarIsNaN(strokeWidth) == false) | 
| 250         paint->setStrokeWidth(strokeWidth); | 250         paint->setStrokeWidth(strokeWidth); | 
| 251     if (textAlign != -1) | 251     if (textAlign != -1) | 
| 252         paint->setTextAlign((SkPaint::Align) textAlign); | 252         paint->setTextAlign((SkPaint::Align) textAlign); | 
| 253     if (SkScalarIsNaN(textScaleX) == false) | 253     if (SkScalarIsNaN(textScaleX) == false) | 
| 254         paint->setTextScaleX(textScaleX); | 254         paint->setTextScaleX(textScaleX); | 
| 255     if (SkScalarIsNaN(textSize) == false) | 255     if (SkScalarIsNaN(textSize) == false) | 
| 256         paint->setTextSize(textSize); | 256         paint->setTextSize(textSize); | 
| 257     if (SkScalarIsNaN(textSkewX) == false) | 257     if (SkScalarIsNaN(textSkewX) == false) | 
| 258         paint->setTextSkewX(textSkewX); | 258         paint->setTextSkewX(textSkewX); | 
| 259     if (typeface == NULL) | 259     if (typeface == nullptr) | 
| 260         paint->setTypeface(NULL); | 260         paint->setTypeface(nullptr); | 
| 261     else if (typeface != (SkDrawTypeface*) -1) | 261     else if (typeface != (SkDrawTypeface*) -1) | 
| 262         SkSafeUnref(paint->setTypeface(typeface->getTypeface())); | 262         SkSafeUnref(paint->setTypeface(typeface->getTypeface())); | 
| 263     if (underline != -1) | 263     if (underline != -1) | 
| 264         paint->setUnderlineText(SkToBool(underline)); | 264         paint->setUnderlineText(SkToBool(underline)); | 
| 265     if (xfermode != -1) | 265     if (xfermode != -1) | 
| 266         paint->setXfermodeMode((SkXfermode::Mode) xfermode); | 266         paint->setXfermodeMode((SkXfermode::Mode) xfermode); | 
| 267 } | 267 } | 
| OLD | NEW | 
|---|