Switch internal testing ImageFilters over to new onFilterImage interface

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1854133002

Review URL: https://codereview.chromium.org/1854133002
This commit is contained in:
robertphillips 2016-04-04 12:07:47 -07:00 committed by Commit bot
parent 8ef9108066
commit 4ba94e2610
4 changed files with 40 additions and 28 deletions

View File

@ -14,6 +14,7 @@
#include "SkBlurImageFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkDropShadowImageFilter.h"
#include "SkSpecialImage.h"
#include "SkTestImageFilters.h"
class FailImageFilter : public SkImageFilter {
@ -36,9 +37,9 @@ public:
protected:
FailImageFilter() : INHERITED(nullptr, 0, nullptr) {}
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override {
return false;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override {
return nullptr;
}
private:
@ -77,11 +78,10 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
protected:
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override {
*result = src;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override {
offset->set(0, 0);
return true;
return sk_ref_sp<SkSpecialImage>(source);
}
private:

View File

@ -8,7 +8,6 @@
#include "gm.h"
#include "SkArithmeticMode.h"
#include "SkDevice.h"
#include "SkBlurImageFilter.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
@ -17,6 +16,8 @@
#include "SkImageSource.h"
#include "SkMatrixConvolutionImageFilter.h"
#include "SkReadBuffer.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
#include "SkWriteBuffer.h"
#include "SkMergeImageFilter.h"
#include "SkMorphologyImageFilter.h"
@ -43,28 +44,38 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
protected:
bool onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const override {
SkBitmap source = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInputDeprecated(0, proxy, src, ctx, &source, &srcOffset)) {
return false;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
SkIPoint* offset) const override {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
if (!input) {
return nullptr;
}
SkIRect bounds;
if (!this->applyCropRectDeprecated(ctx, proxy, source, &srcOffset, &bounds, &source)) {
return false;
input = this->applyCropRect(ctx, input.get(), &inputOffset, &bounds);
if (!input) {
return nullptr;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
SkCanvas canvas(device);
SkImageInfo info = SkImageInfo::MakeN32Premul(bounds.width(), bounds.height());
sk_sp<SkSpecialSurface> surf(source->makeSurface(info));
if (!surf) {
return nullptr;
}
SkCanvas* canvas = surf->getCanvas();
SkASSERT(canvas);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &paint);
*dst = device->accessBitmap(false);
input->draw(canvas, fDX - bounds.left(), fDY - bounds.top(), &paint);
offset->fX += bounds.left();
offset->fY += bounds.top();
return true;
return surf->makeImageSnapshot();
}
void flatten(SkWriteBuffer& buffer) const override {

View File

@ -60,10 +60,11 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
protected:
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context& ctx,
SkBitmap* result, SkIPoint* offset) const override {
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
SkIPoint* offset) const override {
REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix);
return true;
offset->fX = offset->fY = 0;
return sk_ref_sp<SkSpecialImage>(source);
}
void flatten(SkWriteBuffer& buffer) const override {

View File

@ -21,6 +21,7 @@
#include "SkPDFUtils.h"
#include "SkReadBuffer.h"
#include "SkScalar.h"
#include "SkSpecialImage.h"
#include "SkStream.h"
#include "SkTypes.h"
#include "Test.h"
@ -373,12 +374,11 @@ public:
bool visited() const { return fVisited; }
protected:
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override {
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override {
fVisited = true;
offset->fX = offset->fY = 0;
*result = src;
return true;
return sk_ref_sp<SkSpecialImage>(source);
}
private: