| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkScript2.h" | 8 #include "SkScript2.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkFloatingPoint.h" | 10 #include "SkFloatingPoint.h" |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 switch (op) { | 977 switch (op) { |
| 978 case kParen: | 978 case kParen: |
| 979 case kArrayOp: | 979 case kArrayOp: |
| 980 SkASSERT(fOpStack.count() > 1 && fOpStack.top() == op); // !!! ad
d error handling | 980 SkASSERT(fOpStack.count() > 1 && fOpStack.top() == op); // !!! ad
d error handling |
| 981 if (op == kParen) | 981 if (op == kParen) |
| 982 fOpStack.pop(); | 982 fOpStack.pop(); |
| 983 else { | 983 else { |
| 984 SkScriptValue2 value; | 984 SkScriptValue2 value; |
| 985 fValueStack.pop(&value); | 985 fValueStack.pop(&value); |
| 986 SkASSERT(value.fType == SkOperand2::kS32 || value.fType == SkOpe
rand2::kScalar); // !!! add error handling (although, could permit strings event
ually) | 986 SkASSERT(value.fType == SkOperand2::kS32 || value.fType == SkOpe
rand2::kScalar); // !!! add error handling (although, could permit strings event
ually) |
| 987 int index = value.fType == SkOperand2::kScalar ? SkScalarFloor(v
alue.fOperand.fScalar) : | 987 int index = value.fType == SkOperand2::kScalar ? SkScalarFloorTo
Int(value.fOperand.fScalar) : |
| 988 value.fOperand.fS32; | 988 value.fOperand.fS32; |
| 989 SkScriptValue2 arrayValue; | 989 SkScriptValue2 arrayValue; |
| 990 fValueStack.pop(&arrayValue); | 990 fValueStack.pop(&arrayValue); |
| 991 SkASSERT(arrayValue.fType == SkOperand2::kArray); // !!! add er
ror handling | 991 SkASSERT(arrayValue.fType == SkOperand2::kArray); // !!! add er
ror handling |
| 992 SkOpArray* array = arrayValue.fOperand.fArray; | 992 SkOpArray* array = arrayValue.fOperand.fArray; |
| 993 SkOperand2 operand; | 993 SkOperand2 operand; |
| 994 SkDEBUGCODE(bool success = ) array->getIndex(index, &operand); | 994 SkDEBUGCODE(bool success = ) array->getIndex(index, &operand); |
| 995 SkASSERT(success); // !!! add error handling | 995 SkASSERT(success); // !!! add error handling |
| 996 SkScriptValue2 resultValue; | 996 SkScriptValue2 resultValue; |
| 997 resultValue.fType = array->getType(); | 997 resultValue.fType = array->getType(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 bool SkScriptEngine2::ConvertTo(SkScriptEngine2* engine, SkOperand2::OpType toTy
pe, SkScriptValue2* value ) { | 1193 bool SkScriptEngine2::ConvertTo(SkScriptEngine2* engine, SkOperand2::OpType toTy
pe, SkScriptValue2* value ) { |
| 1194 SkASSERT(value); | 1194 SkASSERT(value); |
| 1195 SkOperand2::OpType type = value->fType; | 1195 SkOperand2::OpType type = value->fType; |
| 1196 if (type == toType) | 1196 if (type == toType) |
| 1197 return true; | 1197 return true; |
| 1198 SkOperand2& operand = value->fOperand; | 1198 SkOperand2& operand = value->fOperand; |
| 1199 bool success = true; | 1199 bool success = true; |
| 1200 switch (toType) { | 1200 switch (toType) { |
| 1201 case SkOperand2::kS32: | 1201 case SkOperand2::kS32: |
| 1202 if (type == SkOperand2::kScalar) | 1202 if (type == SkOperand2::kScalar) |
| 1203 operand.fS32 = SkScalarFloor(operand.fScalar); | 1203 operand.fS32 = SkScalarFloorToInt(operand.fScalar); |
| 1204 else { | 1204 else { |
| 1205 SkASSERT(type == SkOperand2::kString); | 1205 SkASSERT(type == SkOperand2::kString); |
| 1206 success = SkParse::FindS32(operand.fString->c_str(), &operand.fS
32) != NULL; | 1206 success = SkParse::FindS32(operand.fString->c_str(), &operand.fS
32) != NULL; |
| 1207 } | 1207 } |
| 1208 break; | 1208 break; |
| 1209 case SkOperand2::kScalar: | 1209 case SkOperand2::kScalar: |
| 1210 if (type == SkOperand2::kS32) | 1210 if (type == SkOperand2::kS32) |
| 1211 operand.fScalar = IntToScalar(operand.fS32); | 1211 operand.fScalar = IntToScalar(operand.fS32); |
| 1212 else { | 1212 else { |
| 1213 SkASSERT(type == SkOperand2::kString); | 1213 SkASSERT(type == SkOperand2::kString); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 case SkOperand2::kString: | 1497 case SkOperand2::kString: |
| 1498 SkASSERT(value.fOperand.fString->equals(scriptTests[index].fStri
ngAnswer)); | 1498 SkASSERT(value.fOperand.fString->equals(scriptTests[index].fStri
ngAnswer)); |
| 1499 break; | 1499 break; |
| 1500 default: | 1500 default: |
| 1501 SkASSERT(0); | 1501 SkASSERT(0); |
| 1502 } | 1502 } |
| 1503 } | 1503 } |
| 1504 #endif // SK_SUPPORT_UNITTEST | 1504 #endif // SK_SUPPORT_UNITTEST |
| 1505 } | 1505 } |
| 1506 #endif // SK_DEBUG | 1506 #endif // SK_DEBUG |
| OLD | NEW |