skia2/include/effects/SkImageSource.h
Xianzhu Wang b449666fa2 Reland "Fix SkImageSource::filterBounds()" again
This relands commit cb4d587666
which was reverted by commit b6d2be1330
because the original CL broke some blink layout tests, and the first
reland was reverted by commit because it broke filterfastbounds gm.

This reland let SkImageSource::onFilterNodeBounds() return the dst rect
with ctm applied when mapping forward or otherwise the default value.

Original description:

> Previously SkImageSource::filterBounds() uses the default
> SkImageFilter::onFilterNodeBounds() which returns the input rect.
>
> Now override onFilterNodeBounds() in SkImageSource to return src
> or dst rect (with transform applied).

Change-Id: I4548981142b9a96beda8339d394cf9943c9f4c0f
Reviewed-on: https://skia-review.googlesource.com/50420
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2017-09-25 19:05:20 +00:00

51 lines
1.5 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkImageSource_DEFINED
#define SkImageSource_DEFINED
#include "SkImage.h"
#include "SkImageFilter.h"
class SK_API SkImageSource : public SkImageFilter {
public:
static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image);
static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image,
const SkRect& srcRect,
const SkRect& dstRect,
SkFilterQuality filterQuality);
SkRect computeFastBounds(const SkRect& src) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
protected:
void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
private:
explicit SkImageSource(sk_sp<SkImage>);
SkImageSource(sk_sp<SkImage>,
const SkRect& srcRect,
const SkRect& dstRect,
SkFilterQuality);
sk_sp<SkImage> fImage;
SkRect fSrcRect, fDstRect;
SkFilterQuality fFilterQuality;
typedef SkImageFilter INHERITED;
};
#endif