Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/xml/SkJSDisplayable.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 8
9 9
10 #include <jsapi.h> 10 #include <jsapi.h>
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 *vp = BOOLEAN_TO_JSVAL(s32); 270 *vp = BOOLEAN_TO_JSVAL(s32);
271 break; 271 break;
272 case SkType_Color: 272 case SkType_Color:
273 case SkType_S32: 273 case SkType_S32:
274 *vp = INT_TO_JSVAL(s32); 274 *vp = INT_TO_JSVAL(s32);
275 break; 275 break;
276 case SkType_Scalar: 276 case SkType_Scalar:
277 if (SkScalarFraction(scalar) == 0) 277 if (SkScalarFraction(scalar) == 0)
278 *vp = INT_TO_JSVAL(SkScalarFloor(scalar)); 278 *vp = INT_TO_JSVAL(SkScalarFloor(scalar));
279 else 279 else
280 #ifdef SK_SCALAR_IS_FLOAT
281 *vp = DOUBLE_TO_JSVAL(scalar); 280 *vp = DOUBLE_TO_JSVAL(scalar);
282 #else
283 *vp = DOUBLE_TO_JSVAL(scalar / 65536.0f );
284 #endif
285 break; 281 break;
286 case SkType_String: 282 case SkType_String:
287 str = JS_NewStringCopyN(cx, string->c_str(), string->size()); 283 str = JS_NewStringCopyN(cx, string->c_str(), string->size());
288 *vp = STRING_TO_JSVAL(str); 284 *vp = STRING_TO_JSVAL(str);
289 break; 285 break;
290 default: 286 default:
291 SkASSERT(0); // !!! unimplemented 287 SkASSERT(0); // !!! unimplemented
292 } 288 }
293 return JS_TRUE; 289 return JS_TRUE;
294 } 290 }
(...skipping 21 matching lines...) Expand all
316 break; 312 break;
317 case SkType_Color: 313 case SkType_Color:
318 case SkType_S32: 314 case SkType_S32:
319 s32 = JSVAL_TO_INT(value); 315 s32 = JSVAL_TO_INT(value);
320 break; 316 break;
321 case SkType_Scalar: 317 case SkType_Scalar:
322 if (JSVAL_IS_INT(value)) 318 if (JSVAL_IS_INT(value))
323 scalar = SkIntToScalar(JSVAL_TO_INT(value)); 319 scalar = SkIntToScalar(JSVAL_TO_INT(value));
324 else { 320 else {
325 SkASSERT(JSVAL_IS_DOUBLE(value)); 321 SkASSERT(JSVAL_IS_DOUBLE(value));
326 #ifdef SK_SCALAR_IS_FLOAT
327 scalar = (float) *(double*) JSVAL_TO_DOUBLE(value); 322 scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
328 #else
329 scalar = (SkFixed) (*(double*)JSVAL_TO_DOUBLE(value) * 65536.0) ;
330 #endif
331 } 323 }
332 break; 324 break;
333 case SkType_String: 325 case SkType_String:
334 str = JS_ValueToString(cx, value); 326 str = JS_ValueToString(cx, value);
335 string.set(JS_GetStringBytes(str)); 327 string.set(JS_GetStringBytes(str));
336 break; 328 break;
337 default: 329 default:
338 SkASSERT(0); // !!! unimplemented 330 SkASSERT(0); // !!! unimplemented
339 } 331 }
340 if (info->fType == SkType_MemberProperty) { 332 if (info->fType == SkType_MemberProperty) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 443 }
452 444
453 void SkJS::DisposeDisplayables() { 445 void SkJS::DisposeDisplayables() {
454 delete SkJSDisplayable::gPaint; 446 delete SkJSDisplayable::gPaint;
455 delete SkJSDisplayable::gCanvas; 447 delete SkJSDisplayable::gCanvas;
456 for (int index = 0; index < kTypeNamesSize; index++) { 448 for (int index = 0; index < kTypeNamesSize; index++) {
457 SkDisplayTypes type = gTypeNames[index].fType; 449 SkDisplayTypes type = gTypeNames[index].fType;
458 delete[] gDisplayableProperties[type]; 450 delete[] gDisplayableProperties[type];
459 } 451 }
460 } 452 }
OLDNEW
« src/core/SkCanvas.cpp ('K') | « src/utils/SkParsePath.cpp ('k') | src/xml/SkXMLWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698