2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-07-07 13:43:38 +00:00
|
|
|
#include "Test.h"
|
|
|
|
#include "SkBlurMaskFilter.h"
|
|
|
|
#include "SkRandom.h"
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define ILLEGAL_MODE ((SkXfermode::Mode)-1)
|
|
|
|
|
|
|
|
static void test_blur(skiatest::Reporter* reporter) {
|
|
|
|
SkScalar radius = SkIntToScalar(2);
|
|
|
|
|
|
|
|
for (int i = 0; i < SkBlurMaskFilter::kBlurStyleCount; ++i) {
|
|
|
|
SkMaskFilter* filter;
|
|
|
|
SkMaskFilter::BlurInfo info;
|
|
|
|
|
|
|
|
uint32_t flags = i & 3;
|
|
|
|
|
|
|
|
filter = SkBlurMaskFilter::Create(radius, (SkBlurMaskFilter::BlurStyle)i,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
sk_bzero(&info, sizeof(info));
|
|
|
|
SkMaskFilter::BlurType type = filter->asABlur(&info);
|
|
|
|
REPORTER_ASSERT(reporter, type == (SkMaskFilter::BlurType)(i + 1));
|
|
|
|
REPORTER_ASSERT(reporter, info.fRadius == radius);
|
|
|
|
REPORTER_ASSERT(reporter, info.fIgnoreTransform ==
|
|
|
|
SkToBool(flags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag));
|
|
|
|
REPORTER_ASSERT(reporter, info.fHighQuality ==
|
|
|
|
SkToBool(flags & SkBlurMaskFilter::kHighQuality_BlurFlag));
|
|
|
|
|
|
|
|
filter->unref();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "TestClassDef.h"
|
|
|
|
DEFINE_TESTCLASS("BlurMaskFilter", BlurTestClass, test_blur)
|