Reimplement deserialization of SkImageFilter's uniqueID.

9fa60d ("Simplify flattening to just write enough ... ") simplified just
a tad too much. In particular, it disabled deserialization of
SkImageFilter's uniqueID, which in turn caused the failure of
SkImageFilter's cache, which caused a large regression in Chrome's SVG
filter performance.

The medium-term fix is to switch to the new SkRecordDraw SkPicture
backend, which will make the unique IDs unnecessary.

This change is an "in case of emergecy" CL, in the event that there are
problems switching on the new backend in Chrome. For that reason, it's
minimalist: only the filters used by Chrome are modified, and whitespace
changes are kept to a minimum. In this way, it should be easy to revert
once the new backend goes in.

R=reed@google.com

Author: senorblanco@chromium.org

Review URL: https://codereview.chromium.org/503833002
This commit is contained in:
senorblanco 2014-08-26 12:27:12 -07:00 коммит произвёл Commit bot
Родитель 21aed57023
Коммит 5e5f948b6b
30 изменённых файлов: 149 добавлений и 117 удалений

Просмотреть файл

@ -237,7 +237,7 @@ protected:
void allocInputs(int count);
};
SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL);
SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL, uint32_t uniqueID = 0);
virtual ~SkImageFilter();

Просмотреть файл

@ -16,8 +16,8 @@ public:
static SkBlurImageFilter* Create(SkScalar sigmaX,
SkScalar sigmaY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
return SkNEW_ARGS(SkBlurImageFilter, (sigmaX, sigmaY, input, cropRect));
const CropRect* cropRect = NULL, uint32_t uniqueID = 0) {
return SkNEW_ARGS(SkBlurImageFilter, (sigmaX, sigmaY, input, cropRect, uniqueID));
}
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
@ -28,7 +28,8 @@ protected:
SkBlurImageFilter(SkScalar sigmaX,
SkScalar sigmaY,
SkImageFilter* input,
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkBlurImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -16,7 +16,8 @@ class SK_API SkColorFilterImageFilter : public SkImageFilter {
public:
static SkColorFilterImageFilter* Create(SkColorFilter* cf,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL);
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0);
virtual ~SkColorFilterImageFilter();
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
@ -35,7 +36,8 @@ protected:
private:
SkColorFilterImageFilter(SkColorFilter* cf,
SkImageFilter* input,
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
SkColorFilter* fColorFilter;
typedef SkImageFilter INHERITED;

Просмотреть файл

@ -27,7 +27,8 @@ public:
ChannelSelectorType yChannelSelector,
SkScalar scale, SkImageFilter* displacement,
SkImageFilter* color = NULL,
const CropRect* cropRect = NULL);
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
@ -51,7 +52,8 @@ protected:
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale, SkImageFilter* inputs[2],
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -14,16 +14,17 @@ public:
static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy,
SkScalar sigmaX, SkScalar sigmaY, SkColor color,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY,
color, input, cropRect));
color, input, cropRect, uniqueID));
}
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
protected:
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
SkImageFilter* input, const CropRect* cropRect);
SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkDropShadowImageFilter(SkReadBuffer&);
#endif

Просмотреть файл

@ -73,7 +73,8 @@ protected:
SkLightingImageFilter(SkLight* light,
SkScalar surfaceScale,
SkImageFilter* input,
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkLightingImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -60,10 +60,11 @@ public:
TileMode tileMode,
bool convolveAlpha,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
return SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias,
kernelOffset, tileMode, convolveAlpha,
input, cropRect));
input, cropRect, uniqueID));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
@ -77,7 +78,8 @@ protected:
TileMode tileMode,
bool convolveAlpha,
SkImageFilter* input,
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkMatrixConvolutionImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -30,7 +30,8 @@ public:
static SkMatrixImageFilter* Create(const SkMatrix& transform,
SkPaint::FilterLevel,
SkImageFilter* input = NULL);
SkImageFilter* input = NULL,
uint32_t uniqueID = 0);
virtual ~SkMatrixImageFilter();
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
@ -40,7 +41,8 @@ public:
protected:
SkMatrixImageFilter(const SkMatrix& transform,
SkPaint::FilterLevel,
SkImageFilter* input);
SkImageFilter* input,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
SkMatrixImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -18,15 +18,17 @@ public:
static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
SkImageFilter* inputs[2] = { first, second };
SkXfermode::Mode modes[2] = { mode, mode };
return SkNEW_ARGS(SkMergeImageFilter, (inputs, 2, modes, cropRect));
return SkNEW_ARGS(SkMergeImageFilter, (inputs, 2, modes, cropRect, uniqueID));
}
static SkMergeImageFilter* Create(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[] = NULL,
const CropRect* cropRect = NULL) {
return SkNEW_ARGS(SkMergeImageFilter, (filters, count, modes, cropRect));
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
return SkNEW_ARGS(SkMergeImageFilter, (filters, count, modes, cropRect, uniqueID));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
@ -34,7 +36,8 @@ public:
protected:
SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[],
const CropRect* cropRect);
const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkMergeImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -30,7 +30,7 @@ public:
protected:
SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
const CropRect* cropRect);
const CropRect* cropRect, uint32_t uniqueID);
bool filterImageGeneric(Proc procX, Proc procY,
Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
@ -56,11 +56,12 @@ class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
public:
static SkDilateImageFilter* Create(int radiusX, int radiusY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect));
return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect, uniqueID));
}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
@ -73,8 +74,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
protected:
SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {}
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
#endif
@ -87,11 +88,12 @@ class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
public:
static SkErodeImageFilter* Create(int radiusX, int radiusY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect));
return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect, uniqueID));
}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
@ -104,8 +106,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
protected:
SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {}
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
#endif

