aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-04 07:13:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-04 07:13:49 -0700
commit3bc969264d4720d67f0b137552b3777a03b431a8 (patch)
tree54124faab382a1531c40a2b32558ee14ca5b5507 /tests
parent94b87bd404d7007ce92672cc1853309df907e12a (diff)
Update SkXfermodeImageFilter to sk_sp
Diffstat (limited to 'tests')
-rw-r--r--tests/ImageFilterTest.cpp33
-rw-r--r--tests/SerializationTest.cpp3
2 files changed, 22 insertions, 14 deletions
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 48d3147ef9..af11bb47fd 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -231,7 +231,10 @@ public:
cropRect).release());
}
this->addFilter("xfermode", SkXfermodeImageFilter::Make(
- SkXfermode::Make(SkXfermode::kSrc_Mode), input, input, cropRect).release());
+ SkXfermode::Make(SkXfermode::kSrc_Mode),
+ sk_ref_sp<SkImageFilter>(input),
+ sk_ref_sp<SkImageFilter>(input),
+ cropRect).release());
}
int count() const { return fFilters.count(); }
SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.get(); }
@@ -839,7 +842,7 @@ DEF_TEST(ImageFilterUnionBounds, reporter) {
// Regardless of which order they appear in, the image filter bounds should
// be combined correctly.
{
- sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(nullptr, offset.get()));
+ sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(nullptr, offset));
SkRect bounds = SkRect::MakeWH(100, 100);
// Intentionally aliasing here, as that's what the real callers do.
bounds = composite->computeFastBounds(bounds);
@@ -847,7 +850,7 @@ DEF_TEST(ImageFilterUnionBounds, reporter) {
}
{
sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(nullptr, nullptr,
- offset.get(), nullptr));
+ offset, nullptr));
SkRect bounds = SkRect::MakeWH(100, 100);
// Intentionally aliasing here, as that's what the real callers do.
bounds = composite->computeFastBounds(bounds);
@@ -1277,21 +1280,25 @@ static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* re
bitmap.allocN32Pixels(1, 1);
bitmap.eraseARGB(255, 255, 255, 255);
- auto green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode));
- SkAutoTUnref<SkImageFilter> greenFilter(SkColorFilterImageFilter::Create(green.get()));
+ sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN,
+ SkXfermode::kSrcIn_Mode));
+ sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Create(green.get()));
SkImageFilter::CropRect cropRect(SkRect::MakeEmpty());
- SkAutoTUnref<SkImageFilter> croppedOut(
+ sk_sp<SkImageFilter> croppedOut(
SkColorFilterImageFilter::Create(green.get(), nullptr, &cropRect));
// Check that an xfermode image filter whose input has been cropped out still draws the other
// input. Also check that drawing with both inputs cropped out doesn't cause a GPU warning.
- auto mode = SkXfermode::Make(SkXfermode::kSrcOver_Mode);
- auto xfermodeNoFg(SkXfermodeImageFilter::Make(mode, greenFilter, croppedOut, nullptr));
- auto xfermodeNoBg(SkXfermodeImageFilter::Make(mode, croppedOut, greenFilter, nullptr));
- auto xfermodeNoFgNoBg(SkXfermodeImageFilter::Make(mode, croppedOut, croppedOut, nullptr));
+ sk_sp<SkXfermode> mode(SkXfermode::Make(SkXfermode::kSrcOver_Mode));
+ sk_sp<SkImageFilter> xfermodeNoFg(SkXfermodeImageFilter::Make(mode, greenFilter,
+ croppedOut, nullptr));
+ sk_sp<SkImageFilter> xfermodeNoBg(SkXfermodeImageFilter::Make(mode, croppedOut,
+ greenFilter, nullptr));
+ sk_sp<SkImageFilter> xfermodeNoFgNoBg(SkXfermodeImageFilter::Make(mode, croppedOut,
+ croppedOut, nullptr));
SkPaint paint;
- paint.setImageFilter(xfermodeNoFg);
+ paint.setImageFilter(std::move(xfermodeNoFg));
canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
uint32_t pixel;
@@ -1299,12 +1306,12 @@ static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* re
canvas->readPixels(info, &pixel, 4, 0, 0);
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
- paint.setImageFilter(xfermodeNoBg);
+ paint.setImageFilter(std::move(xfermodeNoBg));
canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
canvas->readPixels(info, &pixel, 4, 0, 0);
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
- paint.setImageFilter(xfermodeNoFgNoBg);
+ paint.setImageFilter(std::move(xfermodeNoFgNoBg));
canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
canvas->readPixels(info, &pixel, 4, 0, 0);
REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 15b73827ae..9bdfe1e0e6 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -248,7 +248,8 @@ static void TestBitmapSerialization(const SkBitmap& validBitmap,
sk_sp<SkImageFilter> invalidBitmapSource(SkImageSource::Make(std::move(invalidImage)));
sk_sp<SkImageFilter> xfermodeImageFilter(
SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcOver_Mode),
- invalidBitmapSource.get(), validBitmapSource.get(), nullptr));
+ std::move(invalidBitmapSource),
+ std::move(validBitmapSource), nullptr));
SkAutoTUnref<SkImageFilter> deserializedFilter(
TestFlattenableSerialization<SkImageFilter>(