diff options
Diffstat (limited to 'src/effects/SkGroupShape.cpp')
-rw-r--r-- | src/effects/SkGroupShape.cpp | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/src/effects/SkGroupShape.cpp b/src/effects/SkGroupShape.cpp deleted file mode 100644 index 224d2a2eca..0000000000 --- a/src/effects/SkGroupShape.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -/* - * 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 "SkGroupShape.h" -#include "SkFlattenableBuffers.h" - -SkGroupShape::SkGroupShape() {} - -SkGroupShape::~SkGroupShape() { - this->removeAllShapes(); -} - -int SkGroupShape::countShapes() const { - return fList.count(); -} - -SkShape* SkGroupShape::getShape(int index, SkMatrixRef** mr) const { - if ((unsigned)index < (unsigned)fList.count()) { - const Rec& rec = fList[index]; - if (mr) { - *mr = rec.fMatrixRef; - } - return rec.fShape; - } - return NULL; -} - -void SkGroupShape::addShape(int index, SkShape* shape, SkMatrixRef* mr) { - int count = fList.count(); - if (NULL == shape || index < 0 || index > count) { - return; - } - - shape->ref(); - SkMatrixRef::SafeRef(mr); - - Rec* rec; - if (index == count) { - rec = fList.append(); - } else { - rec = fList.insert(index); - } - rec->fShape = shape; - rec->fMatrixRef = mr; -} - -void SkGroupShape::removeShape(int index) { - if ((unsigned)index < (unsigned)fList.count()) { - Rec& rec = fList[index]; - rec.fShape->unref(); - SkMatrixRef::SafeUnref(rec.fMatrixRef); - fList.remove(index); - } -} - -void SkGroupShape::removeAllShapes() { - Rec* rec = fList.begin(); - Rec* stop = fList.end(); - while (rec < stop) { - rec->fShape->unref(); - SkMatrixRef::SafeUnref(rec->fMatrixRef); - rec++; - } - fList.reset(); -} - -/////////////////////////////////////////////////////////////////////////////// - -void SkGroupShape::onDraw(SkCanvas* canvas) { - const Rec* rec = fList.begin(); - const Rec* stop = fList.end(); - while (rec < stop) { - SkShape* shape = rec->fShape; - if (rec->fMatrixRef) { - shape->drawMatrix(canvas, *rec->fMatrixRef); - } else { - shape->draw(canvas); - } - rec++; - } -} - -void SkGroupShape::flatten(SkFlattenableWriteBuffer& buffer) const { - this->INHERITED::flatten(buffer); - - buffer.writeInt(fList.count()); - const Rec* rec = fList.begin(); - const Rec* stop = fList.end(); - while (rec < stop) { - buffer.writeFlattenable(rec->fShape); - buffer.writeBool(NULL != rec->fMatrixRef); - if (rec->fMatrixRef) { - buffer.writeMatrix(*rec->fMatrixRef); - } - rec += 1; - } -} - -SkGroupShape::SkGroupShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer){ - int count = buffer.readInt(); - for (int i = 0; i < count; i++) { - SkShape* shape = buffer.readFlattenableT<SkShape>(); - SkMatrixRef* mr = NULL; - bool hasMatrix = buffer.readBool(); - if (hasMatrix) { - mr = SkNEW(SkMatrixRef); - buffer.readMatrix(mr); - } - if (shape) { - this->appendShape(shape, mr)->unref(); - } - SkSafeUnref(mr); - } -} - -SK_DEFINE_FLATTENABLE_REGISTRAR(SkGroupShape) - |