Index: src/core/SkPaint.cpp |
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp |
index 7fd0b9d227a6da240296b0a0de1564e84885a035..c1097204c4d7ae40777793d4f51cf53321e3d807 100644 |
--- a/src/core/SkPaint.cpp |
+++ b/src/core/SkPaint.cpp |
@@ -40,16 +40,16 @@ |
//#define SK_REPORT_API_RANGE_CHECK |
SkPaint::SkPaint() { |
- fTypeface = NULL; |
- fPathEffect = NULL; |
- fShader = NULL; |
- fXfermode = NULL; |
- fMaskFilter = NULL; |
- fColorFilter = NULL; |
- fRasterizer = NULL; |
- fLooper = NULL; |
- fImageFilter = NULL; |
- fAnnotation = NULL; |
+ fTypeface = nullptr; |
+ fPathEffect = nullptr; |
+ fShader = nullptr; |
+ fXfermode = nullptr; |
+ fMaskFilter = nullptr; |
+ fColorFilter = nullptr; |
+ fRasterizer = nullptr; |
+ fLooper = nullptr; |
+ fImageFilter = nullptr; |
+ fAnnotation = nullptr; |
fTextSize = SkPaintDefaults_TextSize; |
fTextScaleX = SK_Scalar1; |
@@ -398,9 +398,9 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, |
return 0; |
} |
- SkASSERT(textData != NULL); |
+ SkASSERT(textData != nullptr); |
- if (NULL == glyphs) { |
+ if (nullptr == glyphs) { |
switch (this->getTextEncoding()) { |
case kUTF8_TextEncoding: |
return SkUTF8_CountUnichars((const char*)textData, byteLength); |
@@ -425,7 +425,7 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, |
return SkToInt(byteLength >> 1); |
} |
- SkAutoGlyphCache autoCache(*this, NULL, NULL); |
+ SkAutoGlyphCache autoCache(*this, nullptr, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
const char* text = (const char*)textData; |
@@ -465,7 +465,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const { |
return true; |
} |
- SkASSERT(textData != NULL); |
+ SkASSERT(textData != nullptr); |
// handle this encoding before the setup for the glyphcache |
if (this->getTextEncoding() == kGlyphID_TextEncoding) { |
@@ -479,7 +479,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const { |
return true; |
} |
- SkAutoGlyphCache autoCache(*this, NULL, NULL); |
+ SkAutoGlyphCache autoCache(*this, nullptr, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
switch (this->getTextEncoding()) { |
@@ -525,11 +525,11 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkUnichar tex |
return; |
} |
- SkASSERT(glyphs != NULL); |
- SkASSERT(textData != NULL); |
+ SkASSERT(glyphs != nullptr); |
+ SkASSERT(textData != nullptr); |
SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
- SkAutoGlyphCache autoCache(*this, &props, NULL); |
+ SkAutoGlyphCache autoCache(*this, &props, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
for (int index = 0; index < count; index++) { |
@@ -541,24 +541,24 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkUnichar tex |
static const SkGlyph& sk_getMetrics_utf8_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF8_NextUnichar(text)); |
} |
static const SkGlyph& sk_getMetrics_utf16_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text)); |
} |
static const SkGlyph& sk_getMetrics_utf32_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const int32_t* ptr = *(const int32_t**)text; |
SkUnichar uni = *ptr++; |
@@ -568,8 +568,8 @@ static const SkGlyph& sk_getMetrics_utf32_next(SkGlyphCache* cache, |
static const SkGlyph& sk_getMetrics_glyph_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const uint16_t* ptr = *(const uint16_t**)text; |
unsigned glyphID = *ptr; |
@@ -580,24 +580,24 @@ static const SkGlyph& sk_getMetrics_glyph_next(SkGlyphCache* cache, |
static const SkGlyph& sk_getAdvance_utf8_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharAdvance(SkUTF8_NextUnichar(text)); |
} |
static const SkGlyph& sk_getAdvance_utf16_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharAdvance(SkUTF16_NextUnichar((const uint16_t**)text)); |
} |
static const SkGlyph& sk_getAdvance_utf32_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const int32_t* ptr = *(const int32_t**)text; |
SkUnichar uni = *ptr++; |
@@ -607,8 +607,8 @@ static const SkGlyph& sk_getAdvance_utf32_next(SkGlyphCache* cache, |
static const SkGlyph& sk_getAdvance_glyph_next(SkGlyphCache* cache, |
const char** text) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const uint16_t* ptr = *(const uint16_t**)text; |
unsigned glyphID = *ptr; |
@@ -644,32 +644,32 @@ SkMeasureCacheProc SkPaint::getMeasureCacheProc(bool needFullMetrics) const { |
static const SkGlyph& sk_getMetrics_utf8_00(SkGlyphCache* cache, |
const char** text, SkFixed, SkFixed) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF8_NextUnichar(text)); |
} |
static const SkGlyph& sk_getMetrics_utf8_xy(SkGlyphCache* cache, |
const char** text, SkFixed x, SkFixed y) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF8_NextUnichar(text), x, y); |
} |
static const SkGlyph& sk_getMetrics_utf16_00(SkGlyphCache* cache, |
const char** text, SkFixed, SkFixed) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text)); |
} |
static const SkGlyph& sk_getMetrics_utf16_xy(SkGlyphCache* cache, |
const char** text, SkFixed x, SkFixed y) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text), |
x, y); |
@@ -677,8 +677,8 @@ static const SkGlyph& sk_getMetrics_utf16_xy(SkGlyphCache* cache, |
static const SkGlyph& sk_getMetrics_utf32_00(SkGlyphCache* cache, |
const char** text, SkFixed, SkFixed) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const int32_t* ptr = *(const int32_t**)text; |
SkUnichar uni = *ptr++; |
@@ -688,8 +688,8 @@ static const SkGlyph& sk_getMetrics_utf32_00(SkGlyphCache* cache, |
static const SkGlyph& sk_getMetrics_utf32_xy(SkGlyphCache* cache, |
const char** text, SkFixed x, SkFixed y) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const int32_t* ptr = *(const int32_t**)text; |
SkUnichar uni = *ptr++; |
@@ -699,8 +699,8 @@ static const SkGlyph& sk_getMetrics_utf32_xy(SkGlyphCache* cache, |
static const SkGlyph& sk_getMetrics_glyph_00(SkGlyphCache* cache, |
const char** text, SkFixed, SkFixed) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const uint16_t* ptr = *(const uint16_t**)text; |
unsigned glyphID = *ptr; |
@@ -711,8 +711,8 @@ static const SkGlyph& sk_getMetrics_glyph_00(SkGlyphCache* cache, |
static const SkGlyph& sk_getMetrics_glyph_xy(SkGlyphCache* cache, |
const char** text, SkFixed x, SkFixed y) { |
- SkASSERT(cache != NULL); |
- SkASSERT(text != NULL); |
+ SkASSERT(cache != nullptr); |
+ SkASSERT(text != nullptr); |
const uint16_t* ptr = *(const uint16_t**)text; |
unsigned glyphID = *ptr; |
@@ -835,7 +835,7 @@ SkScalar SkPaint::measure_text(SkGlyphCache* cache, |
return 0; |
} |
- SkMeasureCacheProc glyphCacheProc = this->getMeasureCacheProc(NULL != bounds); |
+ SkMeasureCacheProc glyphCacheProc = this->getMeasureCacheProc(nullptr != bounds); |
int xyIndex; |
JoinBoundsProc joinBoundsProc; |
@@ -857,7 +857,7 @@ SkScalar SkPaint::measure_text(SkGlyphCache* cache, |
SkAutoKern autokern; |
- if (NULL == bounds) { |
+ if (nullptr == bounds) { |
if (this->isDevKernText()) { |
int rsb; |
for (; text < stop; n++) { |
@@ -897,13 +897,13 @@ SkScalar SkPaint::measure_text(SkGlyphCache* cache, |
SkScalar SkPaint::measureText(const void* textData, size_t length, SkRect* bounds) const { |
const char* text = (const char*)textData; |
- SkASSERT(text != NULL || length == 0); |
+ SkASSERT(text != nullptr || length == 0); |
SkCanonicalizePaint canon(*this); |
const SkPaint& paint = canon.getPaint(); |
SkScalar scale = canon.getScale(); |
- SkAutoGlyphCache autoCache(paint, NULL, NULL); |
+ SkAutoGlyphCache autoCache(paint, nullptr, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
SkScalar width = 0; |
@@ -944,7 +944,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, |
return length; |
} |
- SkASSERT(textD != NULL); |
+ SkASSERT(textD != nullptr); |
const char* text = (const char*)textD; |
const char* stop = text + length; |
@@ -957,7 +957,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, |
maxWidth /= scale; |
} |
- SkAutoGlyphCache autoCache(paint, NULL, NULL); |
+ SkAutoGlyphCache autoCache(paint, nullptr, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc(false); |
@@ -1022,18 +1022,18 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { |
const SkPaint& paint = canon.getPaint(); |
SkScalar scale = canon.getScale(); |
- SkMatrix zoomMatrix, *zoomPtr = NULL; |
+ SkMatrix zoomMatrix, *zoomPtr = nullptr; |
if (zoom) { |
zoomMatrix.setScale(zoom, zoom); |
zoomPtr = &zoomMatrix; |
} |
FontMetrics storage; |
- if (NULL == metrics) { |
+ if (nullptr == metrics) { |
metrics = &storage; |
} |
- paint.descriptorProc(NULL, zoomPtr, FontMetricsDescProc, metrics, true); |
+ paint.descriptorProc(nullptr, zoomPtr, FontMetricsDescProc, metrics, true); |
if (scale) { |
metrics->fTop = SkScalarMul(metrics->fTop, scale); |
@@ -1068,7 +1068,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength, |
SkASSERT(textData); |
- if (NULL == widths && NULL == bounds) { |
+ if (nullptr == widths && nullptr == bounds) { |
return this->countText(textData, byteLength); |
} |
@@ -1076,10 +1076,10 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength, |
const SkPaint& paint = canon.getPaint(); |
SkScalar scale = canon.getScale(); |
- SkAutoGlyphCache autoCache(paint, NULL, NULL); |
+ SkAutoGlyphCache autoCache(paint, nullptr, nullptr); |
SkGlyphCache* cache = autoCache.getCache(); |
SkMeasureCacheProc glyphCacheProc; |
- glyphCacheProc = paint.getMeasureCacheProc(NULL != bounds); |
+ glyphCacheProc = paint.getMeasureCacheProc(nullptr != bounds); |
const char* text = (const char*)textData; |
const char* stop = text + byteLength; |
@@ -1168,10 +1168,10 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength, |
void SkPaint::getTextPath(const void* textData, size_t length, |
SkScalar x, SkScalar y, SkPath* path) const { |
- SkASSERT(length == 0 || textData != NULL); |
+ SkASSERT(length == 0 || textData != nullptr); |
const char* text = (const char*)textData; |
- if (text == NULL || length == 0 || path == NULL) { |
+ if (text == nullptr || length == 0 || path == nullptr) { |
return; |
} |
@@ -1196,10 +1196,10 @@ void SkPaint::getTextPath(const void* textData, size_t length, |
void SkPaint::getPosTextPath(const void* textData, size_t length, |
const SkPoint pos[], SkPath* path) const { |
- SkASSERT(length == 0 || textData != NULL); |
+ SkASSERT(length == 0 || textData != nullptr); |
const char* text = (const char*)textData; |
- if (text == NULL || length == 0 || path == NULL) { |
+ if (text == nullptr || length == 0 || path == nullptr) { |
return; |
} |
@@ -1213,7 +1213,7 @@ void SkPaint::getPosTextPath(const void* textData, size_t length, |
unsigned int i = 0; |
const SkPath* iterPath; |
- while (iter.next(&iterPath, NULL)) { |
+ while (iter.next(&iterPath, nullptr)) { |
matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); |
if (iterPath) { |
path->addPath(*iterPath, matrix); |
@@ -1229,7 +1229,7 @@ SkRect SkPaint::getFontBounds() const { |
m.postSkew(fTextSkewX, 0); |
SkTypeface* typeface = this->getTypeface(); |
- if (NULL == typeface) { |
+ if (nullptr == typeface) { |
typeface = SkTypeface::GetDefaultTypeface(); |
} |
@@ -1240,7 +1240,7 @@ SkRect SkPaint::getFontBounds() const { |
static void add_flattenable(SkDescriptor* desc, uint32_t tag, |
SkWriteBuffer* buffer) { |
- buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL)); |
+ buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), nullptr)); |
} |
static SkMask::Format compute_mask_format(const SkPaint& paint) { |
@@ -1329,10 +1329,10 @@ void SkScalerContext::MakeRec(const SkPaint& paint, |
const SkSurfaceProps* surfaceProps, |
const SkMatrix* deviceMatrix, |
Rec* rec) { |
- SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); |
+ SkASSERT(deviceMatrix == nullptr || !deviceMatrix->hasPerspective()); |
SkTypeface* typeface = paint.getTypeface(); |
- if (NULL == typeface) { |
+ if (nullptr == typeface) { |
typeface = SkTypeface::GetDefaultTypeface(); |
} |
rec->fFontID = typeface->uniqueID(); |
@@ -1498,8 +1498,8 @@ void SkScalerContext::MakeRec(const SkPaint& paint, |
*/ |
SK_DECLARE_STATIC_MUTEX(gMaskGammaCacheMutex); |
-static SkMaskGamma* gLinearMaskGamma = NULL; |
-static SkMaskGamma* gMaskGamma = NULL; |
+static SkMaskGamma* gLinearMaskGamma = nullptr; |
+static SkMaskGamma* gMaskGamma = nullptr; |
static SkScalar gContrast = SK_ScalarMin; |
static SkScalar gPaintGamma = SK_ScalarMin; |
static SkScalar gDeviceGamma = SK_ScalarMin; |
@@ -1510,7 +1510,7 @@ static SkScalar gDeviceGamma = SK_ScalarMin; |
static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma) { |
gMaskGammaCacheMutex.assertHeld(); |
if (0 == contrast && SK_Scalar1 == paintGamma && SK_Scalar1 == deviceGamma) { |
- if (NULL == gLinearMaskGamma) { |
+ if (nullptr == gLinearMaskGamma) { |
gLinearMaskGamma = new SkMaskGamma; |
} |
return *gLinearMaskGamma; |
@@ -1529,9 +1529,9 @@ static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma |
SkAutoMutexAcquire ama(gMaskGammaCacheMutex); |
SkSafeUnref(gLinearMaskGamma); |
- gLinearMaskGamma = NULL; |
+ gLinearMaskGamma = nullptr; |
SkSafeUnref(gMaskGamma); |
- gMaskGamma = NULL; |
+ gMaskGamma = nullptr; |
SkDEBUGCODE(gContrast = SK_ScalarMin;) |
SkDEBUGCODE(gPaintGamma = SK_ScalarMin;) |
SkDEBUGCODE(gDeviceGamma = SK_ScalarMin;) |
@@ -1975,7 +1975,7 @@ void SkPaint::unflatten(SkReadBuffer& buffer) { |
if (flatFlags & kHasTypeface_FlatFlag) { |
this->setTypeface(buffer.readTypeface()); |
} else { |
- this->setTypeface(NULL); |
+ this->setTypeface(nullptr); |
} |
if (flatFlags & kHasEffects_FlatFlag) { |
@@ -1992,14 +1992,14 @@ void SkPaint::unflatten(SkReadBuffer& buffer) { |
this->setAnnotation(SkAnnotation::Create(buffer))->unref(); |
} |
} else { |
- this->setPathEffect(NULL); |
- this->setShader(NULL); |
- this->setXfermode(NULL); |
- this->setMaskFilter(NULL); |
- this->setColorFilter(NULL); |
- this->setRasterizer(NULL); |
- this->setLooper(NULL); |
- this->setImageFilter(NULL); |
+ this->setPathEffect(nullptr); |
+ this->setShader(nullptr); |
+ this->setXfermode(nullptr); |
+ this->setMaskFilter(nullptr); |
+ this->setColorFilter(nullptr); |
+ this->setRasterizer(nullptr); |
+ this->setLooper(nullptr); |
+ this->setImageFilter(nullptr); |
} |
} |
@@ -2303,14 +2303,14 @@ SkTextToPathIter::SkTextToPathIter(const char text[], size_t length, |
fGlyphCacheProc = paint.getMeasureCacheProc(true); |
fPaint.setLinearText(true); |
- fPaint.setMaskFilter(NULL); // don't want this affecting our path-cache lookup |
+ fPaint.setMaskFilter(nullptr); // don't want this affecting our path-cache lookup |
- if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint)) { |
+ if (fPaint.getPathEffect() == nullptr && !has_thick_frame(fPaint)) { |
applyStrokeAndPathEffects = false; |
} |
// can't use our canonical size if we need to apply patheffects |
- if (fPaint.getPathEffect() == NULL) { |
+ if (fPaint.getPathEffect() == nullptr) { |
fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); |
fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; |
if (has_thick_frame(fPaint)) { |
@@ -2322,13 +2322,13 @@ SkTextToPathIter::SkTextToPathIter(const char text[], size_t length, |
if (!applyStrokeAndPathEffects) { |
fPaint.setStyle(SkPaint::kFill_Style); |
- fPaint.setPathEffect(NULL); |
+ fPaint.setPathEffect(nullptr); |
} |
- fCache = fPaint.detachCache(NULL, NULL, false); |
+ fCache = fPaint.detachCache(nullptr, nullptr, false); |
SkPaint::Style style = SkPaint::kFill_Style; |
- SkPathEffect* pe = NULL; |
+ SkPathEffect* pe = nullptr; |
if (!applyStrokeAndPathEffects) { |
style = paint.getStyle(); // restore |
@@ -2344,7 +2344,7 @@ SkTextToPathIter::SkTextToPathIter(const char text[], size_t length, |
if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first |
int count; |
SkScalar width = SkScalarMul(fPaint.measure_text(fCache, text, length, |
- &count, NULL), fScale); |
+ &count, nullptr), fScale); |
if (paint.getTextAlign() == SkPaint::kCenter_Align) { |
width = SkScalarHalf(width); |
} |
@@ -2376,7 +2376,7 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) { |
} |
} else { |
if (path) { |
- *path = NULL; |
+ *path = nullptr; |
} |
} |
if (xpos) { |
@@ -2398,7 +2398,7 @@ static bool affects_alpha(const SkColorFilter* cf) { |
static bool affects_alpha(const SkImageFilter* imf) { |
// TODO: check if we should allow imagefilters to broadcast that they don't affect alpha |
// ala colorfilters |
- return imf != NULL; |
+ return imf != nullptr; |
} |
bool SkPaint::nothingToDraw() const { |