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

Side by Side Diff: src/animator/SkMemberInfo.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 months 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
« no previous file with comments | « src/animator/SkMemberInfo.h ('k') | src/animator/SkOperandIterpolator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkMemberInfo.h" 10 #include "SkMemberInfo.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 size_t SkMemberInfo::getSize(const SkDisplayable* displayable) const { 100 size_t SkMemberInfo::getSize(const SkDisplayable* displayable) const {
101 size_t byteSize; 101 size_t byteSize;
102 switch (fType) { 102 switch (fType) {
103 case SkType_MemberProperty: 103 case SkType_MemberProperty:
104 byteSize = GetSize(propertyType()); 104 byteSize = GetSize(propertyType());
105 break; 105 break;
106 case SkType_Array: { 106 case SkType_Array: {
107 SkDisplayTypes type; 107 SkDisplayTypes type;
108 if (displayable == NULL) 108 if (displayable == nullptr)
109 return sizeof(int); 109 return sizeof(int);
110 if (displayable->getType() == SkType_Array) { 110 if (displayable->getType() == SkType_Array) {
111 SkDisplayArray* dispArray = (SkDisplayArray*) displayable; 111 SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
112 type = dispArray->values.getType(); 112 type = dispArray->values.getType();
113 } else 113 } else
114 type = propertyType(); 114 type = propertyType();
115 SkTDOperandArray* array = (SkTDOperandArray*) memberData(displayable ); 115 SkTDOperandArray* array = (SkTDOperandArray*) memberData(displayable );
116 byteSize = GetSize(type) * array->count(); 116 byteSize = GetSize(type) * array->count();
117 } break; 117 } break;
118 default: 118 default:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayType s outType, 184 int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayType s outType,
185 const char rawValue[], size_t rawValueLen) const 185 const char rawValue[], size_t rawValueLen) const
186 { 186 {
187 SkString valueStr(rawValue, rawValueLen); 187 SkString valueStr(rawValue, rawValueLen);
188 SkScriptValue scriptValue; 188 SkScriptValue scriptValue;
189 scriptValue.fType = SkType_Unknown; 189 scriptValue.fType = SkType_Unknown;
190 scriptValue.fOperand.fS32 = 0; 190 scriptValue.fOperand.fS32 = 0;
191 SkDisplayTypes type = getType(); 191 SkDisplayTypes type = getType();
192 SkAnimatorScript engine(maker, displayable, type); 192 SkAnimatorScript engine(maker, displayable, type);
193 if (arrayStorage) 193 if (arrayStorage)
194 displayable = NULL; 194 displayable = nullptr;
195 bool success = true; 195 bool success = true;
196 void* untypedStorage = NULL; 196 void* untypedStorage = nullptr;
197 if (displayable && fType != SkType_MemberProperty && fType != SkType_MemberF unction) 197 if (displayable && fType != SkType_MemberProperty && fType != SkType_MemberF unction)
198 untypedStorage = (SkTDOperandArray*) memberData(displayable); 198 untypedStorage = (SkTDOperandArray*) memberData(displayable);
199 199
200 if (type == SkType_ARGB) { 200 if (type == SkType_ARGB) {
201 // for both SpiderMonkey and SkiaScript, substitute any #xyz or #xxyyzz first 201 // for both SpiderMonkey and SkiaScript, substitute any #xyz or #xxyyzz first
202 // it's enough to expand the colors into 0xFFxxyyzz 202 // it's enough to expand the colors into 0xFFxxyyzz
203 const char* poundPos; 203 const char* poundPos;
204 while ((poundPos = strchr(valueStr.c_str(), '#')) != NULL) { 204 while ((poundPos = strchr(valueStr.c_str(), '#')) != nullptr) {
205 size_t offset = poundPos - valueStr.c_str(); 205 size_t offset = poundPos - valueStr.c_str();
206 if (valueStr.size() - offset < 4) 206 if (valueStr.size() - offset < 4)
207 break; 207 break;
208 char r = poundPos[1]; 208 char r = poundPos[1];
209 char g = poundPos[2]; 209 char g = poundPos[2];
210 char b = poundPos[3]; 210 char b = poundPos[3];
211 if (is_hex(r) == false || is_hex(g) == false || is_hex(b) == false) 211 if (is_hex(r) == false || is_hex(g) == false || is_hex(b) == false)
212 break; 212 break;
213 char hex = poundPos[4]; 213 char hex = poundPos[4];
214 if (is_hex(hex) == false) { 214 if (is_hex(hex) == false) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const char* script = valueStr.c_str(); 251 const char* script = valueStr.c_str();
252 success = engine.evaluateScript(&script, &scriptValue); 252 success = engine.evaluateScript(&script, &scriptValue);
253 if (success == false) { 253 if (success == false) {
254 maker.setScriptError(engine); 254 maker.setScriptError(engine);
255 return false; 255 return false;
256 } 256 }
257 } 257 }
258 SkASSERT(success); 258 SkASSERT(success);
259 if (scriptValue.fType == SkType_Displayable) { 259 if (scriptValue.fType == SkType_Displayable) {
260 if (type == SkType_String) { 260 if (type == SkType_String) {
261 const char* charPtr = NULL; 261 const char* charPtr = nullptr;
262 maker.findKey(scriptValue.fOperand.fDisplayable, &charPtr); 262 maker.findKey(scriptValue.fOperand.fDisplayable, &charPtr);
263 scriptValue.fOperand.fString = new SkString(charPtr); 263 scriptValue.fOperand.fString = new SkString(charPtr);
264 scriptValue.fType = SkType_String; 264 scriptValue.fType = SkType_String;
265 engine.SkScriptEngine::track(scriptValue.fOperand.fString); 265 engine.SkScriptEngine::track(scriptValue.fOperand.fString);
266 break; 266 break;
267 } 267 }
268 SkASSERT(SkDisplayType::IsDisplayable(&maker, type)); 268 SkASSERT(SkDisplayType::IsDisplayable(&maker, type));
269 if (displayable) 269 if (displayable)
270 displayable->setReference(this, scriptValue.fOperand.fDispla yable); 270 displayable->setReference(this, scriptValue.fOperand.fDispla yable);
271 else 271 else
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 SkString& raw) const { 351 SkString& raw) const {
352 return setValue(maker, arrayStorage, storageOffset, maxStorage, displayable, outType, raw.c_str(), 352 return setValue(maker, arrayStorage, storageOffset, maxStorage, displayable, outType, raw.c_str(),
353 raw.size()); 353 raw.size());
354 } 354 }
355 355
356 bool SkMemberInfo::writeValue(SkDisplayable* displayable, SkTDOperandArray* arra yStorage, 356 bool SkMemberInfo::writeValue(SkDisplayable* displayable, SkTDOperandArray* arra yStorage,
357 int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outT ype, 357 int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outT ype,
358 SkScriptValue& scriptValue) const 358 SkScriptValue& scriptValue) const
359 { 359 {
360 SkOperand* storage = untypedStorage ? (SkOperand*) untypedStorage : arraySto rage ? 360 SkOperand* storage = untypedStorage ? (SkOperand*) untypedStorage : arraySto rage ?
361 arrayStorage->begin() : NULL; 361 arrayStorage->begin() : nullptr;
362 if (storage) 362 if (storage)
363 storage += storageOffset; 363 storage += storageOffset;
364 SkDisplayTypes type = getType(); 364 SkDisplayTypes type = getType();
365 if (fType == SkType_MemberProperty) { 365 if (fType == SkType_MemberProperty) {
366 if(displayable) 366 if(displayable)
367 displayable->setProperty(propertyIndex(), scriptValue); 367 displayable->setProperty(propertyIndex(), scriptValue);
368 else { 368 else {
369 SkASSERT(storageOffset < arrayStorage->count()); 369 SkASSERT(storageOffset < arrayStorage->count());
370 switch (scriptValue.fType) { 370 switch (scriptValue.fType) {
371 case SkType_Boolean: 371 case SkType_Boolean:
372 case SkType_Float: 372 case SkType_Float:
373 case SkType_Int: 373 case SkType_Int:
374 memcpy(&storage->fScalar, &scriptValue.fOperand.fScalar, siz eof(SkScalar)); 374 memcpy(&storage->fScalar, &scriptValue.fOperand.fScalar, siz eof(SkScalar));
375 break; 375 break;
376 case SkType_Array: 376 case SkType_Array:
377 memcpy(&storage->fScalar, scriptValue.fOperand.fArray->begin (), scriptValue.fOperand.fArray->count() * sizeof(SkScalar)); 377 memcpy(&storage->fScalar, scriptValue.fOperand.fArray->begin (), scriptValue.fOperand.fArray->count() * sizeof(SkScalar));
378 break; 378 break;
379 case SkType_String: 379 case SkType_String:
380 storage->fString->set(*scriptValue.fOperand.fString); 380 storage->fString->set(*scriptValue.fOperand.fString);
381 break; 381 break;
382 default: 382 default:
383 SkASSERT(0); // type isn't handled yet 383 SkASSERT(0); // type isn't handled yet
384 } 384 }
385 } 385 }
386 } else if (fType == SkType_MemberFunction) { 386 } else if (fType == SkType_MemberFunction) {
387 SkASSERT(scriptValue.fType == SkType_Array); 387 SkASSERT(scriptValue.fType == SkType_Array);
388 if (displayable) 388 if (displayable)
389 displayable->executeFunction(displayable, this, scriptValue.fOperand .fArray, NULL); 389 displayable->executeFunction(displayable, this, scriptValue.fOperand .fArray, nullptr);
390 else { 390 else {
391 int count = scriptValue.fOperand.fArray->count(); 391 int count = scriptValue.fOperand.fArray->count();
392 // SkASSERT(maxStorage == 0 || count == maxStorage); 392 // SkASSERT(maxStorage == 0 || count == maxStorage);
393 if (arrayStorage->count() == 2) 393 if (arrayStorage->count() == 2)
394 arrayStorage->setCount(2 * count); 394 arrayStorage->setCount(2 * count);
395 else { 395 else {
396 storageOffset *= count; 396 storageOffset *= count;
397 SkASSERT(count + storageOffset <= arrayStorage->count()); 397 SkASSERT(count + storageOffset <= arrayStorage->count());
398 } 398 }
399 memcpy(&(*arrayStorage)[storageOffset], scriptValue.fOperand.fArray- >begin(), count * sizeof(SkOperand)); 399 memcpy(&(*arrayStorage)[storageOffset], scriptValue.fOperand.fArray- >begin(), count * sizeof(SkOperand));
(...skipping 19 matching lines...) Expand all
419 destArray->setCount(storageOffset + count); 419 destArray->setCount(storageOffset + count);
420 memcpy(destArray->begin() + storageOffset, scriptValue.fOperand.fArr ay->begin(), sizeof(SkOperand) * count); 420 memcpy(destArray->begin() + storageOffset, scriptValue.fOperand.fArr ay->begin(), sizeof(SkOperand) * count);
421 } 421 }
422 } else if (type == SkType_String) { 422 } else if (type == SkType_String) {
423 SkString* string = untypedStorage ? (SkString*) untypedStorage : (*array Storage)[storageOffset].fString; 423 SkString* string = untypedStorage ? (SkString*) untypedStorage : (*array Storage)[storageOffset].fString;
424 string->set(*scriptValue.fOperand.fString); 424 string->set(*scriptValue.fOperand.fString);
425 } else if (type == SkType_ARGB && outType == SkType_Float) { 425 } else if (type == SkType_ARGB && outType == SkType_Float) {
426 SkTypedArray* array = scriptValue.fOperand.fArray; 426 SkTypedArray* array = scriptValue.fOperand.fArray;
427 SkASSERT(scriptValue.fType == SkType_Int || scriptValue.fType == SkType_ ARGB || 427 SkASSERT(scriptValue.fType == SkType_Int || scriptValue.fType == SkType_ ARGB ||
428 scriptValue.fType == SkType_Array); 428 scriptValue.fType == SkType_Array);
429 SkASSERT(scriptValue.fType != SkType_Array || (array != NULL && 429 SkASSERT(scriptValue.fType != SkType_Array || (array != nullptr &&
430 array->getType() == SkType_Int)); 430 array->getType() == SkType_Int));
431 int numberOfColors = scriptValue.fType == SkType_Array ? array->count() : 1; 431 int numberOfColors = scriptValue.fType == SkType_Array ? array->count() : 1;
432 int numberOfComponents = numberOfColors * 4; 432 int numberOfComponents = numberOfColors * 4;
433 // SkASSERT(maxStorage == 0 || maxStorage == numberOfComponents); 433 // SkASSERT(maxStorage == 0 || maxStorage == numberOfComponents);
434 if (maxStorage == 0) 434 if (maxStorage == 0)
435 arrayStorage->setCount(numberOfComponents); 435 arrayStorage->setCount(numberOfComponents);
436 for (int index = 0; index < numberOfColors; index++) { 436 for (int index = 0; index < numberOfColors; index++) {
437 SkColor color = scriptValue.fType == SkType_Array ? 437 SkColor color = scriptValue.fType == SkType_Array ?
438 (SkColor) array->begin()[index].fS32 : (SkColor) scriptValue.fOp erand.fS32; 438 (SkColor) array->begin()[index].fS32 : (SkColor) scriptValue.fOp erand.fS32;
439 storage[0].fScalar = SkIntToScalar(SkColorGetA(color)); 439 storage[0].fScalar = SkIntToScalar(SkColorGetA(color));
440 storage[1].fScalar = SkIntToScalar(SkColorGetR(color)); 440 storage[1].fScalar = SkIntToScalar(SkColorGetR(color));
441 storage[2].fScalar = SkIntToScalar(SkColorGetG(color)); 441 storage[2].fScalar = SkIntToScalar(SkColorGetG(color));
442 storage[3].fScalar = SkIntToScalar(SkColorGetB(color)); 442 storage[3].fScalar = SkIntToScalar(SkColorGetB(color));
443 storage += 4; 443 storage += 4;
444 } 444 }
445 } else if (SkDisplayType::IsStruct(NULL /* !!! maker*/, type)) { 445 } else if (SkDisplayType::IsStruct(nullptr /* !!! maker*/, type)) {
446 if (scriptValue.fType != SkType_Array) 446 if (scriptValue.fType != SkType_Array)
447 return true; // error 447 return true; // error
448 SkASSERT(sizeof(SkScalar) == sizeof(SkOperand)); // !!! no 64 bit pointe r support yet 448 SkASSERT(sizeof(SkScalar) == sizeof(SkOperand)); // !!! no 64 bit pointe r support yet
449 int count = scriptValue.fOperand.fArray->count(); 449 int count = scriptValue.fOperand.fArray->count();
450 if (count > 0) { 450 if (count > 0) {
451 SkASSERT(fCount == count); 451 SkASSERT(fCount == count);
452 memcpy(storage, scriptValue.fOperand.fArray->begin(), count * sizeof (SkOperand)); 452 memcpy(storage, scriptValue.fOperand.fArray->begin(), count * sizeof (SkOperand));
453 } 453 }
454 } else if (scriptValue.fType == SkType_Array) { 454 } else if (scriptValue.fType == SkType_Array) {
455 SkASSERT(scriptValue.fOperand.fArray->getType() == type); 455 SkASSERT(scriptValue.fOperand.fArray->getType() == type);
(...skipping 23 matching lines...) Expand all
479 //} 479 //}
480 480
481 #if SK_USE_CONDENSED_INFO == 0 481 #if SK_USE_CONDENSED_INFO == 0
482 482
483 // Find Nth memberInfo 483 // Find Nth memberInfo
484 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, int * index) { 484 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, int * index) {
485 SkASSERT(*index >= 0); 485 SkASSERT(*index >= 0);
486 if (info->fType == SkType_BaseClassInfo) { 486 if (info->fType == SkType_BaseClassInfo) {
487 const SkMemberInfo* inherited = (SkMemberInfo*) info->fName; 487 const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
488 const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, index); 488 const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, index);
489 if (result != NULL) 489 if (result != nullptr)
490 return result; 490 return result;
491 if (--count == 0) 491 if (--count == 0)
492 return NULL; 492 return nullptr;
493 info++; 493 info++;
494 } 494 }
495 SkASSERT(info->fName); 495 SkASSERT(info->fName);
496 SkASSERT(info->fType != SkType_BaseClassInfo); 496 SkASSERT(info->fType != SkType_BaseClassInfo);
497 if (*index >= count) { 497 if (*index >= count) {
498 *index -= count; 498 *index -= count;
499 return NULL; 499 return nullptr;
500 } 500 }
501 return &info[*index]; 501 return &info[*index];
502 } 502 }
503 503
504 // Find named memberinfo 504 // Find named memberinfo
505 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, con st char** matchPtr) { 505 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, con st char** matchPtr) {
506 const char* match = *matchPtr; 506 const char* match = *matchPtr;
507 if (info->fType == SkType_BaseClassInfo) { 507 if (info->fType == SkType_BaseClassInfo) {
508 const SkMemberInfo* inherited = (SkMemberInfo*) info->fName; 508 const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
509 const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, matchPtr); 509 const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, matchPtr);
510 if (result != NULL) 510 if (result != nullptr)
511 return result; 511 return result;
512 if (--count == 0) 512 if (--count == 0)
513 return NULL; 513 return nullptr;
514 info++; 514 info++;
515 } 515 }
516 SkASSERT(info->fName); 516 SkASSERT(info->fName);
517 SkASSERT(info->fType != SkType_BaseClassInfo); 517 SkASSERT(info->fType != SkType_BaseClassInfo);
518 int index = SkStrSearch(&info->fName, count, match, sizeof(*info)); 518 int index = SkStrSearch(&info->fName, count, match, sizeof(*info));
519 if (index < 0 || index >= count) 519 if (index < 0 || index >= count)
520 return NULL; 520 return nullptr;
521 return &info[index]; 521 return &info[index];
522 } 522 }
523 523
524 const SkMemberInfo* SkMemberInfo::getInherited() const { 524 const SkMemberInfo* SkMemberInfo::getInherited() const {
525 return (SkMemberInfo*) fName; 525 return (SkMemberInfo*) fName;
526 } 526 }
527 527
528 #endif // SK_USE_CONDENSED_INFO == 0 528 #endif // SK_USE_CONDENSED_INFO == 0
529 529
530 #if 0 530 #if 0
(...skipping 19 matching lines...) Expand all
550 // case SkType_PointArray: 550 // case SkType_PointArray:
551 case SkType_ScalarArray: 551 case SkType_ScalarArray:
552 SkParse::FindScalars(value, (SkScalar*) valuePtr, count); 552 SkParse::FindScalars(value, (SkScalar*) valuePtr, count);
553 break; 553 break;
554 default: 554 default:
555 SkASSERT(0); 555 SkASSERT(0);
556 } 556 }
557 return true; 557 return true;
558 } 558 }
559 #endif 559 #endif
OLDNEW
« no previous file with comments | « src/animator/SkMemberInfo.h ('k') | src/animator/SkOperandIterpolator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698