From c84728d72a47415929464c5cf062300d86a91246 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 4 Dec 2013 20:07:47 +0000 Subject: [PATCH] Changed maxInputCount for exact inputCount Processing still had issue when the number of inputs was 0, so I changed my previous fix from a maximum input count to an exact input count. -1 is used when the input count isn't fixed (but still has to be a non-negative number). BUG= R=senorblanco@chromium.org, reed@google.com, sugoi@google.com, bsalomon@google.com Author: sugoi@chromium.org Review URL: https://codereview.chromium.org/100803004 git-svn-id: http://skia.googlecode.com/svn/trunk@12492 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkImageFilter.h | 9 ++++++++- src/animator/SkScript.cpp | 6 +++--- src/core/SkImageFilter.cpp | 4 ++-- src/effects/SkMergeImageFilter.cpp | 7 ++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 1e9f72eb30..4c372a413d 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -156,7 +156,14 @@ protected: virtual ~SkImageFilter(); - explicit SkImageFilter(int maxInputCount, SkFlattenableReadBuffer& rb); + /** + * Constructs a new SkImageFilter read from an SkFlattenableReadBuffer object. + * + * @param inputCount The exact number of inputs expected for this SkImageFilter object. + * -1 can be used if the filter accepts any number of inputs. + * @param rb SkFlattenableReadBuffer object from which the SkImageFilter is read. + */ + explicit SkImageFilter(int inputCount, SkFlattenableReadBuffer& rb); virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE; diff --git a/src/animator/SkScript.cpp b/src/animator/SkScript.cpp index c74b195f3a..934b0abe1a 100644 --- a/src/animator/SkScript.cpp +++ b/src/animator/SkScript.cpp @@ -1532,11 +1532,11 @@ bool SkScriptEngine::ConvertTo(SkScriptEngine* engine, SkDisplayTypes toType, Sk SkString* strPtr = new SkString(); SkASSERT(engine); engine->track(strPtr); - if (type == SkType_Int) + if (type == SkType_Int) { strPtr->appendS32(operand.fS32); - else if (type == SkType_Displayable) + } else if (type == SkType_Displayable) { SkASSERT(0); // must call through instance version instead of static version - else { + } else { if (type != SkType_Float) { success = false; break; diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index cca22bba55..aadf9040b0 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -53,9 +53,9 @@ SkImageFilter::~SkImageFilter() { delete[] fInputs; } -SkImageFilter::SkImageFilter(int maxInputCount, SkFlattenableReadBuffer& buffer) { +SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { fInputCount = buffer.readInt(); - if (buffer.validate((fInputCount >= 0) && (fInputCount <= maxInputCount))) { + if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount == inputCount)))) { fInputs = new SkImageFilter*[fInputCount]; for (int i = 0; i < fInputCount; i++) { if (buffer.readBool()) { diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp index a755fe68cb..b90c830725 100755 --- a/src/effects/SkMergeImageFilter.cpp +++ b/src/effects/SkMergeImageFilter.cpp @@ -11,9 +11,6 @@ #include "SkFlattenableBuffers.h" #include "SkValidationUtils.h" -// Use 65535 as an arbitrary large number of inputs that this image filter should never overflow -static const int kMaxInputs = 65535; - /////////////////////////////////////////////////////////////////////////////// void SkMergeImageFilter::initAllocModes() { @@ -56,7 +53,7 @@ SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* first, SkImageFilter* seco SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[], const CropRect* cropRect) : INHERITED(count, filters, cropRect) { - SkASSERT(count <= kMaxInputs); + SkASSERT(count >= 0); this->initModes(modes); } @@ -161,7 +158,7 @@ void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { } SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) - : INHERITED(kMaxInputs, buffer) { + : INHERITED(-1, buffer) { bool hasModes = buffer.readBool(); if (hasModes) { this->initAllocModes();