Remove use of varargs in SkImageFilter. This is causing a crash in recent

builds of clang.  (It was also masking the fact that SkMergeImageFilter was
calling the wrong constructor!)

Review URL: https://codereview.appspot.com/6709066

git-svn-id: http://skia.googlecode.com/svn/trunk@6029 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
senorblanco@chromium.org 2012-10-22 15:07:14 +00:00
parent d7bafb700c
commit c2e8cef479
6 changed files with 23 additions and 20 deletions

View File

@ -133,10 +133,11 @@ public:
protected:
SkImageFilter(int inputCount, SkImageFilter** inputs);
// The ... represents inputCount SkImageFilter pointers, upon which this
// constructor will call SkSafeRef(). This is the same behaviour as
// the SkImageFilter(int, SkImageFilter**) constructor above.
explicit SkImageFilter(int inputCount, ...);
// Convenience constructor for 1-input filters.
explicit SkImageFilter(SkImageFilter* input);
// Convenience constructor for 2-input filters.
SkImageFilter(SkImageFilter* input1, SkImageFilter* input2);
virtual ~SkImageFilter();

View File

@ -28,7 +28,7 @@ private:
class SK_API SkComposeImageFilter : public SkImageFilter {
public:
SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) : INHERITED(2, outer, inner) {}
SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) : INHERITED(outer, inner) {}
virtual ~SkComposeImageFilter();
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
@ -50,7 +50,7 @@ class SK_API SkMergeImageFilter : public SkImageFilter {
public:
SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
SkXfermode::Mode = SkXfermode::kSrcOver_Mode);
SkMergeImageFilter(SkImageFilter* const filters[], int count,
SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[] = NULL);
virtual ~SkMergeImageFilter();

View File

@ -10,7 +10,6 @@
#include "SkBitmap.h"
#include "SkFlattenableBuffers.h"
#include "SkRect.h"
#include "stdarg.h"
SK_DEFINE_INST_COUNT(SkImageFilter)
@ -22,15 +21,18 @@ SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs)
}
}
SkImageFilter::SkImageFilter(int inputCount, ...)
: fInputCount(inputCount), fInputs(new SkImageFilter*[inputCount]) {
va_list ap;
va_start(ap, inputCount);
for (int i = 0; i < inputCount; ++i) {
fInputs[i] = va_arg(ap, SkImageFilter*);
SkSafeRef(fInputs[i]);
}
va_end(ap);
SkImageFilter::SkImageFilter(SkImageFilter* input)
: fInputCount(1), fInputs(new SkImageFilter*[1]) {
fInputs[0] = input;
SkSafeRef(fInputs[0]);
}
SkImageFilter::SkImageFilter(SkImageFilter* input1, SkImageFilter* input2)
: fInputCount(2), fInputs(new SkImageFilter*[2]) {
fInputs[0] = input1;
fInputs[1] = input2;
SkSafeRef(fInputs[0]);
SkSafeRef(fInputs[1]);
}
SkImageFilter::~SkImageFilter() {

View File

@ -52,7 +52,7 @@ SkPMColor multiply_proc(SkPMColor src, SkPMColor dst) {
///////////////////////////////////////////////////////////////////////////////
SkBlendImageFilter::SkBlendImageFilter(SkBlendImageFilter::Mode mode, SkImageFilter* background, SkImageFilter* foreground)
: INHERITED(2, background, foreground), fMode(mode)
: INHERITED(background, foreground), fMode(mode)
{
}

View File

@ -15,7 +15,7 @@
#include "SkGrPixelRef.h"
#endif
SkSingleInputImageFilter::SkSingleInputImageFilter(SkImageFilter* input) : INHERITED(1, input) {
SkSingleInputImageFilter::SkSingleInputImageFilter(SkImageFilter* input) : INHERITED(input) {
}
SkSingleInputImageFilter::~SkSingleInputImageFilter() {

View File

@ -127,7 +127,7 @@ void SkMergeImageFilter::initModes(const SkXfermode::Mode modes[]) {
}
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
SkXfermode::Mode mode) : INHERITED(2, first, second) {
SkXfermode::Mode mode) : INHERITED(first, second) {
if (SkXfermode::kSrcOver_Mode != mode) {
SkXfermode::Mode modes[] = { mode, mode };
this->initModes(modes);
@ -136,7 +136,7 @@ SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* first, SkImageFilter* seco
}
}
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* const filters[], int count,
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[]) : INHERITED(count, filters) {
this->initModes(modes);
}