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

Side by Side Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 1719913002: fix misc asserts and checks found by fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/effects/Sk1DPathEffect.cpp ('k') | src/effects/SkDashPathEffect.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 27 matching lines...) Expand all
38 SkRegion fRegion; 38 SkRegion fRegion;
39 SkScalar fInnerThreshold; 39 SkScalar fInnerThreshold;
40 SkScalar fOuterThreshold; 40 SkScalar fOuterThreshold;
41 typedef SkImageFilter INHERITED; 41 typedef SkImageFilter INHERITED;
42 }; 42 };
43 43
44 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkAlphaThresholdFilter) 44 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkAlphaThresholdFilter)
45 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAlphaThresholdFilterImpl) 45 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAlphaThresholdFilterImpl)
46 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 46 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
47 47
48 static bool outside_unit(SkScalar x) {
49 return x < 0 || x > 1;
50 }
48 51
49 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region, 52 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
50 SkScalar innerThreshold, 53 SkScalar innerThreshold,
51 SkScalar outerThreshold, 54 SkScalar outerThreshold,
52 SkImageFilter* input) { 55 SkImageFilter* input) {
56 if (outside_unit(innerThreshold) || outside_unit(outerThreshold) ||
57 innerThreshold > outerThreshold)
58 {
59 return nullptr;
60 }
53 return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold , input); 61 return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold , input);
54 } 62 }
55 63
56 #if SK_SUPPORT_GPU 64 #if SK_SUPPORT_GPU
57 #include "GrContext.h" 65 #include "GrContext.h"
58 #include "GrCoordTransform.h" 66 #include "GrCoordTransform.h"
59 #include "GrFragmentProcessor.h" 67 #include "GrFragmentProcessor.h"
60 #include "GrInvariantOutput.h" 68 #include "GrInvariantOutput.h"
61 #include "GrTextureAccess.h" 69 #include "GrTextureAccess.h"
62 #include "effects/GrPorterDuffXferProcessor.h" 70 #include "effects/GrPorterDuffXferProcessor.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { 335 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
328 this->INHERITED::flatten(buffer); 336 this->INHERITED::flatten(buffer);
329 buffer.writeScalar(fInnerThreshold); 337 buffer.writeScalar(fInnerThreshold);
330 buffer.writeScalar(fOuterThreshold); 338 buffer.writeScalar(fOuterThreshold);
331 buffer.writeRegion(fRegion); 339 buffer.writeRegion(fRegion);
332 } 340 }
333 341
334 bool SkAlphaThresholdFilterImpl::onFilterImageDeprecated(Proxy* proxy, const SkB itmap& src, 342 bool SkAlphaThresholdFilterImpl::onFilterImageDeprecated(Proxy* proxy, const SkB itmap& src,
335 const Context& ctx, SkB itmap* dst, 343 const Context& ctx, SkB itmap* dst,
336 SkIPoint* offset) const { 344 SkIPoint* offset) const {
337 SkASSERT(src.colorType() == kN32_SkColorType);
338 345
339 if (src.colorType() != kN32_SkColorType) { 346 if (src.colorType() != kN32_SkColorType) {
340 return false; 347 return false;
341 } 348 }
342 349
343 SkMatrix localInverse; 350 SkMatrix localInverse;
344 if (!ctx.ctm().invert(&localInverse)) { 351 if (!ctx.ctm().invert(&localInverse)) {
345 return false; 352 return false;
346 } 353 }
347 354
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 404 }
398 405
399 #ifndef SK_IGNORE_TO_STRING 406 #ifndef SK_IGNORE_TO_STRING
400 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 407 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
401 str->appendf("SkAlphaThresholdImageFilter: ("); 408 str->appendf("SkAlphaThresholdImageFilter: (");
402 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 409 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
403 str->append(")"); 410 str->append(")");
404 } 411 }
405 #endif 412 #endif
406 413
OLDNEW
« no previous file with comments | « src/effects/Sk1DPathEffect.cpp ('k') | src/effects/SkDashPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698