Trying to be consistent when members are allowed to be NULL
Got a few crashes running the fuzzer locally, all related to handling NULL members/parameters in an inconsistent way. BUG=skia: Review URL: https://codereview.chromium.org/675013003
This commit is contained in:
parent
e228ba3e5c
commit
9bde31e95d
@ -60,6 +60,10 @@ void SkLocalMatrixShader::toString(SkString* str) const {
|
||||
#endif
|
||||
|
||||
SkShader* SkShader::CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) {
|
||||
if (NULL == proxy) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (localMatrix.isIdentity()) {
|
||||
return SkRef(proxy);
|
||||
}
|
||||
|
@ -60,6 +60,9 @@ bool matrix_needs_clamping(SkScalar matrix[20]) {
|
||||
SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
|
||||
SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) {
|
||||
SkASSERT(cf);
|
||||
if (NULL == cf) {
|
||||
return NULL;
|
||||
}
|
||||
SkScalar colorMatrix[20], inputMatrix[20];
|
||||
SkColorFilter* inputColorFilter;
|
||||
if (input && cf->asColorMatrix(colorMatrix)
|
||||
@ -78,9 +81,7 @@ SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
|
||||
|
||||
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
|
||||
SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
|
||||
: INHERITED(1, &input, cropRect, uniqueID), fColorFilter(cf) {
|
||||
SkASSERT(cf);
|
||||
SkSafeRef(cf);
|
||||
: INHERITED(1, &input, cropRect, uniqueID), fColorFilter(SkRef(cf)) {
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
@ -102,7 +103,7 @@ void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
|
||||
SkColorFilterImageFilter::~SkColorFilterImageFilter() {
|
||||
SkSafeUnref(fColorFilter);
|
||||
fColorFilter->unref();
|
||||
}
|
||||
|
||||
bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
|
@ -20,20 +20,18 @@ SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe
|
||||
flags = 0x0;
|
||||
}
|
||||
CropRect cropRect(rect, flags);
|
||||
return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect));
|
||||
return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)) : NULL;
|
||||
}
|
||||
|
||||
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect, uint32_t uniqueID) {
|
||||
SkASSERT(s);
|
||||
return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID));
|
||||
return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)) : NULL;
|
||||
}
|
||||
|
||||
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect,
|
||||
uint32_t uniqueID)
|
||||
: INHERITED(0, NULL, cropRect, uniqueID)
|
||||
, fShader(s) {
|
||||
SkASSERT(s);
|
||||
s->ref();
|
||||
, fShader(SkRef(s)) {
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
@ -55,7 +53,7 @@ void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
|
||||
SkRectShaderImageFilter::~SkRectShaderImageFilter() {
|
||||
SkSafeUnref(fShader);
|
||||
fShader->unref();
|
||||
}
|
||||
|
||||
bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
|
||||
@ -78,7 +76,7 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkPaint paint;
|
||||
SkMatrix matrix(ctx.ctm());
|
||||
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
||||
paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref();
|
||||
SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix)));
|
||||
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
|
||||
canvas.drawRect(rect, paint);
|
||||
|
Loading…
Reference in New Issue
Block a user