Просмотреть файл

@ -16,17 +16,18 @@ class SK_API SkOffsetImageFilter : public SkImageFilter {
public:
static SkOffsetImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) {
return NULL;
}
return SkNEW_ARGS(SkOffsetImageFilter, (dx, dy, input, cropRect));
return SkNEW_ARGS(SkOffsetImageFilter, (dx, dy, input, cropRect, uniqueID));
}
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
protected:
SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect);
SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkOffsetImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -16,23 +16,23 @@ public:
/**
* Refs the passed-in picture.
*/
static SkPictureImageFilter* Create(const SkPicture* picture) {
return SkNEW_ARGS(SkPictureImageFilter, (picture));
static SkPictureImageFilter* Create(const SkPicture* picture, int32_t uniqueID = 0) {
return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID));
}
/**
* Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
* the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
*/
static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect));
static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID = 0) {
return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
protected:
explicit SkPictureImageFilter(const SkPicture* picture);
SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect);
explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID);
SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID);
virtual ~SkPictureImageFilter();
/* Constructs an SkPictureImageFilter object from an SkReadBuffer.
* Note: If the SkPictureImageFilter object construction requires bitmap

Просмотреть файл

@ -28,7 +28,7 @@ public:
SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)")
static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect);
static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL, uint32_t uniqueID = 0);
virtual ~SkRectShaderImageFilter();
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
@ -43,7 +43,7 @@ protected:
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
private:
SkRectShaderImageFilter(SkShader* s, const CropRect* rect);
SkRectShaderImageFilter(SkShader* s, const CropRect* rect, uint32_t uniqueID = 0);
SkShader* fShader;
typedef SkImageFilter INHERITED;

Просмотреть файл

@ -20,7 +20,7 @@ public:
@param input Input from which the subregion defined by srcRect will be tiled
*/
static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect,
SkImageFilter* input);
SkImageFilter* input, uint32_t uniqueID = 0);
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE;
@ -30,8 +30,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
protected:
SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
: INHERITED(1, &input), fSrcRect(srcRect), fDstRect(dstRect) {}
SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input, uint32_t uniqueID)
: INHERITED(1, &input, NULL, uniqueID), fSrcRect(srcRect), fDstRect(dstRect) {}
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkTileImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -25,9 +25,10 @@ public:
static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
SkImageFilter* foreground = NULL,
const CropRect* cropRect = NULL) {
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
SkImageFilter* inputs[2] = { background, foreground };
return SkNEW_ARGS(SkXfermodeImageFilter, (mode, inputs, cropRect));
return SkNEW_ARGS(SkXfermodeImageFilter, (mode, inputs, cropRect, uniqueID));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
@ -45,7 +46,7 @@ public:
protected:
SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2],
const CropRect* cropRect);
const CropRect* cropRect, uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
#endif

Просмотреть файл

