Hide SkImageFilter::CropRect
Moves the (SkRect + flags) struct into SkImageFilter_Base with protected access only. Base constructor and all src/effects/imagefilters Make functions now take a "const SkRect*" instead. CropRect is still what's stored and used by filter implementations during filterImage(), but it's no longer publicly available. The SkImageFilters factory implementations now can go straight to the Make functions in src/effects/imagefilters instead of wrapping its "const SkRect*" in an SkImageFilter::CropRect. Bug: skia:9296, skia:11230 Change-Id: I2c62f42031910ec405623d4519c8a434cd2b3bdd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361496 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Auto-Submit: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
1de89c48c3
commit
747c31e296
@ -7,6 +7,10 @@ This file includes a list of high level updates for each milestone release.
|
||||
Milestone 90
|
||||
------------
|
||||
|
||||
* Remove SkImageFilter::CropRect from the public API as it's no longer usable. All factories
|
||||
work with 'SkRect', 'SkIRect', or nullable pointers to 'Sk[I]Rect'.
|
||||
https://review.skia.org/361496
|
||||
|
||||
* Remove deprecated SkImageFilter factory functions and supporting types. All default-provided
|
||||
SkImageFilters are now only constructed via 'include/effects/SkImageFilters.h'
|
||||
https://review.skia.org/357285
|
||||
|
@ -16,14 +16,6 @@ void Fuzz::next(bool* b) {
|
||||
*b = (n & 1) == 1;
|
||||
}
|
||||
|
||||
void Fuzz::next(SkImageFilter::CropRect* cropRect) {
|
||||
SkRect rect;
|
||||
uint8_t flags;
|
||||
this->next(&rect);
|
||||
this->nextRange(&flags, 0, 0xF);
|
||||
*cropRect = SkImageFilter::CropRect(rect, flags);
|
||||
}
|
||||
|
||||
void Fuzz::nextBytes(void* n, size_t size) {
|
||||
if ((fNextByte + size) > fBytes->size()) {
|
||||
sk_bzero(n, size);
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
|
||||
// Specialized versions for when true random doesn't quite make sense
|
||||
void next(bool* b);
|
||||
void next(SkImageFilter::CropRect* cropRect);
|
||||
void next(SkRegion* region);
|
||||
|
||||
void nextRange(float* f, float min, float max);
|
||||
|
@ -114,7 +114,7 @@ protected:
|
||||
SkISize onISize() override { return SkISize::Make(640, 200); }
|
||||
|
||||
void doDraw(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imgf,
|
||||
const SkRect* clipR = nullptr) {
|
||||
const SkIRect* cropR = nullptr, const SkRect* clipR = nullptr) {
|
||||
SkPaint p;
|
||||
|
||||
if (clipR) {
|
||||
@ -125,12 +125,12 @@ protected:
|
||||
}
|
||||
|
||||
// Visualize the crop rect for debugging
|
||||
if (imgf && as_IFB(imgf)->cropRectIsSet()) {
|
||||
SkImageFilter::CropRect cr = as_IFB(imgf)->getCropRect();
|
||||
|
||||
if (imgf && cropR) {
|
||||
p.setColor(0x66FF00FF);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
canvas->drawRect(cr.rect().makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
|
||||
|
||||
SkRect cr = SkRect::Make(*cropR).makeInset(SK_ScalarHalf, SK_ScalarHalf);
|
||||
canvas->drawRect(cr, p);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
}
|
||||
|
||||
@ -168,17 +168,17 @@ protected:
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr));
|
||||
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr0));
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr0), &cr0);
|
||||
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), &r);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), /* cropR */ nullptr, &r);
|
||||
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr1));
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr1), &cr1);
|
||||
|
||||
SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, nullptr), &clipR);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), /* cropR */ nullptr, &clipR);
|
||||
canvas->restore();
|
||||
|
||||
// 2nd row
|
||||
@ -189,19 +189,19 @@ protected:
|
||||
*/
|
||||
|
||||
// crop==clip==src
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &r);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &cr0, &r);
|
||||
|
||||
// crop==src, clip==dst
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &r2);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &cr0, &r2);
|
||||
|
||||
// crop==dst, clip==src
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &r);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &cr2, &r);
|
||||
|
||||
// crop==clip==dst
|
||||
canvas->translate(100, 0);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &r2);
|
||||
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &cr2, &r2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -30,39 +30,6 @@ class SkColorFilter;
|
||||
*/
|
||||
class SK_API SkImageFilter : public SkFlattenable {
|
||||
public:
|
||||
class CropRect {
|
||||
public:
|
||||
enum CropEdge {
|
||||
kHasLeft_CropEdge = 0x01,
|
||||
kHasTop_CropEdge = 0x02,
|
||||
kHasWidth_CropEdge = 0x04,
|
||||
kHasHeight_CropEdge = 0x08,
|
||||
kHasAll_CropEdge = 0x0F,
|
||||
};
|
||||
CropRect() {}
|
||||
explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
|
||||
: fRect(rect), fFlags(flags) {}
|
||||
uint32_t flags() const { return fFlags; }
|
||||
const SkRect& rect() const { return fRect; }
|
||||
|
||||
/**
|
||||
* Apply this cropRect to the imageBounds. If a given edge of the cropRect is not set, then
|
||||
* the corresponding edge from imageBounds will be used. If "embiggen" is true, the crop
|
||||
* rect is allowed to enlarge the size of the rect, otherwise it may only reduce the rect.
|
||||
* Filters that can affect transparent black should pass "true", while all other filters
|
||||
* should pass "false".
|
||||
*
|
||||
* Note: imageBounds is in "device" space, as the output cropped rectangle will be, so the
|
||||
* matrix is ignored for those. It is only applied to the cropRect's bounds.
|
||||
*/
|
||||
void applyTo(const SkIRect& imageBounds, const SkMatrix& matrix, bool embiggen,
|
||||
SkIRect* cropped) const;
|
||||
|
||||
private:
|
||||
SkRect fRect;
|
||||
uint32_t fFlags;
|
||||
};
|
||||
|
||||
enum MapDirection {
|
||||
kForward_MapDirection,
|
||||
kReverse_MapDirection,
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
CropRect(const SkRect* optionalCrop) : fCropRect(optionalCrop ? *optionalCrop
|
||||
: kNoCropRect) {}
|
||||
|
||||
operator const SkRect*() const { return fCropRect == kNoCropRect ? nullptr : &fCropRect; }
|
||||
|
||||
SkRect fCropRect;
|
||||
};
|
||||
|
||||
|
@ -155,11 +155,10 @@ static int32_t next_image_filter_unique_id() {
|
||||
}
|
||||
|
||||
SkImageFilter_Base::SkImageFilter_Base(sk_sp<SkImageFilter> const* inputs,
|
||||
int inputCount, const CropRect* cropRect)
|
||||
int inputCount, const SkRect* cropRect)
|
||||
: fUsesSrcInput(false)
|
||||
, fCropRect(cropRect)
|
||||
, fUniqueID(next_image_filter_unique_id()) {
|
||||
fCropRect = cropRect ? *cropRect : CropRect(SkRect(), 0x0);
|
||||
|
||||
fInputs.reset(inputCount);
|
||||
|
||||
for (int i = 0; i < inputCount; ++i) {
|
||||
@ -203,7 +202,11 @@ bool SkImageFilter_Base::Common::unflatten(SkReadBuffer& buffer, int expectedCou
|
||||
}
|
||||
|
||||
uint32_t flags = buffer.readUInt();
|
||||
fCropRect = CropRect(rect, flags);
|
||||
if (!buffer.isValid() ||
|
||||
!buffer.validate(flags == 0x0 || flags == CropRect::kHasAll_CropEdge)) {
|
||||
return false;
|
||||
}
|
||||
fCropRect = CropRect(flags ? &rect : nullptr);
|
||||
return buffer.isValid();
|
||||
}
|
||||
|
||||
@ -335,8 +338,8 @@ bool SkImageFilter_Base::canHandleComplexCTM() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds, const SkMatrix& ctm,
|
||||
bool embiggen, SkIRect* cropped) const {
|
||||
void SkImageFilter_Base::CropRect::applyTo(const SkIRect& imageBounds, const SkMatrix& ctm,
|
||||
bool embiggen, SkIRect* cropped) const {
|
||||
*cropped = imageBounds;
|
||||
if (fFlags) {
|
||||
SkRect devCropR;
|
||||
|
@ -101,22 +101,6 @@ public:
|
||||
skif::DeviceSpace<SkIRect> getOutputBounds(
|
||||
const skif::Mapping& mapping, const skif::ParameterSpace<SkRect>& contentBounds) const;
|
||||
|
||||
/**
|
||||
* Returns whether any edges of the crop rect have been set. The crop
|
||||
* rect is set at construction time, and determines which pixels from the
|
||||
* input image will be processed, and which pixels in the output image will be allowed.
|
||||
* The size of the crop rect should be
|
||||
* used as the size of the destination image. The origin of this rect
|
||||
* should be used to offset access to the input images, and should also
|
||||
* be added to the "offset" parameter in onFilterImage.
|
||||
*
|
||||
* DEPRECATED - Remove once cropping is handled by a separate filter
|
||||
*/
|
||||
bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
|
||||
|
||||
// DEPRECATED - Remove once cropping is handled by a separate filter
|
||||
CropRect getCropRect() const { return fCropRect; }
|
||||
|
||||
// Expose isolated node bounds behavior for SampleImageFilterDAG and debugging
|
||||
SkIRect filterNodeBounds(const SkIRect& srcRect, const SkMatrix& ctm,
|
||||
MapDirection dir, const SkIRect* inputRect) const {
|
||||
@ -151,6 +135,43 @@ public:
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
protected:
|
||||
// DEPRECATED: Will be removed once cropping is handled by a standalone image filter
|
||||
class CropRect {
|
||||
public:
|
||||
enum CropEdge {
|
||||
kHasLeft_CropEdge = 0x01,
|
||||
kHasTop_CropEdge = 0x02,
|
||||
kHasWidth_CropEdge = 0x04,
|
||||
kHasHeight_CropEdge = 0x08,
|
||||
kHasAll_CropEdge = 0x0F,
|
||||
};
|
||||
CropRect() : fFlags(0) {}
|
||||
explicit CropRect(const SkRect* rect)
|
||||
: fRect(rect ? *rect : SkRect::MakeEmpty()), fFlags(rect ? kHasAll_CropEdge : 0x0) {}
|
||||
|
||||
// CropRect(const CropRect&) = default;
|
||||
|
||||
uint32_t flags() const { return fFlags; }
|
||||
const SkRect& rect() const { return fRect; }
|
||||
|
||||
/**
|
||||
* Apply this cropRect to the imageBounds. If a given edge of the cropRect is not set, then
|
||||
* the corresponding edge from imageBounds will be used. If "embiggen" is true, the crop
|
||||
* rect is allowed to enlarge the size of the rect, otherwise it may only reduce the rect.
|
||||
* Filters that can affect transparent black should pass "true", while all other filters
|
||||
* should pass "false".
|
||||
*
|
||||
* Note: imageBounds is in "device" space, as the output cropped rectangle will be, so the
|
||||
* matrix is ignored for those. It is only applied to the cropRect's bounds.
|
||||
*/
|
||||
void applyTo(const SkIRect& imageBounds, const SkMatrix& matrix, bool embiggen,
|
||||
SkIRect* cropped) const;
|
||||
|
||||
private:
|
||||
SkRect fRect;
|
||||
uint32_t fFlags;
|
||||
};
|
||||
|
||||
class Common {
|
||||
public:
|
||||
/**
|
||||
@ -163,7 +184,9 @@ protected:
|
||||
*/
|
||||
bool unflatten(SkReadBuffer&, int expectedInputs);
|
||||
|
||||
const CropRect& cropRect() const { return fCropRect; }
|
||||
const SkRect* cropRect() const {
|
||||
return fCropRect.flags() != 0x0 ? &fCropRect.rect() : nullptr;
|
||||
}
|
||||
int inputCount() const { return fInputs.count(); }
|
||||
sk_sp<SkImageFilter>* inputs() { return fInputs.begin(); }
|
||||
|
||||
@ -182,7 +205,7 @@ protected:
|
||||
};
|
||||
|
||||
SkImageFilter_Base(sk_sp<SkImageFilter> const* inputs, int inputCount,
|
||||
const CropRect* cropRect);
|
||||
const SkRect* cropRect);
|
||||
|
||||
~SkImageFilter_Base() override;
|
||||
|
||||
@ -236,6 +259,22 @@ protected:
|
||||
return this->filterInput<For::kInput1>(1, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether any edges of the crop rect have been set. The crop
|
||||
* rect is set at construction time, and determines which pixels from the
|
||||
* input image will be processed, and which pixels in the output image will be allowed.
|
||||
* The size of the crop rect should be
|
||||
* used as the size of the destination image. The origin of this rect
|
||||
* should be used to offset access to the input images, and should also
|
||||
* be added to the "offset" parameter in onFilterImage.
|
||||
*
|
||||
* DEPRECATED - Remove once cropping is handled by a separate filter
|
||||
*/
|
||||
bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
|
||||
|
||||
// DEPRECATED - Remove once cropping is handled by a separate filter
|
||||
CropRect getCropRect() const { return fCropRect; }
|
||||
|
||||
// DEPRECATED - Remove once cropping is handled by a separate filter
|
||||
const CropRect* getCropRectIfSet() const {
|
||||
return this->cropRectIsSet() ? &fCropRect : nullptr;
|
||||
@ -316,8 +355,6 @@ private:
|
||||
|
||||
static void PurgeCache();
|
||||
|
||||
void init(sk_sp<SkImageFilter> const* inputs, int inputCount, const CropRect* cropRect);
|
||||
|
||||
// Configuration points for the filter implementation, marked private since they should not
|
||||
// need to be invoked by the subclasses. These refer to the node's specific behavior and are
|
||||
// not responsible for aggregating the behavior of the entire filter DAG.
|
||||
|
@ -32,7 +32,7 @@ class SkAlphaThresholdFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold,
|
||||
SkScalar outerThreshold, sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect = nullptr)
|
||||
const SkRect* cropRect = nullptr)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fRegion(region)
|
||||
, fInnerThreshold(innerThreshold)
|
||||
@ -65,7 +65,7 @@ private:
|
||||
sk_sp<SkImageFilter> SkAlphaThresholdFilter::Make(const SkRegion& region, SkScalar innerThreshold,
|
||||
SkScalar outerThreshold,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
innerThreshold = SkTPin(innerThreshold, 0.f, 1.f);
|
||||
outerThreshold = SkTPin(outerThreshold, 0.f, 1.f);
|
||||
if (!SkScalarIsFinite(innerThreshold) || !SkScalarIsFinite(outerThreshold)) {
|
||||
@ -88,7 +88,7 @@ sk_sp<SkFlattenable> SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer
|
||||
SkRegion rgn;
|
||||
buffer.readRegion(&rgn);
|
||||
return SkAlphaThresholdFilter::Make(rgn, inner, outer, common.getInput(0),
|
||||
&common.cropRect());
|
||||
common.cropRect());
|
||||
}
|
||||
|
||||
void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
*/
|
||||
static sk_sp<SkImageFilter> Make(const SkRegion& region, SkScalar innerMin,
|
||||
SkScalar outerMax, sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
@ -37,7 +37,7 @@ namespace {
|
||||
class ArithmeticImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
ArithmeticImageFilterImpl(float k1, float k2, float k3, float k4, bool enforcePMColor,
|
||||
sk_sp<SkImageFilter> inputs[2], const CropRect* cropRect)
|
||||
sk_sp<SkImageFilter> inputs[2], const SkRect* cropRect)
|
||||
: INHERITED(inputs, 2, cropRect), fInputs{k1, k2, k3, k4, enforcePMColor} {}
|
||||
|
||||
protected:
|
||||
@ -76,7 +76,7 @@ sk_sp<SkImageFilter> SkArithmeticImageFilter::Make(float k1, float k2, float k3,
|
||||
bool enforcePMColor,
|
||||
sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* crop) {
|
||||
const SkRect* crop) {
|
||||
if (!SkScalarIsFinite(k1) || !SkScalarIsFinite(k2) || !SkScalarIsFinite(k3) ||
|
||||
!SkScalarIsFinite(k4)) {
|
||||
return nullptr;
|
||||
@ -121,7 +121,7 @@ sk_sp<SkFlattenable> ArithmeticImageFilterImpl::CreateProc(SkReadBuffer& buffer)
|
||||
return nullptr;
|
||||
}
|
||||
return SkArithmeticImageFilter::Make(k[0], k[1], k[2], k[3], enforcePMColor, common.getInput(0),
|
||||
common.getInput(1), &common.cropRect());
|
||||
common.getInput(1), common.cropRect());
|
||||
}
|
||||
|
||||
void ArithmeticImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
static sk_sp<SkImageFilter> Make(float k1, float k2, float k3, float k4, bool enforcePMColor,
|
||||
sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* cropRect);
|
||||
const SkRect* cropRect);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace {
|
||||
class SkBlurImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkBlurImageFilterImpl(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
|
||||
sk_sp<SkImageFilter> input, const CropRect* cropRect)
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fSigma{sigmaX, sigmaY}
|
||||
, fTileMode(tileMode) {}
|
||||
@ -81,14 +81,14 @@ static SkTileMode to_sktilemode(SkBlurImageFilter::TileMode tileMode) {
|
||||
|
||||
sk_sp<SkImageFilter> SkBlurImageFilter::Make(SkScalar sigmaX, SkScalar sigmaY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect,
|
||||
const SkRect* cropRect,
|
||||
TileMode tileMode) {
|
||||
return Make(sigmaX, sigmaY, to_sktilemode(tileMode), std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkBlurImageFilter::Make(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (sigmaX < SK_ScalarNearlyZero && sigmaY < SK_ScalarNearlyZero && !cropRect) {
|
||||
return input;
|
||||
}
|
||||
@ -109,7 +109,7 @@ sk_sp<SkFlattenable> SkBlurImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
static_assert(SkBlurImageFilter::kLast_TileMode == 2, "CreateProc");
|
||||
|
||||
return SkBlurImageFilter::Make(
|
||||
sigmaX, sigmaY, tileMode, common.getInput(0), &common.cropRect());
|
||||
sigmaX, sigmaY, tileMode, common.getInput(0), common.cropRect());
|
||||
}
|
||||
|
||||
void SkBlurImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -30,12 +30,12 @@ public:
|
||||
|
||||
static sk_sp<SkImageFilter> Make(SkScalar sigmaX, SkScalar sigmaY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr,
|
||||
const SkRect* cropRect = nullptr,
|
||||
TileMode tileMode = TileMode::kClampToBlack_TileMode);
|
||||
// EXPERIMENTAL: kMirror is not yet supported
|
||||
static sk_sp<SkImageFilter> Make(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace {
|
||||
class SkColorFilterImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkColorFilterImageFilterImpl(sk_sp<SkColorFilter> cf, sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fColorFilter(std::move(cf)) {}
|
||||
|
||||
@ -45,7 +45,7 @@ private:
|
||||
|
||||
sk_sp<SkImageFilter> SkColorFilterImageFilter::Make(sk_sp<SkColorFilter> cf,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!cf) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -76,7 +76,7 @@ void SkColorFilterImageFilter::RegisterFlattenables() {
|
||||
sk_sp<SkFlattenable> SkColorFilterImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
sk_sp<SkColorFilter> cf(buffer.readColorFilter());
|
||||
return SkColorFilterImageFilter::Make(std::move(cf), common.getInput(0), &common.cropRect());
|
||||
return SkColorFilterImageFilter::Make(std::move(cf), common.getInput(0), common.cropRect());
|
||||
}
|
||||
|
||||
void SkColorFilterImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -16,7 +16,7 @@ class SK_API SkColorFilterImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkColorFilter> cf,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -35,7 +35,7 @@ class SkDisplacementMapEffectImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkDisplacementMapEffectImpl(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector,
|
||||
SkScalar scale, sk_sp<SkImageFilter> inputs[2],
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(inputs, 2, cropRect)
|
||||
, fXChannelSelector(xChannelSelector)
|
||||
, fYChannelSelector(yChannelSelector)
|
||||
@ -128,7 +128,7 @@ sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(ChannelSelectorType xChannelS
|
||||
SkScalar scale,
|
||||
sk_sp<SkImageFilter> displacement,
|
||||
sk_sp<SkImageFilter> color,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
return Make(convert_channel_type(xChannelSelector), convert_channel_type(yChannelSelector),
|
||||
scale, std::move(displacement), std::move(color), cropRect);
|
||||
}
|
||||
@ -138,7 +138,7 @@ sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(SkColorChannel xChannelSelect
|
||||
SkScalar scale,
|
||||
sk_sp<SkImageFilter> displacement,
|
||||
sk_sp<SkImageFilter> color,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!channel_selector_type_is_valid(xChannelSelector) ||
|
||||
!channel_selector_type_is_valid(yChannelSelector)) {
|
||||
return nullptr;
|
||||
@ -165,7 +165,7 @@ sk_sp<SkFlattenable> SkDisplacementMapEffectImpl::CreateProc(SkReadBuffer& buffe
|
||||
SkScalar scale = buffer.readScalar();
|
||||
|
||||
return SkDisplacementMapEffect::Make(xsel, ysel, scale, common.getInput(0), common.getInput(1),
|
||||
&common.cropRect());
|
||||
common.cropRect());
|
||||
}
|
||||
|
||||
void SkDisplacementMapEffectImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -32,13 +32,13 @@ public:
|
||||
SkScalar scale,
|
||||
sk_sp<SkImageFilter> displacement,
|
||||
sk_sp<SkImageFilter> color,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> Make(SkColorChannel xChannelSelector,
|
||||
SkColorChannel yChannelSelector,
|
||||
SkScalar scale,
|
||||
sk_sp<SkImageFilter> displacement,
|
||||
sk_sp<SkImageFilter> color,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -21,7 +21,7 @@ class SkDropShadowImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkDropShadowImageFilterImpl(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY,
|
||||
SkColor color, bool shadowOnly, sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fDx(dx)
|
||||
, fDy(dy)
|
||||
@ -55,7 +55,7 @@ sk_sp<SkImageFilter> SkDropShadowImageFilter::Make(SkScalar dx, SkScalar dy,
|
||||
SkScalar sigmaX, SkScalar sigmaY,
|
||||
SkColor color, ShadowMode shadowMode,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
bool shadowOnly = shadowMode == SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode;
|
||||
return sk_sp<SkImageFilter>(new SkDropShadowImageFilterImpl(
|
||||
dx, dy, sigmaX, sigmaY, color, shadowOnly, std::move(input), cropRect));
|
||||
@ -84,7 +84,7 @@ sk_sp<SkFlattenable> SkDropShadowImageFilterImpl::CreateProc(SkReadBuffer& buffe
|
||||
// TODO (michaelludwig) - TODO: Call factory function once SkDropShadowImageFilter::Make no
|
||||
// longer takes the old enum as its argument
|
||||
return sk_sp<SkImageFilter>(new SkDropShadowImageFilterImpl(
|
||||
dx, dy, sigmaX, sigmaY, color, shadowOnly, common.getInput(0), &common.cropRect()));
|
||||
dx, dy, sigmaX, sigmaY, color, shadowOnly, common.getInput(0), common.cropRect()));
|
||||
}
|
||||
|
||||
void SkDropShadowImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
static sk_sp<SkImageFilter> Make(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY,
|
||||
SkColor color, ShadowMode shadowMode,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -32,15 +32,6 @@
|
||||
// filter can be moved out of core
|
||||
#include "src/core/SkMatrixImageFilter.h"
|
||||
|
||||
// TODO (michaelludwig) - We are phasing out the use of SkImageFilter::CropRect since it does not
|
||||
// appear as though edge flags are actually used and will move towards an explicit cropping filter.
|
||||
// To assist with this, the new factory functions just take the basic rects even though the
|
||||
// implementations have not been updated yet.
|
||||
static SkImageFilter::CropRect to_legacy_crop_rect(const SkImageFilters::CropRect& cropRect) {
|
||||
return cropRect.fCropRect.isFinite() ? SkImageFilter::CropRect(cropRect.fCropRect)
|
||||
: SkImageFilter::CropRect(SkRect::MakeEmpty(), 0x0);
|
||||
}
|
||||
|
||||
// Allow kNoCropRect to be referenced (for certain builds, e.g. macOS libFuzzer chromium target,
|
||||
// see crbug.com/1139725)
|
||||
constexpr SkRect SkImageFilters::CropRect::kNoCropRect;
|
||||
@ -71,37 +62,33 @@ void SkImageFilters::RegisterFlattenables() {
|
||||
sk_sp<SkImageFilter> SkImageFilters::AlphaThreshold(
|
||||
const SkRegion& region, SkScalar innerMin, SkScalar outerMax, sk_sp<SkImageFilter> input,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkAlphaThresholdFilter::Make(region, innerMin, outerMax, std::move(input), &r);
|
||||
return SkAlphaThresholdFilter::Make(region, innerMin, outerMax, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Arithmetic(
|
||||
SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor,
|
||||
sk_sp<SkImageFilter> background, sk_sp<SkImageFilter> foreground,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkArithmeticImageFilter::Make(k1, k2, k3, k4, enforcePMColor, std::move(background),
|
||||
std::move(foreground), &r);
|
||||
std::move(foreground), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Blend(
|
||||
SkBlendMode mode, sk_sp<SkImageFilter> background, sk_sp<SkImageFilter> foreground,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkXfermodeImageFilter::Make(mode, std::move(background), std::move(foreground), &r);
|
||||
return SkXfermodeImageFilter::Make(mode, std::move(background), std::move(foreground),
|
||||
cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Blur(
|
||||
SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp<SkImageFilter> input,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkBlurImageFilter::Make(sigmaX, sigmaY, tileMode, std::move(input), &r);
|
||||
return SkBlurImageFilter::Make(sigmaX, sigmaY, tileMode, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::ColorFilter(
|
||||
sk_sp<SkColorFilter> cf, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkColorFilterImageFilter::Make(std::move(cf), std::move(input), &r);
|
||||
return SkColorFilterImageFilter::Make(std::move(cf), std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Compose(
|
||||
@ -112,32 +99,29 @@ sk_sp<SkImageFilter> SkImageFilters::Compose(
|
||||
sk_sp<SkImageFilter> SkImageFilters::DisplacementMap(
|
||||
SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale,
|
||||
sk_sp<SkImageFilter> displacement, sk_sp<SkImageFilter> color, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
|
||||
std::move(displacement), std::move(color), &r);
|
||||
std::move(displacement), std::move(color), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::DropShadow(
|
||||
SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
// TODO (michaelludwig) - Once SkDropShadowImageFilter is fully hidden, this can be updated to
|
||||
// pass a constant bool into the internal factory.
|
||||
return SkDropShadowImageFilter::Make(
|
||||
dx, dy, sigmaX, sigmaY, color,
|
||||
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
|
||||
std::move(input), &r);
|
||||
std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::DropShadowOnly(
|
||||
SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
// TODO (michaelludwig) - Once SkDropShadowImageFilter is fully hidden, this can be updated to
|
||||
// pass a constant bool into the internal factory.
|
||||
return SkDropShadowImageFilter::Make(dx, dy, sigmaX, sigmaY, color,
|
||||
SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode,
|
||||
std::move(input), &r);
|
||||
std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Image(
|
||||
@ -149,17 +133,16 @@ sk_sp<SkImageFilter> SkImageFilters::Image(
|
||||
sk_sp<SkImageFilter> SkImageFilters::Magnifier(
|
||||
const SkRect& srcRect, SkScalar inset, sk_sp<SkImageFilter> input,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkMagnifierImageFilter::Make(srcRect, inset, std::move(input), &r);
|
||||
return SkMagnifierImageFilter::Make(srcRect, inset, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::MatrixConvolution(
|
||||
const SkISize& kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias,
|
||||
const SkIPoint& kernelOffset, SkTileMode tileMode, bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkMatrixConvolutionImageFilter::Make(kernelSize, kernel, gain, bias, kernelOffset,
|
||||
tileMode, convolveAlpha, std::move(input), &r);
|
||||
tileMode, convolveAlpha, std::move(input),
|
||||
cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::MatrixTransform(
|
||||
@ -169,19 +152,16 @@ sk_sp<SkImageFilter> SkImageFilters::MatrixTransform(
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Merge(
|
||||
sk_sp<SkImageFilter>* const filters, int count, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkMergeImageFilter::Make(filters, count, &r);
|
||||
return SkMergeImageFilter::Make(filters, count, cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Offset(
|
||||
SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkOffsetImageFilter::Make(dx, dy, std::move(input), &r);
|
||||
return SkOffsetImageFilter::Make(dx, dy, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Paint(const SkPaint& paint, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkPaintImageFilter::Make(paint, &r);
|
||||
return SkPaintImageFilter::Make(paint, cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Picture(sk_sp<SkPicture> pic, const SkRect& targetRect) {
|
||||
@ -191,13 +171,12 @@ sk_sp<SkImageFilter> SkImageFilters::Picture(sk_sp<SkPicture> pic, const SkRect&
|
||||
sk_sp<SkImageFilter> SkImageFilters::Shader(sk_sp<SkShader> shader, Dither dither,
|
||||
SkFilterQuality filterQuality,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
SkPaint paint;
|
||||
paint.setShader(std::move(shader));
|
||||
paint.setDither((bool) dither);
|
||||
// For SkImage::makeShader() shaders using SkImageShader::kInheritFromPaint sampling options
|
||||
paint.setFilterQuality(filterQuality);
|
||||
return SkPaintImageFilter::Make(paint, &r);
|
||||
return SkPaintImageFilter::Make(paint, cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Tile(
|
||||
@ -209,14 +188,12 @@ sk_sp<SkImageFilter> SkImageFilters::Tile(
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Dilate(
|
||||
SkScalar radiusX, SkScalar radiusY, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkDilateImageFilter::Make(radiusX, radiusY, std::move(input), &r);
|
||||
return SkDilateImageFilter::Make(radiusX, radiusY, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::Erode(
|
||||
SkScalar radiusX, SkScalar radiusY, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkErodeImageFilter::Make(radiusX, radiusY, std::move(input), &r);
|
||||
return SkErodeImageFilter::Make(radiusX, radiusY, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
// Lighting filter effects
|
||||
@ -224,51 +201,45 @@ sk_sp<SkImageFilter> SkImageFilters::Erode(
|
||||
sk_sp<SkImageFilter> SkImageFilters::DistantLitDiffuse(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakeDistantLitDiffuse(direction, lightColor, surfaceScale, kd,
|
||||
std::move(input), &r);
|
||||
std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::PointLitDiffuse(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakePointLitDiffuse(location, lightColor, surfaceScale, kd,
|
||||
std::move(input), &r);
|
||||
std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::SpotLitDiffuse(
|
||||
const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent,
|
||||
SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakeSpotLitDiffuse(location, target, falloffExponent, cutoffAngle,
|
||||
lightColor, surfaceScale, kd,
|
||||
std::move(input), &r);
|
||||
std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::DistantLitSpecular(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakeDistantLitSpecular(direction, lightColor, surfaceScale,
|
||||
ks, shininess, std::move(input), &r);
|
||||
ks, shininess, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::PointLitSpecular(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakePointLitSpecular(location, lightColor, surfaceScale, ks,
|
||||
shininess, std::move(input), &r);
|
||||
shininess, std::move(input), cropRect);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SkImageFilters::SpotLitSpecular(
|
||||
const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent,
|
||||
SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
return SkLightingImageFilter::MakeSpotLitSpecular(location, target, falloffExponent,
|
||||
cutoffAngle, lightColor, surfaceScale,
|
||||
ks, shininess, std::move(input), &r);
|
||||
ks, shininess, std::move(input), cropRect);
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ protected:
|
||||
SkLightingImageFilterInternal(sk_sp<SkImageFilterLight> light,
|
||||
SkScalar surfaceScale,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fLight(std::move(light))
|
||||
, fSurfaceScale(surfaceScale / 255) {}
|
||||
@ -544,14 +544,14 @@ public:
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
sk_sp<SkImageFilter>,
|
||||
const CropRect*);
|
||||
const SkRect*);
|
||||
|
||||
SkScalar kd() const { return fKD; }
|
||||
|
||||
protected:
|
||||
SkDiffuseLightingImageFilter(sk_sp<SkImageFilterLight> light, SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const CropRect* cropRect);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect);
|
||||
void flatten(SkWriteBuffer& buffer) const override;
|
||||
|
||||
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
|
||||
@ -577,7 +577,7 @@ public:
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess,
|
||||
sk_sp<SkImageFilter>, const CropRect*);
|
||||
sk_sp<SkImageFilter>, const SkRect*);
|
||||
|
||||
SkScalar ks() const { return fKS; }
|
||||
SkScalar shininess() const { return fShininess; }
|
||||
@ -586,7 +586,7 @@ protected:
|
||||
SkSpecularLightingImageFilter(sk_sp<SkImageFilterLight> light,
|
||||
SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input, const CropRect*);
|
||||
sk_sp<SkImageFilter> input, const SkRect*);
|
||||
void flatten(SkWriteBuffer& buffer) const override;
|
||||
|
||||
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
|
||||
@ -1142,7 +1142,7 @@ void SkImageFilterLight::flattenLight(SkWriteBuffer& buffer) const {
|
||||
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakeDistantLitDiffuse(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(new SkDistantLight(direction, lightColor));
|
||||
return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd,
|
||||
std::move(input), cropRect);
|
||||
@ -1150,7 +1150,7 @@ sk_sp<SkImageFilter> SkLightingImageFilter::MakeDistantLitDiffuse(
|
||||
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakePointLitDiffuse(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(new SkPointLight(location, lightColor));
|
||||
return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd,
|
||||
std::move(input), cropRect);
|
||||
@ -1159,7 +1159,7 @@ sk_sp<SkImageFilter> SkLightingImageFilter::MakePointLitDiffuse(
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakeSpotLitDiffuse(
|
||||
const SkPoint3& location, const SkPoint3& target, SkScalar specularExponent,
|
||||
SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(
|
||||
new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor));
|
||||
return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd,
|
||||
@ -1168,7 +1168,7 @@ sk_sp<SkImageFilter> SkLightingImageFilter::MakeSpotLitDiffuse(
|
||||
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakeDistantLitSpecular(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(new SkDistantLight(direction, lightColor));
|
||||
return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess,
|
||||
std::move(input), cropRect);
|
||||
@ -1176,7 +1176,7 @@ sk_sp<SkImageFilter> SkLightingImageFilter::MakeDistantLitSpecular(
|
||||
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakePointLitSpecular(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(new SkPointLight(location, lightColor));
|
||||
return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess,
|
||||
std::move(input), cropRect);
|
||||
@ -1185,7 +1185,7 @@ sk_sp<SkImageFilter> SkLightingImageFilter::MakePointLitSpecular(
|
||||
sk_sp<SkImageFilter> SkLightingImageFilter::MakeSpotLitSpecular(
|
||||
const SkPoint3& location, const SkPoint3& target, SkScalar specularExponent,
|
||||
SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect) {
|
||||
SkScalar shininess, sk_sp<SkImageFilter> input, const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilterLight> light(
|
||||
new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor));
|
||||
return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess,
|
||||
@ -1198,7 +1198,7 @@ sk_sp<SkImageFilter> SkDiffuseLightingImageFilter::Make(sk_sp<SkImageFilterLight
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!light) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1218,7 +1218,7 @@ SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(sk_sp<SkImageFilterLi
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(std::move(light), surfaceScale, std::move(input), cropRect)
|
||||
, fKD(kd) {
|
||||
}
|
||||
@ -1230,7 +1230,7 @@ sk_sp<SkFlattenable> SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buff
|
||||
SkScalar surfaceScale = buffer.readScalar();
|
||||
SkScalar kd = buffer.readScalar();
|
||||
|
||||
return Make(std::move(light), surfaceScale, kd, common.getInput(0), &common.cropRect());
|
||||
return Make(std::move(light), surfaceScale, kd, common.getInput(0), common.cropRect());
|
||||
}
|
||||
|
||||
void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
@ -1328,7 +1328,7 @@ sk_sp<SkImageFilter> SkSpecularLightingImageFilter::Make(sk_sp<SkImageFilterLigh
|
||||
SkScalar ks,
|
||||
SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!light) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1350,7 +1350,7 @@ SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(sk_sp<SkImageFilter
|
||||
SkScalar ks,
|
||||
SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(std::move(light), surfaceScale, std::move(input), cropRect)
|
||||
, fKS(ks)
|
||||
, fShininess(shininess) {
|
||||
@ -1364,7 +1364,7 @@ sk_sp<SkFlattenable> SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buf
|
||||
SkScalar shine = buffer.readScalar();
|
||||
|
||||
return Make(std::move(light), surfaceScale, ks, shine, common.getInput(0),
|
||||
&common.cropRect());
|
||||
common.cropRect());
|
||||
}
|
||||
|
||||
void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -18,24 +18,24 @@ class SK_API SkLightingImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> MakeDistantLitDiffuse(const SkPoint3& direction,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> MakePointLitDiffuse(const SkPoint3& location,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> MakeSpotLitDiffuse(const SkPoint3& location,
|
||||
const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> MakeDistantLitSpecular(const SkPoint3& direction,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> MakePointLitSpecular(const SkPoint3& location,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
static sk_sp<SkImageFilter> MakeSpotLitSpecular(const SkPoint3& location,
|
||||
const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess,
|
||||
sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace {
|
||||
class SkMagnifierImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkMagnifierImageFilterImpl(const SkRect& srcRect, SkScalar inset, sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fSrcRect(srcRect)
|
||||
, fInset(inset) {
|
||||
@ -58,7 +58,7 @@ private:
|
||||
|
||||
sk_sp<SkImageFilter> SkMagnifierImageFilter::Make(const SkRect& srcRect, SkScalar inset,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -86,7 +86,7 @@ sk_sp<SkFlattenable> SkMagnifierImageFilterImpl::CreateProc(SkReadBuffer& buffer
|
||||
SkRect src;
|
||||
buffer.readRect(&src);
|
||||
return SkMagnifierImageFilter::Make(src, buffer.readScalar(), common.getInput(0),
|
||||
&common.cropRect());
|
||||
common.cropRect());
|
||||
}
|
||||
|
||||
void SkMagnifierImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -17,7 +17,7 @@ class SK_API SkMagnifierImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(const SkRect& srcRect, SkScalar inset,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
SkMatrixConvolutionImageFilterImpl(const SkISize& kernelSize, const SkScalar* kernel,
|
||||
SkScalar gain, SkScalar bias, const SkIPoint& kernelOffset,
|
||||
SkTileMode tileMode, bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input, const CropRect* cropRect)
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fKernelSize(kernelSize)
|
||||
, fGain(gain)
|
||||
@ -164,7 +164,7 @@ sk_sp<SkImageFilter> SkMatrixConvolutionImageFilter::Make(const SkISize& kernelS
|
||||
TileMode tileMode,
|
||||
bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
return Make(kernelSize, kernel, gain, bias, kernelOffset, to_sktilemode(tileMode),
|
||||
convolveAlpha, std::move(input), cropRect);
|
||||
}
|
||||
@ -177,7 +177,7 @@ sk_sp<SkImageFilter> SkMatrixConvolutionImageFilter::Make(const SkISize& kernelS
|
||||
SkTileMode tileMode,
|
||||
bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
// We need to be able to read at most SK_MaxS32 bytes, so divide that
|
||||
// by the size of a scalar to know how many scalars we can read.
|
||||
static constexpr int32_t kMaxKernelSize = SK_MaxS32 / sizeof(SkScalar);
|
||||
@ -242,7 +242,7 @@ sk_sp<SkFlattenable> SkMatrixConvolutionImageFilterImpl::CreateProc(SkReadBuffer
|
||||
}
|
||||
return SkMatrixConvolutionImageFilter::Make(
|
||||
kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode,
|
||||
convolveAlpha, common.getInput(0), &common.cropRect());
|
||||
convolveAlpha, common.getInput(0), common.cropRect());
|
||||
}
|
||||
|
||||
void SkMatrixConvolutionImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
TileMode tileMode,
|
||||
bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
/** Construct a matrix convolution image filter.
|
||||
@param kernelSize The kernel size in pixels, in each dimension (N by M).
|
||||
@ -77,7 +77,7 @@ public:
|
||||
SkTileMode tileMode,
|
||||
bool convolveAlpha,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace {
|
||||
class SkMergeImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkMergeImageFilterImpl(sk_sp<SkImageFilter>* const filters, int count,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(filters, count, cropRect) {
|
||||
SkASSERT(count >= 0);
|
||||
}
|
||||
@ -39,7 +39,7 @@ private:
|
||||
} // end namespace
|
||||
|
||||
sk_sp<SkImageFilter> SkMergeImageFilter::Make(sk_sp<SkImageFilter>* const filters, int count,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
return sk_sp<SkImageFilter>(new SkMergeImageFilterImpl(filters, count, cropRect));
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ sk_sp<SkFlattenable> SkMergeImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
if (!common.unflatten(buffer, -1) || !buffer.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkMergeImageFilter::Make(common.inputs(), common.inputCount(), &common.cropRect());
|
||||
return SkMergeImageFilter::Make(common.inputs(), common.inputCount(), common.cropRect());
|
||||
}
|
||||
|
||||
sk_sp<SkSpecialImage> SkMergeImageFilterImpl::onFilterImage(const Context& ctx,
|
||||
|
@ -14,10 +14,10 @@
|
||||
class SK_API SkMergeImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter>* const filters, int count,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter> first, sk_sp<SkImageFilter> second,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr) {
|
||||
const SkRect* cropRect = nullptr) {
|
||||
sk_sp<SkImageFilter> array[] = {
|
||||
std::move(first),
|
||||
std::move(second),
|
||||
|
@ -42,7 +42,7 @@ enum class MorphDirection { kX, kY };
|
||||
class SkMorphologyImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkMorphologyImageFilterImpl(MorphType type, SkScalar radiusX, SkScalar radiusY,
|
||||
sk_sp<SkImageFilter> input, const CropRect* cropRect)
|
||||
sk_sp<SkImageFilter> input, const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect)
|
||||
, fType(type)
|
||||
, fRadius(SkSize::Make(radiusX, radiusY)) {}
|
||||
@ -87,7 +87,7 @@ private:
|
||||
|
||||
sk_sp<SkImageFilter> SkDilateImageFilter::Make(SkScalar radiusX, SkScalar radiusY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (radiusX < 0 || radiusY < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -97,7 +97,7 @@ sk_sp<SkImageFilter> SkDilateImageFilter::Make(SkScalar radiusX, SkScalar radius
|
||||
|
||||
sk_sp<SkImageFilter> SkErodeImageFilter::Make(SkScalar radiusX, SkScalar radiusY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (radiusX < 0 || radiusY < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -126,9 +126,9 @@ sk_sp<SkFlattenable> SkMorphologyImageFilterImpl::CreateProc(SkReadBuffer& buffe
|
||||
MorphType filterType = buffer.read32LE(MorphType::kLastType);
|
||||
|
||||
if (filterType == MorphType::kDilate) {
|
||||
return SkDilateImageFilter::Make(width, height, common.getInput(0), &common.cropRect());
|
||||
return SkDilateImageFilter::Make(width, height, common.getInput(0), common.cropRect());
|
||||
} else if (filterType == MorphType::kErode) {
|
||||
return SkErodeImageFilter::Make(width, height, common.getInput(0), &common.cropRect());
|
||||
return SkErodeImageFilter::Make(width, height, common.getInput(0), common.cropRect());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class SK_API SkDilateImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(SkScalar radiusX, SkScalar radiusY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
// Registers all morphology filter implementations
|
||||
static void RegisterFlattenables();
|
||||
@ -31,7 +31,7 @@ class SK_API SkErodeImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(SkScalar radiusX, SkScalar radiusY,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
private:
|
||||
SkErodeImageFilter() = delete;
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
class SkOffsetImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkOffsetImageFilterImpl(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input,
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(&input, 1, cropRect) {
|
||||
fOffset.set(dx, dy);
|
||||
}
|
||||
@ -48,7 +48,7 @@ private:
|
||||
|
||||
sk_sp<SkImageFilter> SkOffsetImageFilter::Make(SkScalar dx, SkScalar dy,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -69,7 +69,7 @@ sk_sp<SkFlattenable> SkOffsetImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
SkPoint offset;
|
||||
buffer.readPoint(&offset);
|
||||
return SkOffsetImageFilter::Make(offset.x(), offset.y(), common.getInput(0),
|
||||
&common.cropRect());
|
||||
common.cropRect());
|
||||
}
|
||||
|
||||
void SkOffsetImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -15,7 +15,7 @@ class SK_API SkOffsetImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(SkScalar dx, SkScalar dy,
|
||||
sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace {
|
||||
|
||||
class SkPaintImageFilterImpl final : public SkImageFilter_Base {
|
||||
public:
|
||||
SkPaintImageFilterImpl(const SkPaint& paint, const CropRect* rect)
|
||||
SkPaintImageFilterImpl(const SkPaint& paint, const SkRect* rect)
|
||||
: INHERITED(nullptr, 0, rect)
|
||||
, fPaint(paint) {}
|
||||
|
||||
@ -41,7 +41,7 @@ private:
|
||||
} // end namespace
|
||||
|
||||
sk_sp<SkImageFilter> SkPaintImageFilter::Make(const SkPaint& paint,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
return sk_sp<SkImageFilter>(new SkPaintImageFilterImpl(paint, cropRect));
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ sk_sp<SkFlattenable> SkPaintImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
|
||||
SkPaint paint;
|
||||
buffer.readPaint(&paint, nullptr);
|
||||
return SkPaintImageFilter::Make(paint, &common.cropRect());
|
||||
return SkPaintImageFilter::Make(paint, common.cropRect());
|
||||
}
|
||||
|
||||
void SkPaintImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
* instead.
|
||||
*/
|
||||
static sk_sp<SkImageFilter> Make(const SkPaint& paint,
|
||||
const SkImageFilter::CropRect* cropRect = nullptr);
|
||||
const SkRect* cropRect = nullptr);
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
|
@ -63,11 +63,8 @@ sk_sp<SkImageFilter> SkTileImageFilter::Make(const SkRect& srcRect, const SkRect
|
||||
if (!ir.intersect(srcRect)) {
|
||||
return input;
|
||||
}
|
||||
SkImageFilter::CropRect cropRect(ir);
|
||||
return SkOffsetImageFilter::Make(dstRect.x() - srcRect.x(),
|
||||
dstRect.y() - srcRect.y(),
|
||||
std::move(input),
|
||||
&cropRect);
|
||||
return SkOffsetImageFilter::Make(dstRect.x() - srcRect.x(), dstRect.y() - srcRect.y(),
|
||||
std::move(input), &ir);
|
||||
}
|
||||
return sk_sp<SkImageFilter>(new SkTileImageFilterImpl(srcRect, dstRect, std::move(input)));
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace {
|
||||
class SkXfermodeImageFilterImpl : public SkImageFilter_Base {
|
||||
public:
|
||||
SkXfermodeImageFilterImpl(SkBlendMode mode, sk_sp<SkImageFilter> inputs[2],
|
||||
const CropRect* cropRect)
|
||||
const SkRect* cropRect)
|
||||
: INHERITED(inputs, 2, cropRect)
|
||||
, fMode(mode) {}
|
||||
|
||||
@ -69,7 +69,7 @@ private:
|
||||
sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(SkBlendMode mode,
|
||||
sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
const SkRect* cropRect) {
|
||||
sk_sp<SkImageFilter> inputs[2] = { std::move(background), std::move(foreground) };
|
||||
return sk_sp<SkImageFilter>(new SkXfermodeImageFilterImpl(mode, inputs, cropRect));
|
||||
}
|
||||
@ -95,7 +95,7 @@ sk_sp<SkFlattenable> SkXfermodeImageFilterImpl::CreateProc(SkReadBuffer& buffer)
|
||||
return nullptr;
|
||||
}
|
||||
return SkXfermodeImageFilter::Make((SkBlendMode)mode, common.getInput(0),
|
||||
common.getInput(1), &common.cropRect());
|
||||
common.getInput(1), common.cropRect());
|
||||
}
|
||||
|
||||
void SkXfermodeImageFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -20,7 +20,7 @@ class SK_API SkXfermodeImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(SkBlendMode, sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* cropRect);
|
||||
const SkRect* cropRect);
|
||||
static sk_sp<SkImageFilter> Make(SkBlendMode mode, sk_sp<SkImageFilter> background) {
|
||||
return Make(mode, std::move(background), nullptr, nullptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user