diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-21 19:24:00 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-21 19:24:00 +0000 |
commit | 6bac947cd5bc460dd9166ada6310d678fd2e39f8 (patch) | |
tree | 4f0adb7306dc1738f7e935ad84aac16ea1cc5d4d /src/core/SkPathEffect.cpp | |
parent | 25fb21f5df904c6f111bbf8f07e6a6c339416d09 (diff) |
Add option in flattening to write factory names inline, as we are recording.
SkGPipe needs this, since it cannot (unlike SkPicture) see all of the factories
before it hands its data to the reader.
In this mode, the writer embedds the factory name the first time it sees it,
and then after that writes an index (referencing the fFactorySet). The reader
installs an empty array, and as it encounters names, appends them to that array
so that subsequent indices can be used to retrieve the previously named factory.
Some of the existing patheffects did not register their factory names, so those
changes are also part of this CL. Annoyingly, to register your factory using the
current scheme, it has to be in the public section of the class definition.
git-svn-id: http://skia.googlecode.com/svn/trunk@1663 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPathEffect.cpp')
-rw-r--r-- | src/core/SkPathEffect.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index c3a24fc049..b8880bb4c3 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -30,8 +30,8 @@ SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) } SkPairPathEffect::~SkPairPathEffect() { - fPE0->unref(); - fPE1->unref(); + SkSafeUnref(fPE0); + SkSafeUnref(fPE1); } /* @@ -45,12 +45,18 @@ void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) { SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { fPE0 = (SkPathEffect*)buffer.readFlattenable(); fPE1 = (SkPathEffect*)buffer.readFlattenable(); + // either of these may fail, so we have to check for nulls later on } /////////////////////////////////////////////////////////////////////////////// bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) { + // we may have failed to unflatten these, so we have to check + if (!fPE0 || !fPE1) { + return false; + } + SkPath tmp; const SkPath* ptr = &src; @@ -134,3 +140,14 @@ SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) { fCap = buffer.readU8(); } +/////////////////////////////////////////////////////////////////////////////// + +static SkFlattenable::Registrar gComposePathEffectReg("SkComposePathEffect", + SkComposePathEffect::CreateProc); + +static SkFlattenable::Registrar gSumPathEffectReg("SkSumPathEffect", + SkSumPathEffect::CreateProc); + +static SkFlattenable::Registrar gStrokePathEffectReg("SkStrokePathEffect", + SkStrokePathEffect::CreateProc); + |