@ -110,12 +110,12 @@ bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) {
///////////////////////////////////////////////////////////////////////////////////////////////////
SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect)
SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect, uint32_t uniqueID)
: fInputCount(inputCount),
fInputs(new SkImageFilter*[inputCount]),
fUsesSrcInput(false),
fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)),
fUniqueID(next_image_filter_unique_id()) {
fUniqueID(uniqueID ? uniqueID : next_image_filter_unique_id()) {
for (int i = 0; i < inputCount; ++i) {
if (NULL == inputs[i] || inputs[i]->usesSrcInput()) {
fUsesSrcInput = true;

Просмотреть файл

@ -38,16 +38,16 @@ SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX,
SkScalar sigmaY,
SkImageFilter* input,
const CropRect* cropRect)
: INHERITED(1, &input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) {
SkASSERT(sigmaX >= 0 && sigmaY >= 0);
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID), fSigma(SkSize::Make(sigmaX, sigmaY)) {
}
SkFlattenable* SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar sigmaX = buffer.readScalar();
SkScalar sigmaY = buffer.readScalar();
return Create(sigmaX, sigmaY, common.getInput(0), &common.cropRect());
return Create(sigmaX, sigmaY, common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -58,7 +58,7 @@ bool matrix_needs_clamping(SkScalar matrix[20]) {
};
SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
SkImageFilter* input, const CropRect* cropRect) {
SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) {
SkASSERT(cf);
SkScalar colorMatrix[20], inputMatrix[20];
SkColorFilter* inputColorFilter;
@ -70,15 +70,15 @@ SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
SkScalar combinedMatrix[20];
mult_color_matrix(colorMatrix, inputMatrix, combinedMatrix);
SkAutoTUnref<SkColorFilter> newCF(SkColorMatrixFilter::Create(combinedMatrix));
return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect));
return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect, 0));
}
}
return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect));
return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect, uniqueID));
}
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
SkImageFilter* input, const CropRect* cropRect)
: INHERITED(1, &input, cropRect), fColorFilter(cf) {
SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID), fColorFilter(cf) {
SkASSERT(cf);
SkSafeRef(cf);
}
@ -93,7 +93,7 @@ SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer)
SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter());
return Create(cf, common.getInput(0), &common.cropRect());
return Create(cf, common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -164,7 +164,7 @@ SkDisplacementMapEffect* SkDisplacementMapEffect::Create(ChannelSelectorType xCh
SkScalar scale,
SkImageFilter* displacement,
SkImageFilter* color,
const CropRect* cropRect) {
const CropRect* cropRect, uint32_t uniqueID) {
if (!channel_selector_type_is_valid(xChannelSelector) ||
!channel_selector_type_is_valid(yChannelSelector)) {
return NULL;
@ -172,15 +172,16 @@ SkDisplacementMapEffect* SkDisplacementMapEffect::Create(ChannelSelectorType xCh
SkImageFilter* inputs[2] = { displacement, color };
return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
inputs, cropRect));
inputs, cropRect, uniqueID));
}
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
SkImageFilter* inputs[2],
const CropRect* cropRect)
: INHERITED(2, inputs, cropRect)
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(2, inputs, cropRect, uniqueID)
, fXChannelSelector(xChannelSelector)
, fYChannelSelector(yChannelSelector)
, fScale(scale)
@ -208,7 +209,7 @@ SkFlattenable* SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
SkScalar scale = buffer.readScalar();
return Create(xsel, ysel, scale, common.getInput(0), common.getInput(1), &common.cropRect());
return Create(xsel, ysel, scale, common.getInput(0), common.getInput(1), &common.cropRect(), common.uniqueID());
}
void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -17,8 +17,9 @@
SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy,
SkScalar sigmaX, SkScalar sigmaY, SkColor color,
SkImageFilter* input, const CropRect* cropRect)
: INHERITED(1, &input, cropRect)
SkImageFilter* input, const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID)
, fDx(dx)
, fDy(dy)
, fSigmaX(sigmaX)
@ -49,7 +50,7 @@ SkFlattenable* SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) {
SkScalar sigmaX = buffer.readScalar();
SkScalar sigmaY = buffer.readScalar();
SkColor color = buffer.readColor();
return Create(dx, dy, sigmaX, sigmaY, color, common.getInput(0), &common.cropRect());
return Create(dx, dy, sigmaX, sigmaY, color, common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -265,14 +265,15 @@ void writePoint3(const SkPoint3& point, SkWriteBuffer& buffer) {
class SkDiffuseLightingImageFilter : public SkLightingImageFilter {
public:
static SkImageFilter* Create(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter*,
const CropRect*);
const CropRect*, uint32_t uniqueID = 0);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
SkScalar kd() const { return fKD; }
protected:
SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale,
SkScalar kd, SkImageFilter* input, const CropRect* cropRect);
SkScalar kd, SkImageFilter* input, const CropRect* cropRect,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer);
#endif
@ -293,7 +294,7 @@ private:
class SkSpecularLightingImageFilter : public SkLightingImageFilter {
public:
static SkImageFilter* Create(SkLight* light, SkScalar surfaceScale,
SkScalar ks, SkScalar shininess, SkImageFilter*, const CropRect*);
SkScalar ks, SkScalar shininess, SkImageFilter*, const CropRect*, uint32_t uniqueID = 0);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
@ -302,7 +303,8 @@ public:
protected:
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks,
SkScalar shininess, SkImageFilter* input, const CropRect*);
SkScalar shininess, SkImageFilter* input, const CropRect*,
uint32_t uniqueID);
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer);
#endif
@ -844,8 +846,9 @@ void SkLight::flattenLight(SkWriteBuffer& buffer) const {
///////////////////////////////////////////////////////////////////////////////
SkLightingImageFilter::SkLightingImageFilter(SkLight* light, SkScalar surfaceScale,
SkImageFilter* input, const CropRect* cropRect)
: INHERITED(1, &input, cropRect)
SkImageFilter* input, const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID)
, fLight(SkRef(light))
, fSurfaceScale(surfaceScale / 255)
{}
@ -941,7 +944,7 @@ void SkLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
///////////////////////////////////////////////////////////////////////////////
SkImageFilter* SkDiffuseLightingImageFilter::Create(SkLight* light, SkScalar surfaceScale,
SkScalar kd, SkImageFilter* input, const CropRect* cropRect) {
SkScalar kd, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) {
if (NULL == light) {
return NULL;
}
@ -953,11 +956,11 @@ SkImageFilter* SkDiffuseLightingImageFilter::Create(SkLight* light, SkScalar sur
if (kd < 0) {
return NULL;
}
return SkNEW_ARGS(SkDiffuseLightingImageFilter, (light, surfaceScale, kd, input, cropRect));
return SkNEW_ARGS(SkDiffuseLightingImageFilter, (light, surfaceScale, kd, input, cropRect, uniqueID));
}
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter* input, const CropRect* cropRect = NULL)
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: SkLightingImageFilter(light, surfaceScale, input, cropRect, uniqueID),
fKD(kd)
{
}
@ -976,7 +979,7 @@ SkFlattenable* SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
SkAutoTUnref<SkLight> light(SkLight::UnflattenLight(buffer));
SkScalar surfaceScale = buffer.readScalar();
SkScalar kd = buffer.readScalar();
return Create(light, surfaceScale, kd, common.getInput(0), &common.cropRect());
return Create(light, surfaceScale, kd, common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
@ -1052,7 +1055,7 @@ bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* tex
///////////////////////////////////////////////////////////////////////////////
SkImageFilter* SkSpecularLightingImageFilter::Create(SkLight* light, SkScalar surfaceScale,
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect) {
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID) {
if (NULL == light) {
return NULL;
}
@ -1065,11 +1068,11 @@ SkImageFilter* SkSpecularLightingImageFilter::Create(SkLight* light, SkScalar su
return NULL;
}
return SkNEW_ARGS(SkSpecularLightingImageFilter,
(light, surfaceScale, ks, shininess, input, cropRect));
(light, surfaceScale, ks, shininess, input, cropRect, uniqueID));
}
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect)
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: SkLightingImageFilter(light, surfaceScale, input, cropRect, uniqueID),
fKS(ks),
fShininess(shininess)
{
@ -1092,7 +1095,7 @@ SkFlattenable* SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
SkScalar surfaceScale = buffer.readScalar();
SkScalar ks = buffer.readScalar();
SkScalar shine = buffer.readScalar();
return Create(light, surfaceScale, ks, shine, common.getInput(0), &common.cropRect());
return Create(light, surfaceScale, ks, shine, common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -26,8 +26,9 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
TileMode tileMode,
bool convolveAlpha,
SkImageFilter* input,
const CropRect* cropRect)
: INHERITED(1, &input, cropRect),
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID),
fKernelSize(kernelSize),
fGain(gain),
fBias(bias),
@ -112,7 +113,7 @@ SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer)
TileMode tileMode = (TileMode)buffer.readInt();
bool convolveAlpha = buffer.readBool();
return Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode, convolveAlpha,
common.getInput(0), &common.cropRect());
common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -17,16 +17,18 @@
SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform,
SkPaint::FilterLevel filterLevel,
SkImageFilter* input)
: INHERITED(1, &input),
SkImageFilter* input,
uint32_t uniqueID)
: INHERITED(1, &input, NULL, uniqueID),
fTransform(transform),
fFilterLevel(filterLevel) {
}
SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
SkPaint::FilterLevel filterLevel,
SkImageFilter* input) {
return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input));
SkImageFilter* input,
uint32_t uniqueID) {
return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input, uniqueID));
}
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
@ -42,7 +44,7 @@ SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix;
buffer.readMatrix(&matrix);
SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readInt());
return Create(matrix, level, common.getInput(0));
return Create(matrix, level, common.getInput(0), common.uniqueID());
}
void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -42,7 +42,9 @@ void SkMergeImageFilter::initModes(const SkXfermode::Mode modes[]) {
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[],
const CropRect* cropRect) : INHERITED(count, filters, cropRect) {
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(count, filters, cropRect, uniqueID) {
SkASSERT(count >= 0);
this->initModes(modes);
}
@ -126,9 +128,9 @@ SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
if (!buffer.isValid()) {
return NULL;
}
return Create(common.inputs(), count, modes.get(), &common.cropRect());
return Create(common.inputs(), count, modes.get(), &common.cropRect(), common.uniqueID());
}
return Create(common.inputs(), count, NULL, &common.cropRect());
return Create(common.inputs(), count, NULL, &common.cropRect(), common.uniqueID());
}
void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -34,8 +34,9 @@ SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer)
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
int radiusY,
SkImageFilter* input,
const CropRect* cropRect)
: INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) {
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID), fRadius(SkISize::Make(radiusX, radiusY)) {
}
void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const {
@ -263,14 +264,14 @@ SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
return Create(width, height, common.getInput(0), &common.cropRect());
return Create(width, height, common.getInput(0), &common.cropRect(), common.uniqueID());
}
SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
return Create(width, height, common.getInput(0), &common.cropRect());
return Create(width, height, common.getInput(0), &common.cropRect(), common.uniqueID());
}
#if SK_SUPPORT_GPU

