From 3eab80cc1f2031b582b37aed6176e1f8df67b72f Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Tue, 24 Mar 2009 18:47:35 +0000 Subject: rename drawable to drawing for now, so we don't collide with animator remove sk_throw in pixelref. a debug statement is enough. git-svn-id: http://skia.googlecode.com/svn/trunk@136 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkDrawable.cpp | 152 ------------------------------------------------ src/core/SkDrawing.cpp | 152 ++++++++++++++++++++++++++++++++++++++++++++++++ src/core/SkPixelRef.cpp | 3 +- 3 files changed, 154 insertions(+), 153 deletions(-) delete mode 100644 src/core/SkDrawable.cpp create mode 100644 src/core/SkDrawing.cpp (limited to 'src') diff --git a/src/core/SkDrawable.cpp b/src/core/SkDrawable.cpp deleted file mode 100644 index 85f3175bdb..0000000000 --- a/src/core/SkDrawable.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "SkDrawable.h" -#include "SkCanvas.h" - -SkDrawable::SkDrawable() { - fMatrix.reset(); - fParent = fFirstChild = fNextSibling = fPrevSibling = NULL; -} - -SkDrawable::~SkDrawable() { - this->detachAllChildren(); -} - -/////////////////////////////////////////////////////////////////////////////// - -void SkDrawable::resetMatrix() { - fMatrix.reset(); -} - -void SkDrawable::getMatrix(SkMatrix* matrix) const { - if (matrix) { - *matrix = fMatrix; - } -} - -void SkDrawable::setMatrix(const SkMatrix& matrix) { - if (fMatrix != matrix) { - this->inval(); - fMatrix = matrix; - this->inval(); - } -} - -void SkDrawable::draw(SkCanvas* canvas) { - SkAutoCanvasRestore ar(canvas, false); - canvas->save(SkCanvas::kMatrix_SaveFlag); - canvas->concat(fMatrix); - - this->onDraw(canvas); - - B2FIter iter(this); - SkDrawable* child; - while ((child = iter.next()) != NULL) { - child->draw(canvas); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -void SkDrawable::detachFromParent() { - SkDrawable* parent = fParent; - - if (NULL == parent) { - return; - } - - this->inval(); - - SkDrawable* next = NULL; - - if (fNextSibling != this) { // do we have any siblings - fNextSibling->fPrevSibling = fPrevSibling; - fPrevSibling->fNextSibling = fNextSibling; - next = fNextSibling; - } - - if (fParent->fFirstChild == this) { - fParent->fFirstChild = next; - } - - fParent = fNextSibling = fPrevSibling = NULL; - this->unref(); -} - -SkDrawable* SkDrawable::attachChildToBack(SkDrawable* child) { - SkASSERT(child != this); - - if (child == NULL || fFirstChild == child) { - return child; - } - - child->ref(); - child->detachFromParent(); - - if (fFirstChild == NULL) { - child->fNextSibling = child; - child->fPrevSibling = child; - } else { - child->fNextSibling = fFirstChild; - child->fPrevSibling = fFirstChild->fPrevSibling; - fFirstChild->fPrevSibling->fNextSibling = child; - fFirstChild->fPrevSibling = child; - } - - fFirstChild = child; - child->fParent = this; - child->inval(); - return child; -} - -SkDrawable* SkDrawable::attachChildToFront(SkDrawable* child) { - SkASSERT(child != this); - - if (child == NULL || fFirstChild && fFirstChild->fPrevSibling == child) { - return child; - } - - child->ref(); - child->detachFromParent(); - - if (fFirstChild == NULL) { - fFirstChild = child; - child->fNextSibling = child; - child->fPrevSibling = child; - } else { - child->fNextSibling = fFirstChild; - child->fPrevSibling = fFirstChild->fPrevSibling; - fFirstChild->fPrevSibling->fNextSibling = child; - fFirstChild->fPrevSibling = child; - } - - child->fParent = this; - child->inval(); - return child; -} - -void SkDrawable::detachAllChildren() { - while (fFirstChild) { - fFirstChild->detachFromParent(); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -SkDrawable::B2FIter::B2FIter(const SkDrawable* parent) { - fFirstChild = parent ? parent->fFirstChild : NULL; - fChild = fFirstChild; -} - -SkDrawable* SkDrawable::B2FIter::next() { - SkDrawable* curr = fChild; - - if (fChild) { - SkDrawable* next = fChild->fNextSibling; - if (next == fFirstChild) { - next = NULL; - } - fChild = next; - } - return curr; -} - - diff --git a/src/core/SkDrawing.cpp b/src/core/SkDrawing.cpp new file mode 100644 index 0000000000..85f3175bdb --- /dev/null +++ b/src/core/SkDrawing.cpp @@ -0,0 +1,152 @@ +#include "SkDrawable.h" +#include "SkCanvas.h" + +SkDrawable::SkDrawable() { + fMatrix.reset(); + fParent = fFirstChild = fNextSibling = fPrevSibling = NULL; +} + +SkDrawable::~SkDrawable() { + this->detachAllChildren(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void SkDrawable::resetMatrix() { + fMatrix.reset(); +} + +void SkDrawable::getMatrix(SkMatrix* matrix) const { + if (matrix) { + *matrix = fMatrix; + } +} + +void SkDrawable::setMatrix(const SkMatrix& matrix) { + if (fMatrix != matrix) { + this->inval(); + fMatrix = matrix; + this->inval(); + } +} + +void SkDrawable::draw(SkCanvas* canvas) { + SkAutoCanvasRestore ar(canvas, false); + canvas->save(SkCanvas::kMatrix_SaveFlag); + canvas->concat(fMatrix); + + this->onDraw(canvas); + + B2FIter iter(this); + SkDrawable* child; + while ((child = iter.next()) != NULL) { + child->draw(canvas); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void SkDrawable::detachFromParent() { + SkDrawable* parent = fParent; + + if (NULL == parent) { + return; + } + + this->inval(); + + SkDrawable* next = NULL; + + if (fNextSibling != this) { // do we have any siblings + fNextSibling->fPrevSibling = fPrevSibling; + fPrevSibling->fNextSibling = fNextSibling; + next = fNextSibling; + } + + if (fParent->fFirstChild == this) { + fParent->fFirstChild = next; + } + + fParent = fNextSibling = fPrevSibling = NULL; + this->unref(); +} + +SkDrawable* SkDrawable::attachChildToBack(SkDrawable* child) { + SkASSERT(child != this); + + if (child == NULL || fFirstChild == child) { + return child; + } + + child->ref(); + child->detachFromParent(); + + if (fFirstChild == NULL) { + child->fNextSibling = child; + child->fPrevSibling = child; + } else { + child->fNextSibling = fFirstChild; + child->fPrevSibling = fFirstChild->fPrevSibling; + fFirstChild->fPrevSibling->fNextSibling = child; + fFirstChild->fPrevSibling = child; + } + + fFirstChild = child; + child->fParent = this; + child->inval(); + return child; +} + +SkDrawable* SkDrawable::attachChildToFront(SkDrawable* child) { + SkASSERT(child != this); + + if (child == NULL || fFirstChild && fFirstChild->fPrevSibling == child) { + return child; + } + + child->ref(); + child->detachFromParent(); + + if (fFirstChild == NULL) { + fFirstChild = child; + child->fNextSibling = child; + child->fPrevSibling = child; + } else { + child->fNextSibling = fFirstChild; + child->fPrevSibling = fFirstChild->fPrevSibling; + fFirstChild->fPrevSibling->fNextSibling = child; + fFirstChild->fPrevSibling = child; + } + + child->fParent = this; + child->inval(); + return child; +} + +void SkDrawable::detachAllChildren() { + while (fFirstChild) { + fFirstChild->detachFromParent(); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +SkDrawable::B2FIter::B2FIter(const SkDrawable* parent) { + fFirstChild = parent ? parent->fFirstChild : NULL; + fChild = fFirstChild; +} + +SkDrawable* SkDrawable::B2FIter::next() { + SkDrawable* curr = fChild; + + if (fChild) { + SkDrawable* next = fChild->fNextSibling; + if (next == fFirstChild) { + next = NULL; + } + fChild = next; + } + return curr; +} + + diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index adfc3c02e9..e096d634b1 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -66,10 +66,11 @@ uint32_t SkPixelRef::getGenerationID() const { } void SkPixelRef::notifyPixelsChanged() { +#ifdef SK_DEBUG if (fIsImmutable) { SkDebugf("========== notifyPixelsChanged called on immutable pixelref"); - sk_throw(); } +#endif // this signals us to recompute this next time around fGenerationID = 0; } -- cgit v1.2.3