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

Side by Side Diff: src/animator/SkDisplayType.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/SkDisplayPost.cpp ('k') | src/animator/SkDisplayTypes.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 "SkDisplayType.h" 10 #include "SkDisplayType.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "SkTSearch.h" 55 #include "SkTSearch.h"
56 56
57 #define CASE_NEW(_class) \ 57 #define CASE_NEW(_class) \
58 case SkType_##_class: result = new Sk##_class(); break 58 case SkType_##_class: result = new Sk##_class(); break
59 #define CASE_DRAW_NEW(_class) \ 59 #define CASE_DRAW_NEW(_class) \
60 case SkType_##_class: result = new SkDraw##_class(); break 60 case SkType_##_class: result = new SkDraw##_class(); break
61 #define CASE_DISPLAY_NEW(_class) \ 61 #define CASE_DISPLAY_NEW(_class) \
62 case SkType_##_class: result = new SkDisplay##_class(); break 62 case SkType_##_class: result = new SkDisplay##_class(); break
63 #ifdef SK_DEBUG 63 #ifdef SK_DEBUG
64 #define CASE_DEBUG_RETURN_NIL(_class) \ 64 #define CASE_DEBUG_RETURN_NIL(_class) \
65 case SkType_##_class: return NULL 65 case SkType_##_class: return nullptr
66 #else 66 #else
67 #define CASE_DEBUG_RETURN_NIL(_class) 67 #define CASE_DEBUG_RETURN_NIL(_class)
68 #endif 68 #endif
69 69
70 70
71 SkDisplayTypes SkDisplayType::gNewTypes = kNumberOfTypes; 71 SkDisplayTypes SkDisplayType::gNewTypes = kNumberOfTypes;
72 72
73 SkDisplayable* SkDisplayType::CreateInstance(SkAnimateMaker* maker, SkDisplayTyp es type) { 73 SkDisplayable* SkDisplayType::CreateInstance(SkAnimateMaker* maker, SkDisplayTyp es type) {
74 SkDisplayable* result = NULL; 74 SkDisplayable* result = nullptr;
75 switch (type) { 75 switch (type) {
76 // unknown 76 // unknown
77 CASE_DISPLAY_NEW(Math); 77 CASE_DISPLAY_NEW(Math);
78 CASE_DISPLAY_NEW(Number); 78 CASE_DISPLAY_NEW(Number);
79 CASE_NEW(Add); 79 CASE_NEW(Add);
80 CASE_NEW(AddCircle); 80 CASE_NEW(AddCircle);
81 // addgeom 81 // addgeom
82 CASE_DEBUG_RETURN_NIL(AddMode); 82 CASE_DEBUG_RETURN_NIL(AddMode);
83 CASE_NEW(AddOval); 83 CASE_NEW(AddOval);
84 CASE_NEW(AddPath); 84 CASE_NEW(AddPath);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // textboxmode 193 // textboxmode
194 CASE_NEW(TextOnPath); 194 CASE_NEW(TextOnPath);
195 CASE_NEW(TextToPath); 195 CASE_NEW(TextToPath);
196 CASE_DEBUG_RETURN_NIL(TileMode); 196 CASE_DEBUG_RETURN_NIL(TileMode);
197 CASE_NEW(Translate); 197 CASE_NEW(Translate);
198 CASE_DRAW_NEW(Typeface); 198 CASE_DRAW_NEW(Typeface);
199 CASE_DEBUG_RETURN_NIL(Xfermode); 199 CASE_DEBUG_RETURN_NIL(Xfermode);
200 default: 200 default:
201 SkExtras** end = maker->fExtras.end(); 201 SkExtras** end = maker->fExtras.end();
202 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; e xtraPtr++) { 202 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; e xtraPtr++) {
203 if ((result = (*extraPtr)->createInstance(type)) != NULL) 203 if ((result = (*extraPtr)->createInstance(type)) != nullptr)
204 return result; 204 return result;
205 } 205 }
206 SkASSERT(0); 206 SkASSERT(0);
207 } 207 }
208 return result; 208 return result;
209 } 209 }
210 210
211 #undef CASE_NEW 211 #undef CASE_NEW
212 #undef CASE_DRAW_NEW 212 #undef CASE_DRAW_NEW
213 #undef CASE_DISPLAY_NEW 213 #undef CASE_DISPLAY_NEW
214 214
215 #if SK_USE_CONDENSED_INFO == 0 215 #if SK_USE_CONDENSED_INFO == 0
216 216
217 #define CASE_GET_INFO(_class) case SkType_##_class: \ 217 #define CASE_GET_INFO(_class) case SkType_##_class: \
218 info = Sk##_class::fInfo; infoCount = Sk##_class::fInfoCount; break 218 info = Sk##_class::fInfo; infoCount = Sk##_class::fInfoCount; break
219 #define CASE_GET_DRAW_INFO(_class) case SkType_##_class: \ 219 #define CASE_GET_DRAW_INFO(_class) case SkType_##_class: \
220 info = SkDraw##_class::fInfo; infoCount = SkDraw##_class::fInfoCount; break 220 info = SkDraw##_class::fInfo; infoCount = SkDraw##_class::fInfoCount; break
221 #define CASE_GET_DISPLAY_INFO(_class) case SkType_##_class: \ 221 #define CASE_GET_DISPLAY_INFO(_class) case SkType_##_class: \
222 info = SkDisplay##_class::fInfo; infoCount = SkDisplay##_class::fInfoCount; \ 222 info = SkDisplay##_class::fInfo; infoCount = SkDisplay##_class::fInfoCount; \
223 break 223 break
224 224
225 const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* maker, 225 const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* maker,
226 SkDisplayTypes type, int* infoCountPtr) { 226 SkDisplayTypes type, int* infoCountPtr) {
227 const SkMemberInfo* info = NULL; 227 const SkMemberInfo* info = nullptr;
228 int infoCount = 0; 228 int infoCount = 0;
229 switch (type) { 229 switch (type) {
230 // unknown 230 // unknown
231 CASE_GET_DISPLAY_INFO(Math); 231 CASE_GET_DISPLAY_INFO(Math);
232 CASE_GET_DISPLAY_INFO(Number); 232 CASE_GET_DISPLAY_INFO(Number);
233 CASE_GET_INFO(Add); 233 CASE_GET_INFO(Add);
234 CASE_GET_INFO(AddCircle); 234 CASE_GET_INFO(AddCircle);
235 CASE_GET_INFO(AddGeom); 235 CASE_GET_INFO(AddGeom);
236 // addmode 236 // addmode
237 CASE_GET_INFO(AddOval); 237 CASE_GET_INFO(AddOval);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 CASE_GET_INFO(TextToPath); 349 CASE_GET_INFO(TextToPath);
350 // tilemode 350 // tilemode
351 CASE_GET_INFO(Translate); 351 CASE_GET_INFO(Translate);
352 CASE_GET_DRAW_INFO(Typeface); 352 CASE_GET_DRAW_INFO(Typeface);
353 // xfermode 353 // xfermode
354 // knumberoftypes 354 // knumberoftypes
355 default: 355 default:
356 if (maker) { 356 if (maker) {
357 SkExtras** end = maker->fExtras.end(); 357 SkExtras** end = maker->fExtras.end();
358 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < en d; extraPtr++) { 358 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < en d; extraPtr++) {
359 if ((info = (*extraPtr)->getMembers(type, infoCountPtr)) != NULL) 359 if ((info = (*extraPtr)->getMembers(type, infoCountPtr)) != nullptr)
360 return info; 360 return info;
361 } 361 }
362 } 362 }
363 return NULL; 363 return nullptr;
364 } 364 }
365 if (infoCountPtr) 365 if (infoCountPtr)
366 *infoCountPtr = infoCount; 366 *infoCountPtr = infoCount;
367 return info; 367 return info;
368 } 368 }
369 369
370 const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* maker, 370 const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* maker,
371 SkDisplayTypes type, const char** matchPtr ) { 371 SkDisplayTypes type, const char** matchPtr ) {
372 int infoCount = 0; // Initialize to remove a warning. 372 int infoCount = 0; // Initialize to remove a warning.
373 const SkMemberInfo* info = GetMembers(maker, type, &infoCount); 373 const SkMemberInfo* info = GetMembers(maker, type, &infoCount);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 { "typeface", SkType_Typeface INIT_BOOL_FIELDS } 518 { "typeface", SkType_Typeface INIT_BOOL_FIELDS }
519 // xfermode 519 // xfermode
520 // knumberoftypes 520 // knumberoftypes
521 }; 521 };
522 522
523 const int kTypeNamesSize = SK_ARRAY_COUNT(gTypeNames); 523 const int kTypeNamesSize = SK_ARRAY_COUNT(gTypeNames);
524 524
525 SkDisplayTypes SkDisplayType::Find(SkAnimateMaker* maker, const SkMemberInfo* ma tch) { 525 SkDisplayTypes SkDisplayType::Find(SkAnimateMaker* maker, const SkMemberInfo* ma tch) {
526 for (int index = 0; index < kTypeNamesSize; index++) { 526 for (int index = 0; index < kTypeNamesSize; index++) {
527 SkDisplayTypes type = gTypeNames[index].fType; 527 SkDisplayTypes type = gTypeNames[index].fType;
528 const SkMemberInfo* info = SkDisplayType::GetMembers(maker, type, NULL); 528 const SkMemberInfo* info = SkDisplayType::GetMembers(maker, type, nullpt r);
529 if (info == match) 529 if (info == match)
530 return type; 530 return type;
531 } 531 }
532 return (SkDisplayTypes) -1; 532 return (SkDisplayTypes) -1;
533 } 533 }
534 534
535 // !!! optimize this by replacing function with a byte-sized lookup table 535 // !!! optimize this by replacing function with a byte-sized lookup table
536 SkDisplayTypes SkDisplayType::GetParent(SkAnimateMaker* maker, SkDisplayTypes ba se) { 536 SkDisplayTypes SkDisplayType::GetParent(SkAnimateMaker* maker, SkDisplayTypes ba se) {
537 if (base == SkType_Group || base == SkType_Save || base == SkType_SaveLayer) //!!! cheat a little until we have a lookup table 537 if (base == SkType_Group || base == SkType_Save || base == SkType_SaveLayer) //!!! cheat a little until we have a lookup table
538 return SkType_Displayable; 538 return SkType_Displayable;
539 if (base == SkType_Set) 539 if (base == SkType_Set)
540 return SkType_Animate; // another cheat until we have a lookup table 540 return SkType_Animate; // another cheat until we have a lookup table
541 const SkMemberInfo* info = GetMembers(maker, base, NULL); // get info for th is type 541 const SkMemberInfo* info = GetMembers(maker, base, nullptr); // get info for this type
542 SkASSERT(info); 542 SkASSERT(info);
543 if (info->fType != SkType_BaseClassInfo) 543 if (info->fType != SkType_BaseClassInfo)
544 return SkType_Unknown; // if no base, done 544 return SkType_Unknown; // if no base, done
545 // !!! could change SK_MEMBER_INHERITED macro to take type, stuff in offset, so that 545 // !!! could change SK_MEMBER_INHERITED macro to take type, stuff in offset, so that
546 // this (and table builder) could know type without the following steps: 546 // this (and table builder) could know type without the following steps:
547 const SkMemberInfo* inherited = info->getInherited(); 547 const SkMemberInfo* inherited = info->getInherited();
548 SkDisplayTypes result = (SkDisplayTypes) (SkType_Unknown + 1); 548 SkDisplayTypes result = (SkDisplayTypes) (SkType_Unknown + 1);
549 for (; result <= SkType_Xfermode; result = (SkDisplayTypes) (result + 1)) { 549 for (; result <= SkType_Xfermode; result = (SkDisplayTypes) (result + 1)) {
550 const SkMemberInfo* match = GetMembers(maker, result, NULL); 550 const SkMemberInfo* match = GetMembers(maker, result, nullptr);
551 if (match == inherited) 551 if (match == inherited)
552 break; 552 break;
553 } 553 }
554 SkASSERT(result <= SkType_Xfermode); 554 SkASSERT(result <= SkType_Xfermode);
555 return result; 555 return result;
556 } 556 }
557 557
558 SkDisplayTypes SkDisplayType::GetType(SkAnimateMaker* maker, const char match[], size_t len ) { 558 SkDisplayTypes SkDisplayType::GetType(SkAnimateMaker* maker, const char match[], size_t len ) {
559 int index = SkStrSearch(&gTypeNames[0].fName, kTypeNamesSize, match, 559 int index = SkStrSearch(&gTypeNames[0].fName, kTypeNamesSize, match,
560 len, sizeof(gTypeNames[0])); 560 len, sizeof(gTypeNames[0]));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 703
704 #ifdef SK_DEBUG 704 #ifdef SK_DEBUG
705 const char* SkDisplayType::GetName(SkAnimateMaker* maker, SkDisplayTypes type) { 705 const char* SkDisplayType::GetName(SkAnimateMaker* maker, SkDisplayTypes type) {
706 for (int index = 0; index < kTypeNamesSize - 1; index++) { 706 for (int index = 0; index < kTypeNamesSize - 1; index++) {
707 if (gTypeNames[index].fType == type) 707 if (gTypeNames[index].fType == type)
708 return gTypeNames[index].fName; 708 return gTypeNames[index].fName;
709 } 709 }
710 SkExtras** end = maker->fExtras.end(); 710 SkExtras** end = maker->fExtras.end();
711 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr+ +) { 711 for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr+ +) {
712 const char* result = (*extraPtr)->getName(type); 712 const char* result = (*extraPtr)->getName(type);
713 if (result != NULL) 713 if (result != nullptr)
714 return result; 714 return result;
715 } 715 }
716 return NULL; 716 return nullptr;
717 } 717 }
718 #endif 718 #endif
719 719
720 #ifdef SK_SUPPORT_UNITTEST 720 #ifdef SK_SUPPORT_UNITTEST
721 void SkDisplayType::UnitTest() { 721 void SkDisplayType::UnitTest() {
722 SkAnimator animator; 722 SkAnimator animator;
723 SkAnimateMaker* maker = animator.fMaker; 723 SkAnimateMaker* maker = animator.fMaker;
724 int index; 724 int index;
725 for (index = 0; index < kTypeNamesSize - 1; index++) { 725 for (index = 0; index < kTypeNamesSize - 1; index++) {
726 SkASSERT(strcmp(gTypeNames[index].fName, gTypeNames[index + 1].fName) < 0); 726 SkASSERT(strcmp(gTypeNames[index].fName, gTypeNames[index + 1].fName) < 0);
727 SkASSERT(gTypeNames[index].fType < gTypeNames[index + 1].fType); 727 SkASSERT(gTypeNames[index].fType < gTypeNames[index + 1].fType);
728 } 728 }
729 for (index = 0; index < kTypeNamesSize; index++) { 729 for (index = 0; index < kTypeNamesSize; index++) {
730 SkDisplayable* test = CreateInstance(maker, gTypeNames[index].fType); 730 SkDisplayable* test = CreateInstance(maker, gTypeNames[index].fType);
731 if (test == NULL) 731 if (test == nullptr)
732 continue; 732 continue;
733 #if defined _WIN32 && _MSC_VER >= 1300 && defined _INC_CRTDBG // only on window s, only if using "crtdbg.h" 733 #if defined _WIN32 && _MSC_VER >= 1300 && defined _INC_CRTDBG // only on window s, only if using "crtdbg.h"
734 // we know that crtdbg puts 0xfdfdfdfd at the end of the block 734 // we know that crtdbg puts 0xfdfdfdfd at the end of the block
735 // look for unitialized memory, signature 0xcdcdcdcd prior to that 735 // look for unitialized memory, signature 0xcdcdcdcd prior to that
736 int* start = (int*) test; 736 int* start = (int*) test;
737 while (*start != 0xfdfdfdfd) { 737 while (*start != 0xfdfdfdfd) {
738 SkASSERT(*start != 0xcdcdcdcd); 738 SkASSERT(*start != 0xcdcdcdcd);
739 start++; 739 start++;
740 } 740 }
741 #endif 741 #endif
742 delete test; 742 delete test;
743 } 743 }
744 for (index = 0; index < kTypeNamesSize; index++) { 744 for (index = 0; index < kTypeNamesSize; index++) {
745 int infoCount; 745 int infoCount;
746 const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &i nfoCount); 746 const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &i nfoCount);
747 if (info == NULL) 747 if (info == nullptr)
748 continue; 748 continue;
749 #if SK_USE_CONDENSED_INFO == 0 749 #if SK_USE_CONDENSED_INFO == 0
750 for (int inner = 0; inner < infoCount - 1; inner++) { 750 for (int inner = 0; inner < infoCount - 1; inner++) {
751 if (info[inner].fType == SkType_BaseClassInfo) 751 if (info[inner].fType == SkType_BaseClassInfo)
752 continue; 752 continue;
753 SkASSERT(strcmp(info[inner].fName, info[inner + 1].fName) < 0); 753 SkASSERT(strcmp(info[inner].fName, info[inner + 1].fName) < 0);
754 } 754 }
755 #endif 755 #endif
756 } 756 }
757 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED 757 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
758 BuildCondensedInfo(maker); 758 BuildCondensedInfo(maker);
759 #endif 759 #endif
760 } 760 }
761 #endif 761 #endif
OLDNEW
« no previous file with comments | « src/animator/SkDisplayPost.cpp ('k') | src/animator/SkDisplayTypes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698