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

Side by Side Diff: src/core/SkPaint.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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/core/SkMultiPictureDraw.cpp ('k') | src/core/SkPath.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 if (byteLength == 0) { 1033 if (byteLength == 0) {
1034 *count = 0; 1034 *count = 0;
1035 if (bounds) { 1035 if (bounds) {
1036 bounds->setEmpty(); 1036 bounds->setEmpty();
1037 } 1037 }
1038 return 0; 1038 return 0;
1039 } 1039 }
1040 1040
1041 SkMeasureCacheProc glyphCacheProc; 1041 SkMeasureCacheProc glyphCacheProc;
1042 glyphCacheProc = this->getMeasureCacheProc(kForward_TextBufferDirection, 1042 glyphCacheProc = this->getMeasureCacheProc(kForward_TextBufferDirection,
1043 NULL != bounds); 1043 bounds);
1044 1044
1045 int xyIndex; 1045 int xyIndex;
1046 JoinBoundsProc joinBoundsProc; 1046 JoinBoundsProc joinBoundsProc;
1047 if (this->isVerticalText()) { 1047 if (this->isVerticalText()) {
1048 xyIndex = 1; 1048 xyIndex = 1;
1049 joinBoundsProc = join_bounds_y; 1049 joinBoundsProc = join_bounds_y;
1050 } else { 1050 } else {
1051 xyIndex = 0; 1051 xyIndex = 0;
1052 joinBoundsProc = join_bounds_x; 1052 joinBoundsProc = join_bounds_x;
1053 } 1053 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 (g.fLeft + g.fWidth) * scale, 1291 (g.fLeft + g.fWidth) * scale,
1292 (g.fTop + g.fHeight) * scale); 1292 (g.fTop + g.fHeight) * scale);
1293 } 1293 }
1294 1294
1295 int SkPaint::getTextWidths(const void* textData, size_t byteLength, 1295 int SkPaint::getTextWidths(const void* textData, size_t byteLength,
1296 SkScalar widths[], SkRect bounds[]) const { 1296 SkScalar widths[], SkRect bounds[]) const {
1297 if (0 == byteLength) { 1297 if (0 == byteLength) {
1298 return 0; 1298 return 0;
1299 } 1299 }
1300 1300
1301 SkASSERT(NULL != textData); 1301 SkASSERT(textData);
1302 1302
1303 if (NULL == widths && NULL == bounds) { 1303 if (NULL == widths && NULL == bounds) {
1304 return this->countText(textData, byteLength); 1304 return this->countText(textData, byteLength);
1305 } 1305 }
1306 1306
1307 SkCanonicalizePaint canon(*this); 1307 SkCanonicalizePaint canon(*this);
1308 const SkPaint& paint = canon.getPaint(); 1308 const SkPaint& paint = canon.getPaint();
1309 SkScalar scale = canon.getScale(); 1309 SkScalar scale = canon.getScale();
1310 1310
1311 SkAutoGlyphCache autoCache(paint, NULL, NULL); 1311 SkAutoGlyphCache autoCache(paint, NULL, NULL);
1312 SkGlyphCache* cache = autoCache.getCache(); 1312 SkGlyphCache* cache = autoCache.getCache();
1313 SkMeasureCacheProc glyphCacheProc; 1313 SkMeasureCacheProc glyphCacheProc;
1314 glyphCacheProc = paint.getMeasureCacheProc(kForward_TextBufferDirection, 1314 glyphCacheProc = paint.getMeasureCacheProc(kForward_TextBufferDirection,
1315 NULL != bounds); 1315 bounds);
1316 1316
1317 const char* text = (const char*)textData; 1317 const char* text = (const char*)textData;
1318 const char* stop = text + byteLength; 1318 const char* stop = text + byteLength;
1319 int count = 0; 1319 int count = 0;
1320 const int xyIndex = paint.isVerticalText() ? 1 : 0; 1320 const int xyIndex = paint.isVerticalText() ? 1 : 0;
1321 1321
1322 if (this->isDevKernText()) { 1322 if (this->isDevKernText()) {
1323 // we adjust the widths returned here through auto-kerning 1323 // we adjust the widths returned here through auto-kerning
1324 SkAutoKern autokern; 1324 SkAutoKern autokern;
1325 SkFixed prevWidth = 0; 1325 SkFixed prevWidth = 0;
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2304 }
2305 2305
2306 return *storage; 2306 return *storage;
2307 } 2307 }
2308 2308
2309 #ifndef SK_IGNORE_TO_STRING 2309 #ifndef SK_IGNORE_TO_STRING
2310 void SkPaint::toString(SkString* str) const { 2310 void SkPaint::toString(SkString* str) const {
2311 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); 2311 str->append("<dl><dt>SkPaint:</dt><dd><dl>");
2312 2312
2313 SkTypeface* typeface = this->getTypeface(); 2313 SkTypeface* typeface = this->getTypeface();
2314 if (NULL != typeface) { 2314 if (typeface) {
2315 SkDynamicMemoryWStream ostream; 2315 SkDynamicMemoryWStream ostream;
2316 typeface->serialize(&ostream); 2316 typeface->serialize(&ostream);
2317 SkAutoTUnref<SkData> data(ostream.copyToData()); 2317 SkAutoTUnref<SkData> data(ostream.copyToData());
2318 2318
2319 SkMemoryStream stream(data); 2319 SkMemoryStream stream(data);
2320 SkFontDescriptor descriptor(&stream); 2320 SkFontDescriptor descriptor(&stream);
2321 2321
2322 str->append("<dt>Font Family Name:</dt><dd>"); 2322 str->append("<dt>Font Family Name:</dt><dd>");
2323 str->append(descriptor.getFamilyName()); 2323 str->append(descriptor.getFamilyName());
2324 str->append("</dd><dt>Font Full Name:</dt><dd>"); 2324 str->append("</dd><dt>Font Full Name:</dt><dd>");
(...skipping 11 matching lines...) Expand all
2336 2336
2337 str->append("<dt>TextScaleX:</dt><dd>"); 2337 str->append("<dt>TextScaleX:</dt><dd>");
2338 str->appendScalar(this->getTextScaleX()); 2338 str->appendScalar(this->getTextScaleX());
2339 str->append("</dd>"); 2339 str->append("</dd>");
2340 2340
2341 str->append("<dt>TextSkewX:</dt><dd>"); 2341 str->append("<dt>TextSkewX:</dt><dd>");
2342 str->appendScalar(this->getTextSkewX()); 2342 str->appendScalar(this->getTextSkewX());
2343 str->append("</dd>"); 2343 str->append("</dd>");
2344 2344
2345 SkPathEffect* pathEffect = this->getPathEffect(); 2345 SkPathEffect* pathEffect = this->getPathEffect();
2346 if (NULL != pathEffect) { 2346 if (pathEffect) {
2347 str->append("<dt>PathEffect:</dt><dd>"); 2347 str->append("<dt>PathEffect:</dt><dd>");
2348 str->append("</dd>"); 2348 str->append("</dd>");
2349 } 2349 }
2350 2350
2351 SkShader* shader = this->getShader(); 2351 SkShader* shader = this->getShader();
2352 if (NULL != shader) { 2352 if (shader) {
2353 str->append("<dt>Shader:</dt><dd>"); 2353 str->append("<dt>Shader:</dt><dd>");
2354 shader->toString(str); 2354 shader->toString(str);
2355 str->append("</dd>"); 2355 str->append("</dd>");
2356 } 2356 }
2357 2357
2358 SkXfermode* xfer = this->getXfermode(); 2358 SkXfermode* xfer = this->getXfermode();
2359 if (NULL != xfer) { 2359 if (xfer) {
2360 str->append("<dt>Xfermode:</dt><dd>"); 2360 str->append("<dt>Xfermode:</dt><dd>");
2361 xfer->toString(str); 2361 xfer->toString(str);
2362 str->append("</dd>"); 2362 str->append("</dd>");
2363 } 2363 }
2364 2364
2365 SkMaskFilter* maskFilter = this->getMaskFilter(); 2365 SkMaskFilter* maskFilter = this->getMaskFilter();
2366 if (NULL != maskFilter) { 2366 if (maskFilter) {
2367 str->append("<dt>MaskFilter:</dt><dd>"); 2367 str->append("<dt>MaskFilter:</dt><dd>");
2368 maskFilter->toString(str); 2368 maskFilter->toString(str);
2369 str->append("</dd>"); 2369 str->append("</dd>");
2370 } 2370 }
2371 2371
2372 SkColorFilter* colorFilter = this->getColorFilter(); 2372 SkColorFilter* colorFilter = this->getColorFilter();
2373 if (NULL != colorFilter) { 2373 if (colorFilter) {
2374 str->append("<dt>ColorFilter:</dt><dd>"); 2374 str->append("<dt>ColorFilter:</dt><dd>");
2375 colorFilter->toString(str); 2375 colorFilter->toString(str);
2376 str->append("</dd>"); 2376 str->append("</dd>");
2377 } 2377 }
2378 2378
2379 SkRasterizer* rasterizer = this->getRasterizer(); 2379 SkRasterizer* rasterizer = this->getRasterizer();
2380 if (NULL != rasterizer) { 2380 if (rasterizer) {
2381 str->append("<dt>Rasterizer:</dt><dd>"); 2381 str->append("<dt>Rasterizer:</dt><dd>");
2382 str->append("</dd>"); 2382 str->append("</dd>");
2383 } 2383 }
2384 2384
2385 SkDrawLooper* looper = this->getLooper(); 2385 SkDrawLooper* looper = this->getLooper();
2386 if (NULL != looper) { 2386 if (looper) {
2387 str->append("<dt>DrawLooper:</dt><dd>"); 2387 str->append("<dt>DrawLooper:</dt><dd>");
2388 looper->toString(str); 2388 looper->toString(str);
2389 str->append("</dd>"); 2389 str->append("</dd>");
2390 } 2390 }
2391 2391
2392 SkImageFilter* imageFilter = this->getImageFilter(); 2392 SkImageFilter* imageFilter = this->getImageFilter();
2393 if (NULL != imageFilter) { 2393 if (imageFilter) {
2394 str->append("<dt>ImageFilter:</dt><dd>"); 2394 str->append("<dt>ImageFilter:</dt><dd>");
2395 str->append("</dd>"); 2395 str->append("</dd>");
2396 } 2396 }
2397 2397
2398 SkAnnotation* annotation = this->getAnnotation(); 2398 SkAnnotation* annotation = this->getAnnotation();
2399 if (NULL != annotation) { 2399 if (annotation) {
2400 str->append("<dt>Annotation:</dt><dd>"); 2400 str->append("<dt>Annotation:</dt><dd>");
2401 str->append("</dd>"); 2401 str->append("</dd>");
2402 } 2402 }
2403 2403
2404 str->append("<dt>Color:</dt><dd>0x"); 2404 str->append("<dt>Color:</dt><dd>0x");
2405 SkColor color = this->getColor(); 2405 SkColor color = this->getColor();
2406 str->appendHex(color); 2406 str->appendHex(color);
2407 str->append("</dd>"); 2407 str->append("</dd>");
2408 2408
2409 str->append("<dt>Stroke Width:</dt><dd>"); 2409 str->append("<dt>Stroke Width:</dt><dd>");
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 F_UNREF(Looper, readDrawLooper); 2671 F_UNREF(Looper, readDrawLooper);
2672 F_UNREF(ImageFilter, readImageFilter); 2672 F_UNREF(ImageFilter, readImageFilter);
2673 F(Typeface, readTypeface); 2673 F(Typeface, readTypeface);
2674 #undef F 2674 #undef F
2675 #undef F_UNREF 2675 #undef F_UNREF
2676 if (dirty & kAnnotation_DirtyBit) { 2676 if (dirty & kAnnotation_DirtyBit) {
2677 paint->setAnnotation(SkAnnotation::Create(buffer))->unref(); 2677 paint->setAnnotation(SkAnnotation::Create(buffer))->unref();
2678 } 2678 }
2679 SkASSERT(dirty == paint->fDirtyBits); 2679 SkASSERT(dirty == paint->fDirtyBits);
2680 } 2680 }
OLDNEW
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698