Просмотреть файл

@ -95,7 +95,7 @@ SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkPoint offset;
buffer.readPoint(&offset);
return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect());
return Create(offset.x(), offset.y(), common.getInput(0), &common.cropRect(), common.uniqueID());
}
void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
@ -104,8 +104,8 @@ void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
}
SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input,
const CropRect* cropRect)
: INHERITED(1, &input, cropRect) {
const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(1, &input, cropRect, uniqueID) {
fOffset.set(dx, dy);
}

Просмотреть файл

@ -12,16 +12,17 @@
#include "SkWriteBuffer.h"
#include "SkValidationUtils.h"
SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture)
: INHERITED(0, 0),
SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID)
: INHERITED(0, 0, NULL, uniqueID),
fPicture(picture),
fCropRect(SkRect::MakeWH(picture ? SkIntToScalar(picture->width()) : 0,
picture ? SkIntToScalar(picture->height()) : 0)) {
SkSafeRef(fPicture);
}
SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect)
: INHERITED(0, 0),
SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
uint32_t uniqueID)
: INHERITED(0, 0, NULL, uniqueID),
fPicture(picture),
fCropRect(cropRect) {
SkSafeRef(fPicture);

Просмотреть файл

@ -23,13 +23,14 @@ SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe
return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect));
}
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) {
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect, uint32_t uniqueID) {
SkASSERT(s);
return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect));
return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID));
}
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect)
: INHERITED(0, NULL, cropRect)
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(0, NULL, cropRect, uniqueID)
, fShader(s) {
SkASSERT(s);
s->ref();
@ -45,7 +46,7 @@ SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer)
SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
SkAutoTUnref<SkShader> shader(buffer.readShader());
return Create(shader.get(), &common.cropRect());
return Create(shader.get(), &common.cropRect(), common.uniqueID());
}
void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -17,11 +17,11 @@
#include "SkValidationUtils.h"
SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect,
SkImageFilter* input) {
SkImageFilter* input, uint32_t uniqueID) {
if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
return NULL;
}
return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input));
return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input, uniqueID));
}
bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
@ -108,7 +108,7 @@ SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
SkRect src, dst;
buffer.readRect(&src);
buffer.readRect(&dst);
return Create(src, dst, common.getInput(0));
return Create(src, dst, common.getInput(0), common.uniqueID());
}
void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const {

Просмотреть файл

@ -22,8 +22,9 @@
SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode,
SkImageFilter* inputs[2],
const CropRect* cropRect)
: INHERITED(2, inputs, cropRect), fMode(mode) {
const CropRect* cropRect,
uint32_t uniqueID)
: INHERITED(2, inputs, cropRect, uniqueID), fMode(mode) {
SkSafeRef(fMode);
}
@ -41,7 +42,7 @@ SkXfermodeImageFilter::SkXfermodeImageFilter(SkReadBuffer& buffer)
SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
SkAutoTUnref<SkXfermode> mode(buffer.readXfermode());
return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect());
return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect(), common.uniqueID());
}
void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const {