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

Side by Side Diff: src/utils/SkParseColor.cpp

Issue 27229004: Guard colorNames variable under SK_SUPPORT_UNITTEST. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "SkParse.h" 10 #include "SkParse.h"
11 11
12 #ifdef SK_DEBUG 12 #ifdef SK_DEBUG
13 #include "SkString.h" 13 #include "SkString.h"
14 14
15 #ifdef SK_SUPPORT_UNITTEST
15 // compress names 6 chars per long (packed 5 bits/char ) 16 // compress names 6 chars per long (packed 5 bits/char )
16 // note: little advantage to splitting chars across longs, since 3 longs at 2 unused bits each 17 // note: little advantage to splitting chars across longs, since 3 longs at 2 unused bits each
17 // allow for one additional split char (vs. the 18 unsplit chars in the three longs) 18 // allow for one additional split char (vs. the 18 unsplit chars in the three longs)
18 // use extra two bits to represent: 19 // use extra two bits to represent:
19 // 00 : final 6 (or fewer) chars (if 'a' is 0x01, zero could have specia l meaning) 20 // 00 : final 6 (or fewer) chars (if 'a' is 0x01, zero could have specia l meaning)
20 // 01 : not final 6 chars 21 // 01 : not final 6 chars
21 // 10 : color 22 // 10 : color
22 // 11 : unused, except as debugging sentinal? (could be -1 for easier te st) 23 // 11 : unused, except as debugging sentinal? (could be -1 for easier te st)
23 // !!! the bit to end the word (last) is at the low bit for binary search 24 // !!! the bit to end the word (last) is at the low bit for binary search
24 // lookup first character in offset for quick start 25 // lookup first character in offset for quick start
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 { "tomato", 0xFF6347 }, 169 { "tomato", 0xFF6347 },
169 { "turquoise", 0x40E0D0 }, 170 { "turquoise", 0x40E0D0 },
170 { "violet", 0xEE82EE }, 171 { "violet", 0xEE82EE },
171 { "wheat", 0xF5DEB3 }, 172 { "wheat", 0xF5DEB3 },
172 { "white", 0xFFFFFF }, 173 { "white", 0xFFFFFF },
173 { "whitesmoke", 0xF5F5F5 }, 174 { "whitesmoke", 0xF5F5F5 },
174 { "yellow", 0xFFFF00 }, 175 { "yellow", 0xFFFF00 },
175 { "yellowgreen", 0x9ACD32 } 176 { "yellowgreen", 0x9ACD32 }
176 }; 177 };
177 178
178 int colorNamesSize = sizeof(colorNames) / sizeof(colorNames[0]); 179 int colorNamesSize = SK_ARRAY_COUNT(colorNames);
179 180
180 #ifdef SK_SUPPORT_UNITTEST
181 static void CreateTable() { 181 static void CreateTable() {
182 SkString comment; 182 SkString comment;
183 size_t originalSize = 0; 183 size_t originalSize = 0;
184 int replacement = 0; 184 int replacement = 0;
185 for (int index = 0; index < colorNamesSize; index++) { 185 for (int index = 0; index < colorNamesSize; index++) {
186 SkNameRGB nameRGB = colorNames[index]; 186 SkNameRGB nameRGB = colorNames[index];
187 const char* name = nameRGB.name; 187 const char* name = nameRGB.name;
188 size_t len = strlen(name); 188 size_t len = strlen(name);
189 originalSize += len + 9; 189 originalSize += len + 9;
190 bool first = true; 190 bool first = true;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 result = SK_ColorBLACK; 530 result = SK_ColorBLACK;
531 SkASSERT(FindColor("#123", &result)); 531 SkASSERT(FindColor("#123", &result));
532 SkASSERT(result == 0Xff112233); 532 SkASSERT(result == 0Xff112233);
533 SkASSERT(FindColor("#abcd", &result)); 533 SkASSERT(FindColor("#abcd", &result));
534 SkASSERT(result == 0Xaabbccdd); 534 SkASSERT(result == 0Xaabbccdd);
535 result = SK_ColorBLACK; 535 result = SK_ColorBLACK;
536 // SkASSERT(FindColor("71,162,253", &result)); 536 // SkASSERT(FindColor("71,162,253", &result));
537 // SkASSERT(result == ((0xFF << 24) | (71 << 16) | (162 << 8) | (253 << 0))); 537 // SkASSERT(result == ((0xFF << 24) | (71 << 16) | (162 << 8) | (253 << 0)));
538 } 538 }
539 #endif 539 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698