From d6caf2eefd0dc05d0855bf8419bb8d4aca903f6c Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Fri, 8 Jul 2011 14:41:12 +0000 Subject: [PATCH] Replace reference parameter with pointer so that we can pass NULL in SkDrawPaint::add(); check the pointer when it's used to avoid dereferencing NULL. Add title to Animator sample slide. git-svn-id: http://skia.googlecode.com/svn/trunk@1825 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SampleAnimator.cpp | 9 +++++++++ src/animator/SkDrawPaint.cpp | 6 +++--- src/animator/SkDrawPaint.h | 2 +- src/animator/SkPaintParts.cpp | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/samplecode/SampleAnimator.cpp b/samplecode/SampleAnimator.cpp index 99173fc8ab..b4e487a73c 100644 --- a/samplecode/SampleAnimator.cpp +++ b/samplecode/SampleAnimator.cpp @@ -24,6 +24,7 @@ public: protected: // overrides virtual void onDraw(SkCanvas*); + virtual bool onQuery(SkEvent* evt); private: SkString fBaseURI; @@ -140,6 +141,14 @@ void SkAnimatorView::onDraw(SkCanvas* canvas) { } } +bool SkAnimatorView::onQuery(SkEvent* evt) { + if (SampleCode::TitleQ(*evt)) { + SampleCode::TitleR(evt, "Animator"); + return true; + } + return this->INHERITED::onQuery(evt); +} + ////////////////////////////////////////////////////////////////////////////// static SkView* MyFactory() { diff --git a/src/animator/SkDrawPaint.cpp b/src/animator/SkDrawPaint.cpp index f21a15a10e..cd2c915e23 100644 --- a/src/animator/SkDrawPaint.cpp +++ b/src/animator/SkDrawPaint.cpp @@ -98,11 +98,11 @@ SkDrawPaint::~SkDrawPaint() { delete typeface; } -bool SkDrawPaint::add(SkAnimateMaker& maker, SkDisplayable* child) { +bool SkDrawPaint::add(SkAnimateMaker* maker, SkDisplayable* child) { SkASSERT(child && child->isPaintPart()); SkPaintPart* part = (SkPaintPart*) child; - if (part->add()) - maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); + if (part->add() && maker) + maker->setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); return true; } diff --git a/src/animator/SkDrawPaint.h b/src/animator/SkDrawPaint.h index ea77acd933..b68fb6b4bb 100644 --- a/src/animator/SkDrawPaint.h +++ b/src/animator/SkDrawPaint.h @@ -34,7 +34,7 @@ class SkDrawPaint : public SkDrawable { DECLARE_DRAW_MEMBER_INFO(Paint); SkDrawPaint(); virtual ~SkDrawPaint(); - virtual bool add(SkAnimateMaker& , SkDisplayable* child); + virtual bool add(SkAnimateMaker* , SkDisplayable* child); virtual SkDisplayable* deepCopy(SkAnimateMaker* ); virtual bool draw(SkAnimateMaker& ); #ifdef SK_DUMP_ENABLED diff --git a/src/animator/SkPaintParts.cpp b/src/animator/SkPaintParts.cpp index 48799c68a4..38d3ae017b 100644 --- a/src/animator/SkPaintParts.cpp +++ b/src/animator/SkPaintParts.cpp @@ -61,7 +61,7 @@ bool SkDrawPathEffect::add() { fPaint->fOwnsPathEffect = true; return false; } - fPaint->add(*(SkAnimateMaker*) NULL, this); + fPaint->add(NULL, this); return false; } -- 2.34.1