Simplify flattening to just write enough to call the factory/public-constructor for the class. We want to *not* rely on private constructors, and not rely on calling through the inheritance hierarchy for either flattening or unflattening(CreateProc).
Refactoring pattern: 1. guard the existing constructor(readbuffer) with the legacy build-flag 2. If you are a instancable subclass, implement CreateProc(readbuffer) to create a new instances from the buffer params (or return NULL). If you're a shader subclass 1. You must read/write the local matrix if your class accepts that in its factory/constructor, else ignore it. R=robertphillips@google.com, mtklein@google.com, senorblanco@google.com, senorblanco@chromium.org, sugoi@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/395603002
This commit is contained in:
parent
5d74806b47
commit
9fa60daad4
@ -23,24 +23,34 @@ public:
|
||||
}
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
|
||||
|
||||
protected:
|
||||
FailImageFilter() : INHERITED(0, NULL) {}
|
||||
FailImageFilter() : INHERITED(0, NULL) {
|
||||
static bool gOnce;
|
||||
if (!gOnce) {
|
||||
gOnce = true;
|
||||
SkFlattenable::Register("FailImageFilter", this->getFactory(),
|
||||
this->GetFlattenableType());
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
|
||||
return false;
|
||||
}
|
||||
|
||||
FailImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(0, buffer) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
FailImageFilter(SkReadBuffer& buffer) : INHERITED(0, buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkImageFilter INHERITED;
|
||||
};
|
||||
|
||||
// register the filter with the flattenable registry
|
||||
static SkFlattenable::Registrar gFailImageFilterReg("FailImageFilter",
|
||||
FailImageFilter::CreateProc,
|
||||
FailImageFilter::GetFlattenableType());
|
||||
SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
|
||||
return FailImageFilter::Create();
|
||||
}
|
||||
|
||||
class IdentityImageFilter : public SkImageFilter {
|
||||
public:
|
||||
@ -50,7 +60,15 @@ public:
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
|
||||
protected:
|
||||
IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {}
|
||||
IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {
|
||||
static bool gOnce;
|
||||
if (!gOnce) {
|
||||
gOnce = true;
|
||||
SkFlattenable::Register("IdentityImageFilter", this->getFactory(),
|
||||
this->GetFlattenableType());
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
|
||||
*result = src;
|
||||
@ -58,18 +76,18 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
IdentityImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
IdentityImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkImageFilter INHERITED;
|
||||
};
|
||||
|
||||
// register the filter with the flattenable registry
|
||||
static SkFlattenable::Registrar gIdentityImageFilterReg("IdentityImageFilter",
|
||||
IdentityImageFilter::CreateProc,
|
||||
IdentityImageFilter::GetFlattenableType());
|
||||
|
||||
SkFlattenable* IdentityImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
return IdentityImageFilter::Create(common.getInput(0));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -57,28 +57,42 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SimpleOffsetFilter(SkReadBuffer& buffer)
|
||||
: SkImageFilter(1, buffer) {
|
||||
fDX = buffer.readScalar();
|
||||
fDY = buffer.readScalar();
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
this->SkImageFilter::flatten(buffer);
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fDX);
|
||||
buffer.writeScalar(fDY);
|
||||
}
|
||||
|
||||
private:
|
||||
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
|
||||
: SkImageFilter(1, &input), fDX(dx), fDY(dy) {}
|
||||
: SkImageFilter(1, &input), fDX(dx), fDY(dy) {
|
||||
static bool gOnce;
|
||||
if (!gOnce) {
|
||||
gOnce = true;
|
||||
SkFlattenable::Register("SimpleOffsetFilter", this->getFactory(),
|
||||
this->GetFlattenableType());
|
||||
}
|
||||
}
|
||||
|
||||
SkScalar fDX, fDY;
|
||||
|
||||
typedef SkImageFilter INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable::Registrar registrar("SimpleOffsetFilter",
|
||||
SimpleOffsetFilter::CreateProc,
|
||||
SimpleOffsetFilter::GetFlattenableType());
|
||||
SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkScalar dx = buffer.readScalar();
|
||||
SkScalar dy = buffer.readScalar();
|
||||
return Create(dx, dy, common.getInput(0));
|
||||
}
|
||||
|
||||
class ImageFiltersGraphGM : public skiagm::GM {
|
||||
public:
|
||||
|
@ -135,7 +135,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkColorFilter() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorFilter(SkReadBuffer& rb) : INHERITED(rb) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkFlattenable INHERITED;
|
||||
|
@ -114,7 +114,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkDrawLooper() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkFlattenable INHERITED;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkFlattenable_DEFINED
|
||||
#define SkFlattenable_DEFINED
|
||||
|
||||
@ -15,9 +13,26 @@
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
||||
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
|
||||
flattenable::GetFlattenableType());
|
||||
#define SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
|
||||
/*
|
||||
* Flattening is straight-forward:
|
||||
* 1. call getFactory() so we have a function-ptr to recreate the subclass
|
||||
* 2. call flatten(buffer) to write out enough data for the factory to read
|
||||
*
|
||||
* Unflattening is easy for the caller: new_instance = factory(buffer)
|
||||
*
|
||||
* The complexity of supporting this is as follows.
|
||||
*
|
||||
* If your subclass wants to control unflattening, use this macro in your declaration:
|
||||
* SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS
|
||||
* This will provide a getFactory(), and require that the subclass implements CreateProc.
|
||||
*
|
||||
* For older buffers (before the DEEPFLATTENING change, the macros below declare
|
||||
* a thin factory DeepCreateProc. It checks the version of the buffer, and if it is pre-deep,
|
||||
* then it calls through to a (usually protected) constructor, passing the buffer.
|
||||
* If the buffer is newer, then it directly calls the "real" factory: CreateProc.
|
||||
*/
|
||||
|
||||
#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables();
|
||||
|
||||
@ -30,11 +45,39 @@ class SkWriteBuffer;
|
||||
#define SK_DECLARE_UNFLATTENABLE_OBJECT() \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
|
||||
|
||||
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
|
||||
static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \
|
||||
return SkNEW_ARGS(flattenable, (buffer)); \
|
||||
}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
||||
SkFlattenable::Registrar(#flattenable, flattenable::DeepCreateProc, \
|
||||
flattenable::GetFlattenableType());
|
||||
|
||||
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
||||
private: \
|
||||
static SkFlattenable* CreateProc(SkReadBuffer&); \
|
||||
static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) { \
|
||||
if (NeedsDeepUnflatten(buffer)) { \
|
||||
return SkNEW_ARGS(flattenable, (buffer)); \
|
||||
} \
|
||||
return CreateProc(buffer); \
|
||||
} \
|
||||
friend class SkPrivateEffectInitializer; \
|
||||
public: \
|
||||
virtual Factory getFactory() const SK_OVERRIDE {return DeepCreateProc;}
|
||||
#else
|
||||
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
|
||||
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
|
||||
flattenable::GetFlattenableType());
|
||||
|
||||
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
|
||||
private: \
|
||||
static SkFlattenable* CreateProc(SkReadBuffer&); \
|
||||
friend class SkPrivateEffectInitializer; \
|
||||
public: \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
|
||||
#endif
|
||||
|
||||
// If your subclass will *never* need to be unflattened, declare this.
|
||||
#define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc; }
|
||||
|
||||
/** For SkFlattenable derived objects with a valid type
|
||||
This macro should only be used in base class objects in core
|
||||
@ -94,14 +137,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** Override this to write data specific to your subclass into the buffer,
|
||||
being sure to call your super-class' version first. This data will later
|
||||
be passed to your Factory function, returned by getFactory().
|
||||
/**
|
||||
* Override this if your subclass needs to record data that it will need to recreate itself
|
||||
* from its CreateProc (returned by getFactory()).
|
||||
*/
|
||||
virtual void flatten(SkWriteBuffer&) const;
|
||||
virtual void flatten(SkWriteBuffer&) const {}
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
static bool NeedsDeepUnflatten(const SkReadBuffer&);
|
||||
SkFlattenable(SkReadBuffer&) {}
|
||||
#endif
|
||||
|
||||
static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
static void InitializeFlattenablesIfNeeded();
|
||||
|
@ -205,13 +205,23 @@ protected:
|
||||
Common() {}
|
||||
~Common();
|
||||
|
||||
bool unflatten(SkReadBuffer&, int expectedInputs = -1);
|
||||
/**
|
||||
* Attempt to unflatten the cropRect and the expected number of input filters.
|
||||
* If any number of input filters is valid, pass -1.
|
||||
* If this fails (i.e. corrupt buffer or contents) then return false and common will
|
||||
* be left uninitialized.
|
||||
* If this returns true, then inputCount() is the number of found input filters, each
|
||||
* of which may be NULL or a valid imagefilter.
|
||||
*/
|
||||
bool unflatten(SkReadBuffer&, int expectedInputs);
|
||||
|
||||
CropRect cropRect() const { return fCropRect; }
|
||||
const CropRect& cropRect() const { return fCropRect; }
|
||||
int inputCount() const { return fInputs.count(); }
|
||||
SkImageFilter** inputs() const { return fInputs.get(); }
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
SkImageFilter* getInput(int index) const { return fInputs[index]; }
|
||||
|
||||
// If the caller wants a copy of the inputs, call this and it will transfer ownership
|
||||
// of the unflattened input filters to the caller. This is just a short-cut for copying
|
||||
// the inputs, calling ref() on each, and then waiting for Common's destructor to call
|
||||
@ -240,7 +250,7 @@ protected:
|
||||
*/
|
||||
explicit SkImageFilter(int inputCount, SkReadBuffer& rb);
|
||||
|
||||
virtual void flatten(SkWriteBuffer& wb) const SK_OVERRIDE;
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
/**
|
||||
* This is the virtual which should be overridden by the derived class
|
||||
@ -320,4 +330,15 @@ private:
|
||||
uint32_t fUniqueID; // Globally unique
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to unflatten the common data, and return NULL if we fail.
|
||||
*/
|
||||
#define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
|
||||
Common localVar; \
|
||||
do { \
|
||||
if (!localVar.unflatten(buffer, expectedCount)) { \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
@ -155,8 +155,10 @@ public:
|
||||
|
||||
protected:
|
||||
SkMaskFilter() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
// empty for now, but lets get our subclass to remember to init us for the future
|
||||
SkMaskFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
enum FilterReturn {
|
||||
kFalse_FilterReturn,
|
||||
|
@ -135,7 +135,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkPathEffect() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
// illegal
|
||||
@ -157,7 +159,10 @@ public:
|
||||
|
||||
protected:
|
||||
SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPairPathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
// these are visible to our subclasses
|
||||
@ -191,7 +196,10 @@ public:
|
||||
protected:
|
||||
SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
|
||||
: INHERITED(outer, inner) {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
// illegal
|
||||
@ -225,7 +233,10 @@ public:
|
||||
protected:
|
||||
SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
|
||||
: INHERITED(first, second) {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
// illegal
|
||||
|
@ -248,7 +248,7 @@ private:
|
||||
|
||||
// Only SKPs within the min/current picture version range (inclusive) can be read.
|
||||
static const uint32_t MIN_PICTURE_VERSION = 19;
|
||||
static const uint32_t CURRENT_PICTURE_VERSION = 32;
|
||||
static const uint32_t CURRENT_PICTURE_VERSION = 33;
|
||||
|
||||
mutable uint32_t fUniqueID;
|
||||
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkRasterizer() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkRasterizer(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
|
||||
const SkIRect* clipBounds,
|
||||
|
@ -461,7 +461,9 @@ public:
|
||||
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkShader(SkReadBuffer& );
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const;
|
||||
|
@ -217,7 +217,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkXfermode() {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {}
|
||||
#endif
|
||||
|
||||
/** The default implementation of xfer32/xfer16/xferA8 in turn call this
|
||||
method, 1 color at a time (upscaled to a SkPMColor). The default
|
||||
|
@ -64,7 +64,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkPath1DPathEffect(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
// overrides from Sk1DPathEffect
|
||||
|
@ -39,7 +39,9 @@ protected:
|
||||
|
||||
// protected so that subclasses can call this during unflattening
|
||||
explicit Sk2DPathEffect(const SkMatrix& mat);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit Sk2DPathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
@ -68,7 +70,9 @@ public:
|
||||
protected:
|
||||
SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
|
||||
: Sk2DPathEffect(matrix), fWidth(width) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkLine2DPathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
@ -94,7 +98,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkPath2DPathEffect(const SkMatrix&, const SkPath&);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkPath2DPathEffect(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
|
||||
|
@ -54,12 +54,15 @@ public:
|
||||
|
||||
protected:
|
||||
SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkAvoidXfermode(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkColor fOpColor;
|
||||
uint32_t fDistMul; // x.14
|
||||
uint32_t fDistMul; // x.14 cached from fTolerance
|
||||
uint8_t fTolerance;
|
||||
Mode fMode;
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
|
@ -27,7 +27,9 @@ public:
|
||||
protected:
|
||||
explicit SkBitmapSource(const SkBitmap& bitmap);
|
||||
SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkBitmapSource(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -53,7 +53,9 @@ protected:
|
||||
SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy,
|
||||
uint32_t flags);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBlurDrawLooper(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool asABlurShadow(BlurShadowRec*) const SK_OVERRIDE;
|
||||
|
@ -29,7 +29,9 @@ protected:
|
||||
SkScalar sigmaY,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkBlurImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -22,7 +22,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorFilterImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
protected:
|
||||
explicit SkColorMatrixFilter(const SkColorMatrix&);
|
||||
explicit SkColorMatrixFilter(const SkScalar array[20]);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkColorMatrixFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -14,7 +14,13 @@ class SK_API SkComposeImageFilter : public SkImageFilter {
|
||||
public:
|
||||
virtual ~SkComposeImageFilter();
|
||||
|
||||
static SkComposeImageFilter* Create(SkImageFilter* outer, SkImageFilter* inner) {
|
||||
static SkImageFilter* Create(SkImageFilter* outer, SkImageFilter* inner) {
|
||||
if (NULL == outer) {
|
||||
return SkSafeRef(inner);
|
||||
}
|
||||
if (NULL == inner) {
|
||||
return SkRef(outer);
|
||||
}
|
||||
SkImageFilter* inputs[2] = { outer, inner };
|
||||
return SkNEW_ARGS(SkComposeImageFilter, (inputs));
|
||||
}
|
||||
@ -22,8 +28,13 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
|
||||
|
||||
protected:
|
||||
explicit SkComposeImageFilter(SkImageFilter* inputs[2]) : INHERITED(2, inputs) {}
|
||||
explicit SkComposeImageFilter(SkImageFilter* inputs[2]) : INHERITED(2, inputs) {
|
||||
SkASSERT(inputs[0]);
|
||||
SkASSERT(inputs[1]);
|
||||
}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkComposeImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
|
||||
protected:
|
||||
explicit SkCornerPathEffect(SkScalar radius);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkCornerPathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -51,13 +51,13 @@ public:
|
||||
|
||||
virtual DashType asADash(DashInfo* info) const SK_OVERRIDE;
|
||||
|
||||
virtual Factory getFactory() const SK_OVERRIDE;
|
||||
|
||||
static SkFlattenable* CreateProc(SkReadBuffer&);
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDashPathEffect)
|
||||
|
||||
protected:
|
||||
SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDashPathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -45,7 +45,9 @@ protected:
|
||||
SkDiscretePathEffect(SkScalar segLength,
|
||||
SkScalar deviation,
|
||||
uint32_t seedAssist);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDiscretePathEffect(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -27,11 +27,7 @@ public:
|
||||
ChannelSelectorType yChannelSelector,
|
||||
SkScalar scale, SkImageFilter* displacement,
|
||||
SkImageFilter* color = NULL,
|
||||
const CropRect* cropRect = NULL) {
|
||||
SkImageFilter* inputs[2] = { displacement, color };
|
||||
return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
|
||||
inputs, cropRect));
|
||||
}
|
||||
const CropRect* cropRect = NULL);
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
|
||||
|
||||
@ -56,7 +52,9 @@ protected:
|
||||
ChannelSelectorType yChannelSelector,
|
||||
SkScalar scale, SkImageFilter* inputs[2],
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -24,7 +24,9 @@ public:
|
||||
protected:
|
||||
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
|
||||
SkImageFilter* input, const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDropShadowImageFilter(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
|
||||
|
@ -37,7 +37,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkEmbossMaskFilter(SkScalar blurSigma, const Light& light);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkEmbossMaskFilter(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -81,8 +81,14 @@ public:
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
|
||||
/// Implements Flattenable.
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
static SkFlattenable* DeepCreateProc(SkReadBuffer& buffer) {
|
||||
return CreateProc(buffer);
|
||||
}
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return DeepCreateProc; }
|
||||
#else
|
||||
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
|
||||
#endif
|
||||
static SkFlattenable* CreateProc(SkReadBuffer& buffer);
|
||||
|
||||
protected:
|
||||
|
@ -69,7 +69,9 @@ public:
|
||||
protected:
|
||||
SkLayerRasterizer();
|
||||
SkLayerRasterizer(SkDeque* layers);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLayerRasterizer(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
// override from SkRasterizer
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLerpXfermode(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -74,14 +74,16 @@ protected:
|
||||
SkScalar surfaceScale,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkLightingImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
const SkLight* light() const { return fLight; }
|
||||
const SkLight* light() const { return fLight.get(); }
|
||||
SkScalar surfaceScale() const { return fSurfaceScale; }
|
||||
|
||||
private:
|
||||
typedef SkImageFilter INHERITED;
|
||||
SkLight* fLight;
|
||||
SkAutoTUnref<SkLight> fLight;
|
||||
SkScalar fSurfaceScale;
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLumaColorFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -14,16 +14,15 @@
|
||||
|
||||
class SK_API SkMagnifierImageFilter : public SkImageFilter {
|
||||
public:
|
||||
static SkMagnifierImageFilter* Create(const SkRect& srcRect, SkScalar inset,
|
||||
SkImageFilter* input = NULL) {
|
||||
return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset, input));
|
||||
}
|
||||
static SkImageFilter* Create(const SkRect& src, SkScalar inset, SkImageFilter* input = NULL);
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
|
||||
|
||||
protected:
|
||||
SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkMagnifierImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -78,7 +78,9 @@ protected:
|
||||
bool convolveAlpha,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkMatrixConvolutionImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -41,7 +41,9 @@ protected:
|
||||
SkMatrixImageFilter(const SkMatrix& transform,
|
||||
SkPaint::FilterLevel,
|
||||
SkImageFilter* input);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMatrixImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -35,7 +35,9 @@ protected:
|
||||
SkMergeImageFilter(SkImageFilter* filters[], int count,
|
||||
const SkXfermode::Mode modes[],
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkMergeImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -34,7 +34,9 @@ protected:
|
||||
bool filterImageGeneric(Proc procX, Proc procY,
|
||||
Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMorphologyImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
||||
@ -55,6 +57,9 @@ public:
|
||||
static SkDilateImageFilter* Create(int radiusX, int radiusY,
|
||||
SkImageFilter* input = NULL,
|
||||
const CropRect* cropRect = NULL) {
|
||||
if (radiusX < 0 || radiusY < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect));
|
||||
}
|
||||
|
||||
@ -70,7 +75,9 @@ public:
|
||||
protected:
|
||||
SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
|
||||
: INHERITED(radiusX, radiusY, input, cropRect) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkMorphologyImageFilter INHERITED;
|
||||
@ -81,6 +88,9 @@ public:
|
||||
static SkErodeImageFilter* Create(int radiusX, int radiusY,
|
||||
SkImageFilter* input = NULL,
|
||||
const CropRect* cropRect = NULL) {
|
||||
if (radiusX < 0 || radiusY < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect));
|
||||
}
|
||||
|
||||
@ -96,7 +106,9 @@ public:
|
||||
protected:
|
||||
SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
|
||||
: INHERITED(radiusX, radiusY, input, cropRect) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkMorphologyImageFilter INHERITED;
|
||||
|
@ -17,6 +17,9 @@ class SK_API SkOffsetImageFilter : public SkImageFilter {
|
||||
public:
|
||||
static SkOffsetImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
|
||||
const CropRect* cropRect = NULL) {
|
||||
if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkOffsetImageFilter, (dx, dy, input, cropRect));
|
||||
}
|
||||
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
|
||||
@ -24,7 +27,9 @@ public:
|
||||
|
||||
protected:
|
||||
SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkOffsetImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -103,7 +103,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPerlinNoiseShader(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
|
||||
|
||||
|
@ -40,7 +40,9 @@ protected:
|
||||
* SkReadBuffer::setBitmapDecoder() before calling this constructor.
|
||||
* @param SkReadBuffer Serialized picture data.
|
||||
*/
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkPictureImageFilter(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
|
@ -26,7 +26,9 @@ public:
|
||||
|
||||
protected:
|
||||
explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkPixelXorXfermode(SkReadBuffer& rb);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
// override from SkXfermode
|
||||
|
@ -34,7 +34,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkRectShaderImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -55,7 +55,9 @@ public:
|
||||
protected:
|
||||
SkTableMaskFilter();
|
||||
explicit SkTableMaskFilter(const uint8_t table[256]);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkTableMaskFilter(SkReadBuffer& rb);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -8,6 +8,13 @@
|
||||
class SK_API SkDownSampleImageFilter : public SkImageFilter {
|
||||
public:
|
||||
static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) {
|
||||
if (!SkScalarIsFinite(scale)) {
|
||||
return NULL;
|
||||
}
|
||||
// we don't support scale in this range
|
||||
if (scale > SK_Scalar1 || scale <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkDownSampleImageFilter, (scale, input));
|
||||
}
|
||||
|
||||
@ -16,7 +23,9 @@ public:
|
||||
protected:
|
||||
SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input)
|
||||
: INHERITED(1, &input), fScale(scale) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDownSampleImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
|
@ -20,9 +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) {
|
||||
return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input));
|
||||
}
|
||||
SkImageFilter* input);
|
||||
|
||||
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE;
|
||||
@ -34,7 +32,9 @@ public:
|
||||
protected:
|
||||
SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
|
||||
: INHERITED(1, &input), fSrcRect(srcRect), fDstRect(dstRect) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkTileImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
|
||||
|
@ -37,8 +37,13 @@ public:
|
||||
protected:
|
||||
virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
|
||||
|
||||
// we don't need to flatten anything at all
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
typedef SkShader INHERITED;
|
||||
};
|
||||
|
@ -46,7 +46,9 @@ public:
|
||||
protected:
|
||||
SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2],
|
||||
const CropRect* cropRect);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -90,13 +90,15 @@ protected:
|
||||
dst->addCircle(loc.fX, loc.fY, fRadius);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fRadius = buffer.readScalar();
|
||||
fPts = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeMatrix(this->getMatrix());
|
||||
buffer.writeScalar(fRadius);
|
||||
}
|
||||
|
||||
@ -107,6 +109,12 @@ private:
|
||||
typedef Sk2DPathEffect INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix matrix;
|
||||
buffer.readMatrix(&matrix);
|
||||
return SkNEW_ARGS(Dot2DPathEffect, (buffer.readScalar(), matrix, NULL));
|
||||
}
|
||||
|
||||
class InverseFillPE : public SkPathEffect {
|
||||
public:
|
||||
InverseFillPE() {}
|
||||
@ -119,12 +127,19 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
typedef SkPathEffect INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkNEW(InverseFillPE);
|
||||
}
|
||||
|
||||
static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
|
||||
SkMatrix lattice;
|
||||
SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp);
|
||||
|
@ -172,9 +172,11 @@ protected:
|
||||
dst->addCircle(loc.fX, loc.fY, fRadius);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fRadius = buffer.readScalar();
|
||||
}
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fRadius);
|
||||
|
@ -39,13 +39,14 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo
|
||||
fTileModeY = (uint8_t)tmy;
|
||||
}
|
||||
|
||||
SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
buffer.readBitmap(&fRawBitmap);
|
||||
fRawBitmap.setImmutable();
|
||||
fTileModeX = buffer.readUInt();
|
||||
fTileModeY = buffer.readUInt();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
|
||||
SkMatrix* texM,
|
||||
@ -63,9 +64,21 @@ SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
|
||||
return kDefault_BitmapType;
|
||||
}
|
||||
|
||||
void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix lm;
|
||||
buffer.readMatrix(&lm);
|
||||
SkBitmap bm;
|
||||
if (!buffer.readBitmap(&bm)) {
|
||||
return NULL;
|
||||
}
|
||||
bm.setImmutable();
|
||||
TileMode mx = (TileMode)buffer.readUInt();
|
||||
TileMode my = (TileMode)buffer.readUInt();
|
||||
return SkShader::CreateBitmapShader(bm, mx, my, &lm);
|
||||
}
|
||||
|
||||
void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeMatrix(this->getLocalMatrix());
|
||||
buffer.writeBitmap(fRawBitmap);
|
||||
buffer.writeUInt(fTileModeX);
|
||||
buffer.writeUInt(fTileModeY);
|
||||
|
@ -55,7 +55,9 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBitmapProcShader(SkReadBuffer& );
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
|
||||
|
||||
|
@ -714,19 +714,17 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fProxy = buffer.readShader();
|
||||
// Leaving this here until we bump the picture version, though this
|
||||
// shader should never be recorded.
|
||||
buffer.readColor();
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeFlattenable(fProxy);
|
||||
// Leaving this here until we bump the picture version, though this
|
||||
// shader should never be recorded.
|
||||
buffer.writeColor(SkColor());
|
||||
}
|
||||
|
||||
private:
|
||||
@ -735,6 +733,11 @@ private:
|
||||
typedef SkShader INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable* Sk3DShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkShader> shader(buffer.readShader());
|
||||
return SkNEW_ARGS(Sk3DShader, (shader));
|
||||
}
|
||||
|
||||
class Sk3DBlitter : public SkBlitter {
|
||||
public:
|
||||
Sk3DBlitter(SkBlitter* proxy, Sk3DShader::Sk3DShaderContext* shaderContext)
|
||||
|
@ -26,8 +26,8 @@ SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) {
|
||||
SkSafeRef(mode);
|
||||
}
|
||||
|
||||
SkComposeShader::SkComposeShader(SkReadBuffer& buffer) :
|
||||
INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkComposeShader::SkComposeShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fShaderA = buffer.readShader();
|
||||
if (NULL == fShaderA) {
|
||||
fShaderA = SkNEW_ARGS(SkColorShader, ((SkColor)0));
|
||||
@ -38,6 +38,7 @@ SkComposeShader::SkComposeShader(SkReadBuffer& buffer) :
|
||||
}
|
||||
fMode = buffer.readXfermode();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkComposeShader::~SkComposeShader() {
|
||||
SkSafeUnref(fMode);
|
||||
@ -66,8 +67,17 @@ private:
|
||||
};
|
||||
#define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore)
|
||||
|
||||
SkFlattenable* SkComposeShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkShader> shaderA(buffer.readShader());
|
||||
SkAutoTUnref<SkShader> shaderB(buffer.readShader());
|
||||
SkAutoTUnref<SkXfermode> mode(buffer.readXfermode());
|
||||
if (!shaderA.get() || !shaderB.get()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkComposeShader, (shaderA, shaderB, mode));
|
||||
}
|
||||
|
||||
void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeFlattenable(fShaderA);
|
||||
buffer.writeFlattenable(fShaderB);
|
||||
buffer.writeFlattenable(fMode);
|
||||
|
@ -2019,11 +2019,9 @@ public:
|
||||
};
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
|
||||
SK_DECLARE_NOT_FLATTENABLE_PROCS(SkTriColorShader)
|
||||
|
||||
protected:
|
||||
SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {}
|
||||
|
||||
virtual Context* onCreateContext(const ContextRec& rec, void* storage) const SK_OVERRIDE {
|
||||
return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, rec));
|
||||
}
|
||||
|
@ -30,7 +30,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
virtual SkShader::Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE {
|
||||
return NULL;
|
||||
|
@ -21,19 +21,28 @@ SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) {
|
||||
filter->ref();
|
||||
}
|
||||
|
||||
SkFilterShader::SkFilterShader(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkFilterShader::SkFilterShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fShader = buffer.readShader();
|
||||
fFilter = buffer.readColorFilter();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFilterShader::~SkFilterShader() {
|
||||
fFilter->unref();
|
||||
fShader->unref();
|
||||
}
|
||||
|
||||
SkFlattenable* SkFilterShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkShader> shader(buffer.readShader());
|
||||
SkAutoTUnref<SkColorFilter> filter(buffer.readColorFilter());
|
||||
if (!shader.get() || !filter.get()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkFilterShader, (shader, filter));
|
||||
}
|
||||
|
||||
void SkFilterShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeFlattenable(fShader);
|
||||
buffer.writeFlattenable(fFilter);
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader)
|
||||
|
||||
protected:
|
||||
SkFilterShader(SkReadBuffer& );
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkFilterShader(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
|
||||
|
||||
|
@ -1,22 +1,21 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkPtrRecorder.h"
|
||||
#include "SkReadBuffer.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkFlattenable::flatten(SkWriteBuffer&) const
|
||||
{
|
||||
/* we don't write anything at the moment, but this allows our subclasses
|
||||
to not know that, since we want them to always call INHERITED::flatten()
|
||||
in their code.
|
||||
*/
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
bool SkFlattenable::NeedsDeepUnflatten(const SkReadBuffer& buffer) {
|
||||
return buffer.isVersionLT(SkReadBuffer::kFlattenCreateProc_Version);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -75,11 +75,11 @@ void SkImageFilter::Common::detachInputs(SkImageFilter** inputs) {
|
||||
}
|
||||
|
||||
bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) {
|
||||
int count = buffer.readInt();
|
||||
if (expectedCount < 0) { // means the caller doesn't care how many
|
||||
expectedCount = count;
|
||||
const int count = buffer.readInt();
|
||||
if (!buffer.validate(count >= 0)) {
|
||||
return false;
|
||||
}
|
||||
if (!buffer.validate((count == expectedCount) && (count >= 0))) {
|
||||
if (!buffer.validate(expectedCount < 0 || count == expectedCount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "SkLocalMatrixShader.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kSimplifyLocalMatrix_Version)) {
|
||||
buffer.readMatrix(&(INHERITED::fLocalMatrix));
|
||||
@ -16,9 +17,20 @@ SkLocalMatrixShader::SkLocalMatrixShader(SkReadBuffer& buffer) : INHERITED(buffe
|
||||
sk_throw();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix lm;
|
||||
buffer.readMatrix(&lm);
|
||||
SkAutoTUnref<SkShader> shader(buffer.readShader());
|
||||
if (!shader.get()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkShader::CreateLocalMatrixShader(shader, lm);
|
||||
}
|
||||
|
||||
void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeMatrix(this->getLocalMatrix());
|
||||
buffer.writeFlattenable(fProxyShader.get());
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixShader)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLocalMatrixShader(SkReadBuffer&);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE;
|
||||
|
||||
|
@ -45,19 +45,26 @@ SkPairPathEffect::~SkPairPathEffect() {
|
||||
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
|
||||
*/
|
||||
void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeFlattenable(fPE0);
|
||||
buffer.writeFlattenable(fPE1);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) {
|
||||
fPE0 = buffer.readPathEffect();
|
||||
fPE1 = buffer.readPathEffect();
|
||||
// either of these may fail, so we have to check for nulls later on
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
|
||||
SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
|
||||
return SkComposePathEffect::Create(pe0, pe1);
|
||||
}
|
||||
|
||||
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||
SkStrokeRec* rec, const SkRect* cullRect) const {
|
||||
// we may have failed to unflatten these, so we have to check
|
||||
@ -76,6 +83,12 @@ bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
|
||||
SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
|
||||
return SkSumPathEffect::Create(pe0, pe1);
|
||||
}
|
||||
|
||||
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||
SkStrokeRec* rec, const SkRect* cullRect) const {
|
||||
// use bit-or so that we always call both, even if the first one succeeds
|
||||
|
@ -28,13 +28,14 @@ SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
|
||||
SkIntToScalar(picture->height()));
|
||||
}
|
||||
|
||||
SkPictureShader::SkPictureShader(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPictureShader::SkPictureShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fTmx = static_cast<SkShader::TileMode>(buffer.read32());
|
||||
fTmy = static_cast<SkShader::TileMode>(buffer.read32());
|
||||
buffer.readRect(&fTile);
|
||||
fPicture = SkPicture::CreateFromBuffer(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
SkPictureShader::~SkPictureShader() {
|
||||
fPicture->unref();
|
||||
@ -49,9 +50,19 @@ SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
|
||||
return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile));
|
||||
}
|
||||
|
||||
void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix lm;
|
||||
buffer.readMatrix(&lm);
|
||||
TileMode mx = (TileMode)buffer.read32();
|
||||
TileMode my = (TileMode)buffer.read32();
|
||||
SkRect tile;
|
||||
buffer.readRect(&tile);
|
||||
SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromBuffer(buffer));
|
||||
return SkPictureShader::Create(picture, mx, my, &lm, &tile);
|
||||
}
|
||||
|
||||
void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeMatrix(this->getLocalMatrix());
|
||||
buffer.write32(fTmx);
|
||||
buffer.write32(fTmy);
|
||||
buffer.writeRect(fTile);
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
kSimplifyLocalMatrix_Version = 30,
|
||||
kImageFilterUniqueID_Version = 31,
|
||||
kRemoveAndroidPaintOpts_Version = 32,
|
||||
kFlattenCreateProc_Version = 33,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ SkShader::SkShader(const SkMatrix* localMatrix) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
inc_shader_counter();
|
||||
if (buffer.readBool()) {
|
||||
@ -53,6 +54,7 @@ SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fLocalMatrix.reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SkShader::~SkShader() {
|
||||
dec_shader_counter();
|
||||
@ -254,6 +256,7 @@ bool SkColorShader::isOpaque() const {
|
||||
return SkColorGetA(fColor) == 255;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) {
|
||||
// V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit the paint's
|
||||
// color. We don't support that any more.
|
||||
@ -266,9 +269,13 @@ SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) {
|
||||
}
|
||||
fColor = b.readColor();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkColorShader, (buffer.readColor()));
|
||||
}
|
||||
|
||||
void SkColorShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeColor(fColor);
|
||||
}
|
||||
|
||||
@ -383,6 +390,10 @@ void SkColorShader::toString(SkString* str) const {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
|
||||
return SkShader::CreateEmptyShader();
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
#include "SkEmptyShader.h"
|
||||
|
||||
|
@ -1240,6 +1240,7 @@ GrEffect* XferEffect::TestCreate(SkRandom* rand,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkProcCoeffXfermode::SkProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
uint32_t mode32 = buffer.read32() % SK_ARRAY_COUNT(gProcCoeffs);
|
||||
if (mode32 >= SK_ARRAY_COUNT(gProcCoeffs)) {
|
||||
@ -1254,6 +1255,19 @@ SkProcCoeffXfermode::SkProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffe
|
||||
fSrcCoeff = rec.fSC;
|
||||
fDstCoeff = rec.fDC;
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) {
|
||||
uint32_t mode32 = buffer.read32();
|
||||
if (!buffer.validate(mode32 >= SK_ARRAY_COUNT(gProcCoeffs))) {
|
||||
return NULL;
|
||||
}
|
||||
return SkXfermode::Create((SkXfermode::Mode)mode32);
|
||||
}
|
||||
|
||||
void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.write32(fMode);
|
||||
}
|
||||
|
||||
bool SkProcCoeffXfermode::asMode(Mode* mode) const {
|
||||
if (mode) {
|
||||
@ -1376,11 +1390,6 @@ bool SkProcCoeffXfermode::asNewEffect(GrEffect** effect, GrTexture* background)
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.write32(fMode);
|
||||
}
|
||||
|
||||
const char* SkXfermode::ModeName(Mode mode) {
|
||||
SkASSERT((unsigned) mode <= (unsigned)kLastMode);
|
||||
const char* gModeStrings[] = {
|
||||
@ -1433,12 +1442,12 @@ public:
|
||||
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode)
|
||||
|
||||
private:
|
||||
SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
|
||||
SkClearXfermode(SkReadBuffer& buffer)
|
||||
: SkProcCoeffXfermode(buffer) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkClearXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {}
|
||||
#endif
|
||||
|
||||
typedef SkProcCoeffXfermode INHERITED;
|
||||
};
|
||||
@ -1498,13 +1507,12 @@ public:
|
||||
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode)
|
||||
|
||||
private:
|
||||
SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
|
||||
SkSrcXfermode(SkReadBuffer& buffer)
|
||||
: SkProcCoeffXfermode(buffer) {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkSrcXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {}
|
||||
#endif
|
||||
typedef SkProcCoeffXfermode INHERITED;
|
||||
};
|
||||
|
||||
@ -1567,11 +1575,12 @@ public:
|
||||
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode)
|
||||
|
||||
private:
|
||||
SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
typedef SkProcCoeffXfermode INHERITED;
|
||||
};
|
||||
@ -1613,12 +1622,12 @@ public:
|
||||
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode)
|
||||
|
||||
private:
|
||||
SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
|
||||
SkDstOutXfermode(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDstOutXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
typedef SkProcCoeffXfermode INHERITED;
|
||||
};
|
||||
@ -1692,7 +1701,7 @@ SkXfermode* create_mode(int iMode) {
|
||||
break;
|
||||
default:
|
||||
// no special-case, just rely in the rec and its function-ptrs
|
||||
xfer = SkProcCoeffXfermode::Create(rec, mode);
|
||||
xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1952,14 +1961,4 @@ SkXfermodeProc16 SkXfermode::GetProc16(Mode mode, SkColor srcColor) {
|
||||
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
|
||||
#if !SK_ARM_NEON_IS_NONE
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode)
|
||||
#endif
|
||||
#if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSSE2ProcCoeffXfermode)
|
||||
#endif
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
@ -15,10 +15,14 @@ struct ProcCoeff {
|
||||
|
||||
class SK_API SkProcCoeffXfermode : public SkXfermode {
|
||||
public:
|
||||
static SkProcCoeffXfermode* Create(const ProcCoeff& rec, Mode mode) {
|
||||
return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
|
||||
SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) {
|
||||
fMode = mode;
|
||||
fProc = rec.fProc;
|
||||
// these may be valid, or may be CANNOT_USE_COEFF
|
||||
fSrcCoeff = rec.fSC;
|
||||
fDstCoeff = rec.fDC;
|
||||
}
|
||||
|
||||
|
||||
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const SK_OVERRIDE;
|
||||
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
||||
@ -39,15 +43,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
|
||||
|
||||
protected:
|
||||
SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) {
|
||||
fMode = mode;
|
||||
fProc = rec.fProc;
|
||||
// these may be valid, or may be CANNOT_USE_COEFF
|
||||
fSrcCoeff = rec.fSC;
|
||||
fDstCoeff = rec.fDC;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkProcCoeffXfermode(SkReadBuffer& buffer);
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
|
||||
@ -60,6 +58,8 @@ private:
|
||||
Mode fMode;
|
||||
Coeff fSrcCoeff, fDstCoeff;
|
||||
|
||||
friend class SkXfermode;
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
};
|
||||
|
||||
|
@ -147,6 +147,7 @@ static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPath1DPathEffect::SkPath1DPathEffect(SkReadBuffer& buffer) {
|
||||
fAdvance = buffer.readScalar();
|
||||
if (fAdvance > 0) {
|
||||
@ -160,13 +161,25 @@ SkPath1DPathEffect::SkPath1DPathEffect(SkReadBuffer& buffer) {
|
||||
fStyle = kStyleCount;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const {
|
||||
return fInitialOffset;
|
||||
}
|
||||
|
||||
SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkScalar advance = buffer.readScalar();
|
||||
if (advance > 0) {
|
||||
SkPath path;
|
||||
buffer.readPath(&path);
|
||||
SkScalar phase = buffer.readScalar();
|
||||
Style style = (Style)buffer.readUInt();
|
||||
return SkPath1DPathEffect::Create(path, advance, phase, style);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fAdvance);
|
||||
if (fAdvance > 0) {
|
||||
buffer.writePath(fPath);
|
||||
|
@ -73,10 +73,12 @@ void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeMatrix(fMatrix);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) {
|
||||
buffer.readMatrix(&fMatrix);
|
||||
fMatrixIsInvertible = fMatrix.invert(&fInverse);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -102,12 +104,21 @@ void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fWidth = buffer.readScalar();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix matrix;
|
||||
buffer.readMatrix(&matrix);
|
||||
SkScalar width = buffer.readScalar();
|
||||
return SkLine2DPathEffect::Create(width, matrix);
|
||||
}
|
||||
|
||||
void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeMatrix(this->getMatrix());
|
||||
buffer.writeScalar(fWidth);
|
||||
}
|
||||
|
||||
@ -117,13 +128,22 @@ SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)
|
||||
: INHERITED(m), fPath(p) {
|
||||
}
|
||||
|
||||
SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
buffer.readPath(&fPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkMatrix matrix;
|
||||
buffer.readMatrix(&matrix);
|
||||
SkPath path;
|
||||
buffer.readPath(&path);
|
||||
return SkPath2DPathEffect::Create(matrix, path);
|
||||
}
|
||||
|
||||
void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeMatrix(this->getMatrix());
|
||||
buffer.writePath(fPath);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,9 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl)
|
||||
|
||||
protected:
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
@ -233,12 +235,23 @@ void AlphaThresholdEffect::getConstantColorComponents(GrColor* color, uint32_t*
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fInnerThreshold = buffer.readScalar();
|
||||
fOuterThreshold = buffer.readScalar();
|
||||
buffer.readRegion(&fRegion);
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkScalar inner = buffer.readScalar();
|
||||
SkScalar outer = buffer.readScalar();
|
||||
SkRegion rgn;
|
||||
buffer.readRegion(&rgn);
|
||||
return SkAlphaThresholdFilter::Create(rgn, inner, outer, common.getInput(0));
|
||||
}
|
||||
|
||||
SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
|
||||
SkScalar innerThreshold,
|
||||
|
@ -47,6 +47,7 @@ private:
|
||||
fEnforcePMColor = enforcePMColor;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fK[0] = buffer.readScalar();
|
||||
fK[1] = buffer.readScalar();
|
||||
@ -54,9 +55,9 @@ private:
|
||||
fK[3] = buffer.readScalar();
|
||||
fEnforcePMColor = buffer.readBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fK[0]);
|
||||
buffer.writeScalar(fK[1]);
|
||||
buffer.writeScalar(fK[2]);
|
||||
@ -66,9 +67,20 @@ private:
|
||||
SkScalar fK[4];
|
||||
bool fEnforcePMColor;
|
||||
|
||||
friend class SkArithmeticMode;
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) {
|
||||
const SkScalar k1 = buffer.readScalar();
|
||||
const SkScalar k2 = buffer.readScalar();
|
||||
const SkScalar k3 = buffer.readScalar();
|
||||
const SkScalar k4 = buffer.readScalar();
|
||||
const bool enforcePMColor = buffer.readBool();
|
||||
return Create(k1, k2, k3, k4, enforcePMColor);
|
||||
}
|
||||
|
||||
static int pinToByte(int value) {
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
|
@ -15,24 +15,30 @@ SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) {
|
||||
if (tolerance > 255) {
|
||||
tolerance = 255;
|
||||
}
|
||||
|
||||
fTolerance = SkToU8(tolerance);
|
||||
fOpColor = opColor;
|
||||
fDistMul = (256 << 14) / (tolerance + 1);
|
||||
fMode = mode;
|
||||
}
|
||||
|
||||
SkAvoidXfermode::SkAvoidXfermode(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkAvoidXfermode::SkAvoidXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fOpColor = buffer.readColor();
|
||||
fDistMul = buffer.readUInt();
|
||||
fMode = (Mode)buffer.readUInt();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) {
|
||||
const SkColor color = buffer.readColor();
|
||||
const unsigned tolerance = buffer.readUInt();
|
||||
const unsigned mode = buffer.readUInt();
|
||||
return Create(color, tolerance, (Mode)mode);
|
||||
}
|
||||
|
||||
void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
||||
buffer.writeColor(fOpColor);
|
||||
buffer.writeUInt(fDistMul);
|
||||
buffer.writeUInt(fTolerance);
|
||||
buffer.writeUInt(fMode);
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,12 @@
|
||||
#include "SkValidationUtils.h"
|
||||
|
||||
SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap)
|
||||
: INHERITED(0, 0),
|
||||
fBitmap(bitmap),
|
||||
fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()),
|
||||
SkIntToScalar(bitmap.height()))),
|
||||
fDstRect(fSrcRect) {
|
||||
}
|
||||
: INHERITED(0, 0)
|
||||
, fBitmap(bitmap)
|
||||
, fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()),
|
||||
SkIntToScalar(bitmap.height())))
|
||||
, fDstRect(fSrcRect)
|
||||
{}
|
||||
|
||||
SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect)
|
||||
: INHERITED(0, 0)
|
||||
@ -26,6 +26,7 @@ SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co
|
||||
, fSrcRect(srcRect)
|
||||
, fDstRect(dstRect) {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) {
|
||||
if (buffer.isVersionLT(SkReadBuffer::kNoMoreBitmapFlatten_Version)) {
|
||||
fBitmap.legacyUnflatten(buffer);
|
||||
@ -36,12 +37,23 @@ SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) {
|
||||
buffer.readRect(&fDstRect);
|
||||
buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) {
|
||||
SkRect src, dst;
|
||||
buffer.readRect(&src);
|
||||
buffer.readRect(&dst);
|
||||
SkBitmap bitmap;
|
||||
if (!buffer.readBitmap(&bitmap)) {
|
||||
return NULL;
|
||||
}
|
||||
return SkBitmapSource::Create(bitmap, src, dst);
|
||||
}
|
||||
|
||||
void SkBitmapSource::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeBitmap(fBitmap);
|
||||
buffer.writeRect(fSrcRect);
|
||||
buffer.writeRect(fDstRect);
|
||||
buffer.writeBitmap(fBitmap);
|
||||
}
|
||||
|
||||
bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
|
||||
|
@ -62,6 +62,7 @@ void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy,
|
||||
this->initEffects();
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
|
||||
fSigma = buffer.readScalar();
|
||||
@ -72,13 +73,22 @@ SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
|
||||
this->initEffects();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkBlurDrawLooper::CreateProc(SkReadBuffer& buffer) {
|
||||
const SkColor color = buffer.readColor();
|
||||
const SkScalar sigma = buffer.readScalar();
|
||||
const SkScalar dx = buffer.readScalar();
|
||||
const SkScalar dy = buffer.readScalar();
|
||||
const uint32_t flags = buffer.read32();
|
||||
return Create(color, sigma, dx, dy, flags);
|
||||
}
|
||||
|
||||
void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeColor(fBlurColor);
|
||||
buffer.writeScalar(fSigma);
|
||||
buffer.writeScalar(fDx);
|
||||
buffer.writeScalar(fDy);
|
||||
buffer.writeColor(fBlurColor);
|
||||
buffer.write32(fBlurFlags);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
// raster paths.
|
||||
#define MAX_SIGMA SkIntToScalar(532)
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fSigma.fWidth = buffer.readScalar();
|
||||
@ -32,6 +33,7 @@ SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
|
||||
(fSigma.fWidth >= 0) &&
|
||||
(fSigma.fHeight >= 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX,
|
||||
SkScalar sigmaY,
|
||||
@ -41,6 +43,13 @@ SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX,
|
||||
SkASSERT(sigmaX >= 0 && sigmaY >= 0);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fSigma.fWidth);
|
||||
|
@ -108,6 +108,8 @@ private:
|
||||
return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
|
||||
}
|
||||
|
||||
friend class SkBlurMaskFilter;
|
||||
|
||||
typedef SkMaskFilter INHERITED;
|
||||
};
|
||||
|
||||
@ -522,19 +524,29 @@ void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src,
|
||||
src.fRight + pad, src.fBottom + pad);
|
||||
}
|
||||
|
||||
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer)
|
||||
: SkMaskFilter(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) : SkMaskFilter(buffer) {
|
||||
fSigma = buffer.readScalar();
|
||||
fBlurStyle = (SkBlurStyle)buffer.readInt();
|
||||
fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag;
|
||||
SkASSERT(fSigma > 0);
|
||||
SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle);
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
|
||||
const SkScalar sigma = buffer.readScalar();
|
||||
const unsigned style = buffer.readUInt();
|
||||
const unsigned flags = buffer.readUInt();
|
||||
if (style <= kLastEnum_SkBlurStyle) {
|
||||
return SkBlurMaskFilter::Create((SkBlurStyle)style, sigma, flags);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fSigma);
|
||||
buffer.writeInt(fBlurStyle);
|
||||
buffer.writeUInt(fBlurStyle);
|
||||
buffer.writeUInt(fBlurFlags);
|
||||
}
|
||||
|
||||
|
@ -83,14 +83,20 @@ SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
|
||||
SkSafeRef(cf);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fColorFilter = buffer.readColorFilter();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
return Create(buffer.readColorFilter(), common.getInput(0), &common.cropRect());
|
||||
}
|
||||
|
||||
void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
||||
buffer.writeFlattenable(fColorFilter);
|
||||
}
|
||||
|
||||
|
@ -15,17 +15,9 @@
|
||||
#include "SkValidationUtils.h"
|
||||
#include "SkColorMatrixFilter.h"
|
||||
|
||||
#define ILLEGAL_XFERMODE_MODE ((SkXfermode::Mode)-1)
|
||||
|
||||
// baseclass for filters that store a color and mode
|
||||
class SkModeColorFilter : public SkColorFilter {
|
||||
public:
|
||||
SkModeColorFilter(SkColor color) {
|
||||
fColor = color;
|
||||
fMode = ILLEGAL_XFERMODE_MODE;
|
||||
this->updateCache();
|
||||
}
|
||||
|
||||
SkModeColorFilter(SkColor color, SkXfermode::Mode mode) {
|
||||
fColor = color;
|
||||
fMode = mode;
|
||||
@ -34,14 +26,9 @@ public:
|
||||
|
||||
SkColor getColor() const { return fColor; }
|
||||
SkXfermode::Mode getMode() const { return fMode; }
|
||||
bool isModeValid() const { return ILLEGAL_XFERMODE_MODE != fMode; }
|
||||
SkPMColor getPMColor() const { return fPMColor; }
|
||||
|
||||
virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode) const SK_OVERRIDE {
|
||||
if (ILLEGAL_XFERMODE_MODE == fMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (color) {
|
||||
*color = fColor;
|
||||
}
|
||||
@ -93,11 +80,11 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeColor(fColor);
|
||||
buffer.writeUInt(fMode);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkModeColorFilter(SkReadBuffer& buffer) {
|
||||
fColor = buffer.readColor();
|
||||
fMode = (SkXfermode::Mode)buffer.readUInt();
|
||||
@ -106,6 +93,7 @@ protected:
|
||||
buffer.validate(SkIsValidMode(fMode));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkColor fColor;
|
||||
@ -121,9 +109,17 @@ private:
|
||||
fProc16 = SkXfermode::GetProc16(fMode, fColor);
|
||||
}
|
||||
|
||||
friend class SkColorFilter;
|
||||
|
||||
typedef SkColorFilter INHERITED;
|
||||
};
|
||||
|
||||
SkFlattenable* SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SkColor color = buffer.readColor();
|
||||
SkXfermode::Mode mode = (SkXfermode::Mode)buffer.readUInt();
|
||||
return SkColorFilter::CreateModeFilter(color, mode);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrBlend.h"
|
||||
@ -443,12 +439,6 @@ public:
|
||||
sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count);
|
||||
}
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Src_SkModeColorFilter)
|
||||
|
||||
protected:
|
||||
Src_SkModeColorFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {}
|
||||
|
||||
private:
|
||||
typedef SkModeColorFilter INHERITED;
|
||||
};
|
||||
@ -479,14 +469,6 @@ public:
|
||||
sk_memset16(result, SkPixel32ToPixel16(this->getPMColor()), count);
|
||||
}
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SrcOver_SkModeColorFilter)
|
||||
|
||||
protected:
|
||||
SrcOver_SkModeColorFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
fColor32Proc = SkBlitRow::ColorProcFactory();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
SkBlitRow::ColorProc fColor32Proc;
|
||||
@ -496,8 +478,11 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkColorFilter* SkColorFilter::CreateModeFilter(SkColor color,
|
||||
SkXfermode::Mode mode) {
|
||||
SkColorFilter* SkColorFilter::CreateModeFilter(SkColor color, SkXfermode::Mode mode) {
|
||||
if (!SkIsValidMode(mode)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned alpha = SkColorGetA(color);
|
||||
|
||||
// first collaps some modes if possible
|
||||
@ -562,6 +547,4 @@ SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
|
||||
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Src_SkModeColorFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SrcOver_SkModeColorFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
@ -303,18 +303,26 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkColorMatrixFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20);
|
||||
buffer.writeScalarArray(fMatrix.fMat, 20);
|
||||
}
|
||||
|
||||
SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
SkASSERT(buffer.getArrayCount() == 20);
|
||||
if (buffer.readScalarArray(fMatrix.fMat, 20)) {
|
||||
this->initState(fMatrix.fMat);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkColorMatrixFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SkColorMatrix matrix;
|
||||
if (buffer.readScalarArray(matrix.fMat, 20)) {
|
||||
return Create(matrix);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const {
|
||||
if (matrix) {
|
||||
|
@ -21,14 +21,6 @@ bool SkComposeImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkImageFilter* outer = getInput(0);
|
||||
SkImageFilter* inner = getInput(1);
|
||||
|
||||
if (!outer && !inner) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!outer || !inner) {
|
||||
return (outer ? outer : inner)->filterImage(proxy, src, ctx, result, offset);
|
||||
}
|
||||
|
||||
SkBitmap tmp;
|
||||
return inner->filterImage(proxy, src, ctx, &tmp, offset) &&
|
||||
outer->filterImage(proxy, tmp, ctx, result, offset);
|
||||
@ -40,19 +32,17 @@ bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
|
||||
SkImageFilter* outer = getInput(0);
|
||||
SkImageFilter* inner = getInput(1);
|
||||
|
||||
if (!outer && !inner) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!outer || !inner) {
|
||||
return (outer ? outer : inner)->filterBounds(src, ctm, dst);
|
||||
}
|
||||
|
||||
SkIRect tmp;
|
||||
return inner->filterBounds(src, ctm, &tmp) &&
|
||||
outer->filterBounds(tmp, ctm, dst);
|
||||
return inner->filterBounds(src, ctm, &tmp) && outer->filterBounds(tmp, ctm, dst);
|
||||
}
|
||||
|
||||
SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
|
||||
return SkComposeImageFilter::Create(common.getInput(0), common.getInput(1));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkComposeImageFilter::SkComposeImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(2, buffer) {
|
||||
}
|
||||
#endif
|
||||
|
@ -128,11 +128,16 @@ DONE:
|
||||
return true;
|
||||
}
|
||||
|
||||
SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkCornerPathEffect::Create(buffer.readScalar());
|
||||
}
|
||||
|
||||
void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fRadius);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkCornerPathEffect::SkCornerPathEffect(SkReadBuffer& buffer) {
|
||||
fRadius = buffer.readScalar();
|
||||
}
|
||||
#endif
|
||||
|
@ -238,20 +238,22 @@ SkPathEffect::DashType SkDashPathEffect::asADash(DashInfo* info) const {
|
||||
return kDash_DashType;
|
||||
}
|
||||
|
||||
SkFlattenable::Factory SkDashPathEffect::getFactory() const {
|
||||
return CreateProc;
|
||||
}
|
||||
|
||||
void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fPhase);
|
||||
buffer.writeScalarArray(fIntervals, fCount);
|
||||
}
|
||||
|
||||
SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkDashPathEffect, (buffer));
|
||||
const SkScalar phase = buffer.readScalar();
|
||||
uint32_t count = buffer.getArrayCount();
|
||||
SkAutoSTArray<32, SkScalar> intervals(count);
|
||||
if (buffer.readScalarArray(intervals.get(), count)) {
|
||||
return Create(intervals.get(), SkToInt(count), phase);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer)
|
||||
, fPhase(0)
|
||||
@ -292,3 +294,5 @@ SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer)
|
||||
&fInitialDashLength, &fInitialDashIndex, &fIntervalLength);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -75,15 +75,24 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||
return true;
|
||||
}
|
||||
|
||||
SkFlattenable* SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SkScalar segLength = buffer.readScalar();
|
||||
SkScalar perterb = buffer.readScalar();
|
||||
uint32_t seed = buffer.readUInt();
|
||||
return Create(segLength, perterb, seed);
|
||||
}
|
||||
|
||||
void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fSegLength);
|
||||
buffer.writeScalar(fPerterb);
|
||||
buffer.writeUInt(fSeedAssist);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDiscretePathEffect::SkDiscretePathEffect(SkReadBuffer& buffer) {
|
||||
fSegLength = buffer.readScalar();
|
||||
fPerterb = buffer.readScalar();
|
||||
fSeedAssist = buffer.readUInt();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -159,6 +159,22 @@ bool channel_selector_type_is_valid(SkDisplacementMapEffect::ChannelSelectorType
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkDisplacementMapEffect* SkDisplacementMapEffect::Create(ChannelSelectorType xChannelSelector,
|
||||
ChannelSelectorType yChannelSelector,
|
||||
SkScalar scale,
|
||||
SkImageFilter* displacement,
|
||||
SkImageFilter* color,
|
||||
const CropRect* cropRect) {
|
||||
if (!channel_selector_type_is_valid(xChannelSelector) ||
|
||||
!channel_selector_type_is_valid(yChannelSelector)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkImageFilter* inputs[2] = { displacement, color };
|
||||
return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
|
||||
inputs, cropRect));
|
||||
}
|
||||
|
||||
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
|
||||
ChannelSelectorType yChannelSelector,
|
||||
SkScalar scale,
|
||||
@ -174,6 +190,7 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel
|
||||
SkDisplacementMapEffect::~SkDisplacementMapEffect() {
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDisplacementMapEffect::SkDisplacementMapEffect(SkReadBuffer& buffer)
|
||||
: INHERITED(2, buffer)
|
||||
{
|
||||
@ -184,6 +201,15 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(SkReadBuffer& buffer)
|
||||
channel_selector_type_is_valid(fYChannelSelector) &&
|
||||
SkScalarIsFinite(fScale));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
|
||||
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());
|
||||
}
|
||||
|
||||
void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
@ -27,6 +27,7 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy,
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDropShadowImageFilter::SkDropShadowImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fDx = buffer.readScalar();
|
||||
@ -39,9 +40,19 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkReadBuffer& buffer)
|
||||
SkScalarIsFinite(fSigmaX) &&
|
||||
SkScalarIsFinite(fSigmaY));
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const
|
||||
{
|
||||
SkFlattenable* SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkScalar dx = buffer.readScalar();
|
||||
SkScalar dy = buffer.readScalar();
|
||||
SkScalar sigmaX = buffer.readScalar();
|
||||
SkScalar sigmaY = buffer.readScalar();
|
||||
SkColor color = buffer.readColor();
|
||||
return Create(dx, dy, sigmaX, sigmaY, color, common.getInput(0), &common.cropRect());
|
||||
}
|
||||
|
||||
void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fDx);
|
||||
buffer.writeScalar(fDy);
|
||||
|
@ -124,17 +124,26 @@ bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src,
|
||||
return true;
|
||||
}
|
||||
|
||||
SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer)
|
||||
: SkMaskFilter(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer) : SkMaskFilter(buffer) {
|
||||
SkASSERT(buffer.getArrayCount() == sizeof(Light));
|
||||
buffer.readByteArray(&fLight, sizeof(Light));
|
||||
SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean
|
||||
fBlurSigma = buffer.readScalar();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
Light light;
|
||||
if (buffer.readByteArray(&light, sizeof(Light))) {
|
||||
light.fPad = 0; // for the font-cache lookup to be clean
|
||||
const SkScalar sigma = buffer.readScalar();
|
||||
return Create(sigma, light);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
||||
Light tmpLight = fLight;
|
||||
tmpLight.fPad = 0; // for the font-cache lookup to be clean
|
||||
buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
|
||||
|
@ -200,20 +200,6 @@ bool SkLayerDrawLooper::asABlurShadow(BlurShadowRec* bsRec) const {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
Rec* rec = fRecs;
|
||||
int count = 0;
|
||||
while (rec) {
|
||||
rec = rec->fNext;
|
||||
count += 1;
|
||||
}
|
||||
SkASSERT(count == fCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer.writeInt(fCount);
|
||||
|
||||
Rec* rec = fRecs;
|
||||
@ -245,22 +231,7 @@ SkFlattenable* SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) {
|
||||
info.fPostTranslate = buffer.readBool();
|
||||
buffer.readPaint(builder.addLayerOnTop(info));
|
||||
}
|
||||
SkLayerDrawLooper* looper = builder.detachLooper();
|
||||
SkASSERT(count == looper->fCount);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
Rec* rec = looper->fRecs;
|
||||
int n = 0;
|
||||
while (rec) {
|
||||
rec = rec->fNext;
|
||||
n += 1;
|
||||
}
|
||||
SkASSERT(count == n);
|
||||
}
|
||||
#endif
|
||||
|
||||
return looper;
|
||||
return builder.detachLooper();
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
|
@ -148,12 +148,18 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLayerRasterizer::SkLayerRasterizer(SkReadBuffer& buffer)
|
||||
: SkRasterizer(buffer), fLayers(ReadLayers(buffer)) {}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkLayerRasterizer, (ReadLayers(buffer)));
|
||||
}
|
||||
|
||||
SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
|
||||
int count = buffer.readInt();
|
||||
|
||||
|
||||
SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec)));
|
||||
for (int i = 0; i < count; i++) {
|
||||
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back();
|
||||
|
@ -23,16 +23,20 @@ SkXfermode* SkLerpXfermode::Create(SkScalar scale) {
|
||||
|
||||
SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {}
|
||||
|
||||
SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fScale256 = buffer.readUInt();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeUInt(fScale256);
|
||||
}
|
||||
|
||||
SkFlattenable* SkLerpXfermode::CreateProc(SkReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkLerpXfermode, (buffer.readUInt()));
|
||||
}
|
||||
|
||||
void SkLerpXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const {
|
||||
const int scale = fScale256;
|
||||
|
@ -264,13 +264,18 @@ void writePoint3(const SkPoint3& point, SkWriteBuffer& buffer) {
|
||||
|
||||
class SkDiffuseLightingImageFilter : public SkLightingImageFilter {
|
||||
public:
|
||||
SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale,
|
||||
SkScalar kd, SkImageFilter* input, const CropRect* cropRect);
|
||||
static SkImageFilter* Create(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter*,
|
||||
const CropRect*);
|
||||
|
||||
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);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
@ -280,20 +285,27 @@ protected:
|
||||
#endif
|
||||
|
||||
private:
|
||||
friend class SkLightingImageFilter;
|
||||
typedef SkLightingImageFilter INHERITED;
|
||||
SkScalar fKD;
|
||||
};
|
||||
|
||||
class SkSpecularLightingImageFilter : public SkLightingImageFilter {
|
||||
public:
|
||||
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect);
|
||||
static SkImageFilter* Create(SkLight* light, SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess, SkImageFilter*, const CropRect*);
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
|
||||
|
||||
SkScalar ks() const { return fKS; }
|
||||
SkScalar shininess() const { return fShininess; }
|
||||
|
||||
protected:
|
||||
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks,
|
||||
SkScalar shininess, SkImageFilter* input, const CropRect*);
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer);
|
||||
#endif
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
@ -303,9 +315,10 @@ protected:
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SkLightingImageFilter INHERITED;
|
||||
SkScalar fKS;
|
||||
SkScalar fShininess;
|
||||
friend class SkLightingImageFilter;
|
||||
typedef SkLightingImageFilter INHERITED;
|
||||
};
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
@ -832,101 +845,139 @@ void SkLight::flattenLight(SkWriteBuffer& buffer) const {
|
||||
|
||||
SkLightingImageFilter::SkLightingImageFilter(SkLight* light, SkScalar surfaceScale,
|
||||
SkImageFilter* input, const CropRect* cropRect)
|
||||
: INHERITED(1, &input, cropRect),
|
||||
fLight(light),
|
||||
fSurfaceScale(SkScalarDiv(surfaceScale, SkIntToScalar(255)))
|
||||
{
|
||||
SkASSERT(fLight);
|
||||
// our caller knows that we take ownership of the light, so we don't
|
||||
// need to call ref() here.
|
||||
: INHERITED(1, &input, cropRect)
|
||||
, fLight(SkRef(light))
|
||||
, fSurfaceScale(surfaceScale / 255)
|
||||
{}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreateDistantLitDiffuse(const SkPoint3& direction,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkDistantLight, (direction, lightColor)));
|
||||
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreateDistantLitDiffuse(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale,
|
||||
SkScalar kd, SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkDiffuseLightingImageFilter,
|
||||
(SkNEW_ARGS(SkDistantLight, (direction, lightColor)), surfaceScale, kd,
|
||||
input, cropRect));
|
||||
SkImageFilter* SkLightingImageFilter::CreatePointLitDiffuse(const SkPoint3& location,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkPointLight, (location, lightColor)));
|
||||
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreatePointLitDiffuse(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale,
|
||||
SkScalar kd, SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkDiffuseLightingImageFilter,
|
||||
(SkNEW_ARGS(SkPointLight, (location, lightColor)), surfaceScale, kd,
|
||||
input, cropRect));
|
||||
SkImageFilter* SkLightingImageFilter::CreateSpotLitDiffuse(const SkPoint3& location,
|
||||
const SkPoint3& target,
|
||||
SkScalar specularExponent,
|
||||
SkScalar cutoffAngle,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar kd,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkSpotLight, (location, target, specularExponent,
|
||||
cutoffAngle, lightColor)));
|
||||
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreateSpotLitDiffuse(
|
||||
const SkPoint3& location, const SkPoint3& target,
|
||||
SkScalar specularExponent, SkScalar cutoffAngle,
|
||||
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
|
||||
SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkDiffuseLightingImageFilter,
|
||||
(SkNEW_ARGS(SkSpotLight, (location, target, specularExponent,
|
||||
cutoffAngle, lightColor)),
|
||||
surfaceScale, kd, input, cropRect));
|
||||
SkImageFilter* SkLightingImageFilter::CreateDistantLitSpecular(const SkPoint3& direction,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar ks,
|
||||
SkScalar shine,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkDistantLight, (direction, lightColor)));
|
||||
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreateDistantLitSpecular(
|
||||
const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkSpecularLightingImageFilter,
|
||||
(SkNEW_ARGS(SkDistantLight, (direction, lightColor)),
|
||||
surfaceScale, ks, shininess, input, cropRect));
|
||||
SkImageFilter* SkLightingImageFilter::CreatePointLitSpecular(const SkPoint3& location,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar ks,
|
||||
SkScalar shine,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkPointLight, (location, lightColor)));
|
||||
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreatePointLitSpecular(
|
||||
const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkSpecularLightingImageFilter,
|
||||
(SkNEW_ARGS(SkPointLight, (location, lightColor)),
|
||||
surfaceScale, ks, shininess, input, cropRect));
|
||||
SkImageFilter* SkLightingImageFilter::CreateSpotLitSpecular(const SkPoint3& location,
|
||||
const SkPoint3& target,
|
||||
SkScalar specularExponent,
|
||||
SkScalar cutoffAngle,
|
||||
SkColor lightColor,
|
||||
SkScalar surfaceScale,
|
||||
SkScalar ks,
|
||||
SkScalar shine,
|
||||
SkImageFilter* input,
|
||||
const CropRect* cropRect) {
|
||||
SkAutoTUnref<SkLight> light(SkNEW_ARGS(SkSpotLight, (location, target, specularExponent,
|
||||
cutoffAngle, lightColor)));
|
||||
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
|
||||
}
|
||||
|
||||
SkImageFilter* SkLightingImageFilter::CreateSpotLitSpecular(
|
||||
const SkPoint3& location, const SkPoint3& target,
|
||||
SkScalar specularExponent, SkScalar cutoffAngle,
|
||||
SkColor lightColor, SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect) {
|
||||
return SkNEW_ARGS(SkSpecularLightingImageFilter,
|
||||
(SkNEW_ARGS(SkSpotLight, (location, target, specularExponent, cutoffAngle, lightColor)),
|
||||
surfaceScale, ks, shininess, input, cropRect));
|
||||
}
|
||||
|
||||
SkLightingImageFilter::~SkLightingImageFilter() {
|
||||
SkSafeUnref(fLight);
|
||||
}
|
||||
SkLightingImageFilter::~SkLightingImageFilter() {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLightingImageFilter::SkLightingImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fLight = SkLight::UnflattenLight(buffer);
|
||||
fLight.reset(SkLight::UnflattenLight(buffer));
|
||||
fSurfaceScale = buffer.readScalar();
|
||||
buffer.validate(SkScalarIsFinite(fSurfaceScale));
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
fLight->flattenLight(buffer);
|
||||
buffer.writeScalar(fSurfaceScale);
|
||||
buffer.writeScalar(fSurfaceScale * 255);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter* input, const CropRect* cropRect = NULL)
|
||||
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
|
||||
SkImageFilter* SkDiffuseLightingImageFilter::Create(SkLight* light, SkScalar surfaceScale,
|
||||
SkScalar kd, SkImageFilter* input, const CropRect* cropRect) {
|
||||
if (NULL == light) {
|
||||
return NULL;
|
||||
}
|
||||
if (!SkScalarIsFinite(surfaceScale) || !SkScalarIsFinite(kd)) {
|
||||
return NULL;
|
||||
}
|
||||
// According to the spec, kd can be any non-negative number :
|
||||
// http://www.w3.org/TR/SVG/filters.html#feDiffuseLightingElement
|
||||
fKD(kd < 0 ? 0 : kd)
|
||||
if (kd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkDiffuseLightingImageFilter, (light, surfaceScale, kd, input, cropRect));
|
||||
}
|
||||
|
||||
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar kd, SkImageFilter* input, const CropRect* cropRect = NULL)
|
||||
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
|
||||
fKD(kd)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer)
|
||||
{
|
||||
fKD = buffer.readScalar();
|
||||
buffer.validate(SkScalarIsFinite(fKD) && (fKD >= 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkAutoTUnref<SkLight> light(SkLight::UnflattenLight(buffer));
|
||||
SkScalar surfaceScale = buffer.readScalar();
|
||||
SkScalar kd = buffer.readScalar();
|
||||
return Create(light, surfaceScale, kd, common.getInput(0), &common.cropRect());
|
||||
}
|
||||
|
||||
void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
@ -1000,23 +1051,49 @@ bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* tex
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect)
|
||||
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
|
||||
SkImageFilter* SkSpecularLightingImageFilter::Create(SkLight* light, SkScalar surfaceScale,
|
||||
SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect) {
|
||||
if (NULL == light) {
|
||||
return NULL;
|
||||
}
|
||||
if (!SkScalarIsFinite(surfaceScale) || !SkScalarIsFinite(ks) || !SkScalarIsFinite(shininess)) {
|
||||
return NULL;
|
||||
}
|
||||
// According to the spec, ks can be any non-negative number :
|
||||
// http://www.w3.org/TR/SVG/filters.html#feSpecularLightingElement
|
||||
fKS(ks < 0 ? 0 : ks),
|
||||
if (ks < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkSpecularLightingImageFilter,
|
||||
(light, surfaceScale, ks, shininess, input, cropRect));
|
||||
}
|
||||
|
||||
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect)
|
||||
: SkLightingImageFilter(light, surfaceScale, input, cropRect),
|
||||
fKS(ks),
|
||||
fShininess(shininess)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer)
|
||||
: INHERITED(buffer)
|
||||
{
|
||||
fKS = buffer.readScalar();
|
||||
fShininess = buffer.readScalar();
|
||||
buffer.validate(SkScalarIsFinite(fKS) && (fKS >= 0) &&
|
||||
SkScalarIsFinite(fShininess));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkAutoTUnref<SkLight> light(SkLight::UnflattenLight(buffer));
|
||||
SkScalar surfaceScale = buffer.readScalar();
|
||||
SkScalar ks = buffer.readScalar();
|
||||
SkScalar shine = buffer.readScalar();
|
||||
return Create(light, surfaceScale, ks, shine, common.getInput(0), &common.cropRect());
|
||||
}
|
||||
|
||||
void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
@ -41,16 +41,17 @@ SkColorFilter* SkLumaColorFilter::Create() {
|
||||
return SkNEW(SkLumaColorFilter);
|
||||
}
|
||||
|
||||
SkLumaColorFilter::SkLumaColorFilter()
|
||||
: INHERITED() {
|
||||
SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkLumaColorFilter::SkLumaColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) {
|
||||
return SkNEW(SkLumaColorFilter);
|
||||
}
|
||||
|
||||
SkLumaColorFilter::SkLumaColorFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
}
|
||||
|
||||
void SkLumaColorFilter::flatten(SkWriteBuffer&) const {
|
||||
}
|
||||
void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkLumaColorFilter::toString(SkString* str) const {
|
||||
|
@ -232,6 +232,22 @@ void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* val
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar inset,
|
||||
SkImageFilter* input) {
|
||||
|
||||
if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) {
|
||||
return NULL;
|
||||
}
|
||||
// Negative numbers in src rect are not supported
|
||||
if (srcRect.fLeft < 0 || srcRect.fTop < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset, input));
|
||||
}
|
||||
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
float x = buffer.readScalar();
|
||||
@ -245,6 +261,7 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer)
|
||||
// Negative numbers in src rect are not supported
|
||||
(fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset,
|
||||
SkImageFilter* input)
|
||||
@ -271,12 +288,16 @@ bool SkMagnifierImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkMagnifierImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkRect src;
|
||||
buffer.readRect(&src);
|
||||
return Create(src, buffer.readScalar(), common.getInput(0));
|
||||
}
|
||||
|
||||
void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fSrcRect.x());
|
||||
buffer.writeScalar(fSrcRect.y());
|
||||
buffer.writeScalar(fSrcRect.width());
|
||||
buffer.writeScalar(fSrcRect.height());
|
||||
buffer.writeRect(fSrcRect);
|
||||
buffer.writeScalar(fInset);
|
||||
}
|
||||
|
||||
|
@ -17,18 +17,6 @@
|
||||
#include "effects/GrMatrixConvolutionEffect.h"
|
||||
#endif
|
||||
|
||||
static bool tile_mode_is_valid(SkMatrixConvolutionImageFilter::TileMode tileMode) {
|
||||
switch (tileMode) {
|
||||
case SkMatrixConvolutionImageFilter::kClamp_TileMode:
|
||||
case SkMatrixConvolutionImageFilter::kRepeat_TileMode:
|
||||
case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
|
||||
const SkISize& kernelSize,
|
||||
const SkScalar* kernel,
|
||||
@ -54,6 +42,19 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
|
||||
SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
static bool tile_mode_is_valid(SkMatrixConvolutionImageFilter::TileMode tileMode) {
|
||||
switch (tileMode) {
|
||||
case SkMatrixConvolutionImageFilter::kClamp_TileMode:
|
||||
case SkMatrixConvolutionImageFilter::kRepeat_TileMode:
|
||||
case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
// We need to be able to read at most SK_MaxS32 bytes, so divide that
|
||||
@ -86,6 +87,33 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buf
|
||||
(fKernelOffset.fX >= 0) && (fKernelOffset.fX < fKernelSize.fWidth) &&
|
||||
(fKernelOffset.fY >= 0) && (fKernelOffset.fY < fKernelSize.fHeight));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkISize kernelSize;
|
||||
kernelSize.fWidth = buffer.readInt();
|
||||
kernelSize.fHeight = buffer.readInt();
|
||||
const int count = buffer.getArrayCount();
|
||||
|
||||
const int64_t kernelArea = sk_64_mul(kernelSize.width(), kernelSize.height());
|
||||
if (!buffer.validate(kernelArea == count)) {
|
||||
return NULL;
|
||||
}
|
||||
SkAutoSTArray<16, SkScalar> kernel(count);
|
||||
if (!buffer.readScalarArray(kernel.get(), count)) {
|
||||
return NULL;
|
||||
}
|
||||
SkScalar gain = buffer.readScalar();
|
||||
SkScalar bias = buffer.readScalar();
|
||||
SkIPoint kernelOffset;
|
||||
kernelOffset.fX = buffer.readInt();
|
||||
kernelOffset.fY = buffer.readInt();
|
||||
TileMode tileMode = (TileMode)buffer.readInt();
|
||||
bool convolveAlpha = buffer.readBool();
|
||||
return Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode, convolveAlpha,
|
||||
common.getInput(0), &common.cropRect());
|
||||
}
|
||||
|
||||
void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
@ -29,11 +29,21 @@ SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
|
||||
return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
buffer.readMatrix(&fTransform);
|
||||
fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt());
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
|
||||
SkMatrix matrix;
|
||||
buffer.readMatrix(&matrix);
|
||||
SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readInt());
|
||||
return Create(matrix, level, common.getInput(0));
|
||||
}
|
||||
|
||||
void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
@ -105,15 +105,41 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
|
||||
return true;
|
||||
}
|
||||
|
||||
SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
Common common;
|
||||
if (!common.unflatten(buffer, -1)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int count = common.inputCount();
|
||||
bool hasModes = buffer.readBool();
|
||||
if (hasModes) {
|
||||
SkAutoSTArray<4, SkXfermode::Mode> modes(count);
|
||||
SkAutoSTArray<4, uint8_t> modes8(count);
|
||||
if (!buffer.readByteArray(modes8.get(), count)) {
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < count; ++i) {
|
||||
modes[i] = (SkXfermode::Mode)modes8[i];
|
||||
buffer.validate(SkIsValidMode(modes[i]));
|
||||
}
|
||||
if (!buffer.isValid()) {
|
||||
return NULL;
|
||||
}
|
||||
return Create(common.inputs(), count, modes.get(), &common.cropRect());
|
||||
}
|
||||
return Create(common.inputs(), count, NULL, &common.cropRect());
|
||||
}
|
||||
|
||||
void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
|
||||
buffer.writeBool(fModes != NULL);
|
||||
if (fModes) {
|
||||
buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0]));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMergeImageFilter::SkMergeImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(-1, buffer) {
|
||||
bool hasModes = buffer.readBool();
|
||||
@ -132,3 +158,4 @@ SkMergeImageFilter::SkMergeImageFilter(SkReadBuffer& buffer)
|
||||
fModes = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "effects/Gr1DKernelEffect.h"
|
||||
#endif
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
fRadius.fWidth = buffer.readInt();
|
||||
@ -28,6 +29,7 @@ SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer)
|
||||
buffer.validate((fRadius.fWidth >= 0) &&
|
||||
(fRadius.fHeight >= 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
|
||||
int radiusY,
|
||||
@ -36,7 +38,6 @@ SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
|
||||
: INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) {
|
||||
}
|
||||
|
||||
|
||||
void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeInt(fRadius.fWidth);
|
||||
@ -258,6 +259,20 @@ bool SkMorphologyImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
|
||||
return true;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -91,6 +91,13 @@ bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
|
||||
return true;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writePoint(fOffset);
|
||||
@ -102,9 +109,11 @@ SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
|
||||
fOffset.set(dx, dy);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(1, buffer) {
|
||||
buffer.readPoint(&fOffset);
|
||||
buffer.validate(SkScalarIsFinite(fOffset.fX) &&
|
||||
SkScalarIsFinite(fOffset.fY));
|
||||
}
|
||||
#endif
|
||||
|
@ -287,9 +287,8 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type,
|
||||
SkASSERT(numOctaves >= 0 && numOctaves < 256);
|
||||
}
|
||||
|
||||
SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer)
|
||||
{
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer) : INHERITED(buffer) {
|
||||
fType = (SkPerlinNoiseShader::Type) buffer.readInt();
|
||||
fBaseFrequencyX = buffer.readScalar();
|
||||
fBaseFrequencyY = buffer.readScalar();
|
||||
@ -302,18 +301,37 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer)
|
||||
(fNumOctaves >= 0) && (fNumOctaves <= 255) &&
|
||||
(fStitchTiles != fTileSize.isEmpty()));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkPerlinNoiseShader::~SkPerlinNoiseShader() {
|
||||
}
|
||||
|
||||
SkFlattenable* SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) {
|
||||
Type type = (Type)buffer.readInt();
|
||||
SkScalar freqX = buffer.readScalar();
|
||||
SkScalar freqY = buffer.readScalar();
|
||||
int octaves = buffer.readInt();
|
||||
SkScalar seed = buffer.readScalar();
|
||||
SkISize tileSize;
|
||||
tileSize.fWidth = buffer.readInt();
|
||||
tileSize.fHeight = buffer.readInt();
|
||||
|
||||
switch (type) {
|
||||
case kFractalNoise_Type:
|
||||
return SkPerlinNoiseShader::CreateFractalNoise(freqX, freqY, octaves, seed, &tileSize);
|
||||
case kTurbulence_Type:
|
||||
return SkPerlinNoiseShader::CreateTubulence(freqX, freqY, octaves, seed, &tileSize);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SkPerlinNoiseShader::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeInt((int) fType);
|
||||
buffer.writeScalar(fBaseFrequencyX);
|
||||
buffer.writeScalar(fBaseFrequencyY);
|
||||
buffer.writeInt(fNumOctaves);
|
||||
buffer.writeScalar(fSeed);
|
||||
buffer.writeBool(fStitchTiles);
|
||||
buffer.writeInt(fTileSize.fWidth);
|
||||
buffer.writeInt(fTileSize.fHeight);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ SkPictureImageFilter::~SkPictureImageFilter() {
|
||||
SkSafeUnref(fPicture);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer)
|
||||
: INHERITED(0, buffer),
|
||||
fPicture(NULL) {
|
||||
@ -43,9 +44,25 @@ SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer)
|
||||
}
|
||||
buffer.readRect(&fCropRect);
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SkAutoTUnref<SkPicture> picture;
|
||||
SkRect cropRect;
|
||||
|
||||
if (!buffer.isCrossProcess()) {
|
||||
if (buffer.readBool()) {
|
||||
picture.reset(SkPicture::CreateFromBuffer(buffer));
|
||||
}
|
||||
} else {
|
||||
buffer.validate(!buffer.readBool());
|
||||
}
|
||||
buffer.readRect(&cropRect);
|
||||
|
||||
return Create(picture, cropRect);
|
||||
}
|
||||
|
||||
void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
this->INHERITED::flatten(buffer);
|
||||
if (!buffer.isCrossProcess()) {
|
||||
bool hasPicture = (fPicture != NULL);
|
||||
buffer.writeBool(hasPicture);
|
||||
|
@ -22,14 +22,18 @@ SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
|
||||
}
|
||||
|
||||
void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const {
|
||||
this->INHERITED::flatten(wb);
|
||||
wb.writeColor(fOpColor);
|
||||
}
|
||||
|
||||
SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb)
|
||||
: INHERITED(rb) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
||||
SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb) : INHERITED(rb) {
|
||||
fOpColor = rb.readColor();
|
||||
}
|
||||
#endif
|
||||
|
||||
SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) {
|
||||
return Create(buffer.readColor());
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkPixelXorXfermode::toString(SkString* str) const {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user