michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #include "SkPictureFlat.h" michael@0: michael@0: #include "SkChecksum.h" michael@0: #include "SkColorFilter.h" michael@0: #include "SkDrawLooper.h" michael@0: #include "SkMaskFilter.h" michael@0: #include "SkRasterizer.h" michael@0: #include "SkShader.h" michael@0: #include "SkTypeface.h" michael@0: #include "SkXfermode.h" michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: SkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(NULL) {} michael@0: michael@0: SkTypefacePlayback::~SkTypefacePlayback() { michael@0: this->reset(NULL); michael@0: } michael@0: michael@0: void SkTypefacePlayback::reset(const SkRefCntSet* rec) { michael@0: for (int i = 0; i < fCount; i++) { michael@0: SkASSERT(fArray[i]); michael@0: fArray[i]->unref(); michael@0: } michael@0: SkDELETE_ARRAY(fArray); michael@0: michael@0: if (rec!= NULL && rec->count() > 0) { michael@0: fCount = rec->count(); michael@0: fArray = SkNEW_ARRAY(SkRefCnt*, fCount); michael@0: rec->copyToArray(fArray); michael@0: for (int i = 0; i < fCount; i++) { michael@0: fArray[i]->ref(); michael@0: } michael@0: } else { michael@0: fCount = 0; michael@0: fArray = NULL; michael@0: } michael@0: } michael@0: michael@0: void SkTypefacePlayback::setCount(int count) { michael@0: this->reset(NULL); michael@0: michael@0: fCount = count; michael@0: fArray = SkNEW_ARRAY(SkRefCnt*, count); michael@0: sk_bzero(fArray, count * sizeof(SkRefCnt*)); michael@0: } michael@0: michael@0: SkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) { michael@0: SkASSERT((unsigned)index < (unsigned)fCount); michael@0: SkRefCnt_SafeAssign(fArray[index], obj); michael@0: return obj; michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: SkFlatController::SkFlatController(uint32_t writeBufferFlags) michael@0: : fBitmapHeap(NULL) michael@0: , fTypefaceSet(NULL) michael@0: , fTypefacePlayback(NULL) michael@0: , fFactorySet(NULL) michael@0: , fWriteBufferFlags(writeBufferFlags) {} michael@0: michael@0: SkFlatController::~SkFlatController() { michael@0: SkSafeUnref(fBitmapHeap); michael@0: SkSafeUnref(fTypefaceSet); michael@0: SkSafeUnref(fFactorySet); michael@0: } michael@0: michael@0: void SkFlatController::setBitmapHeap(SkBitmapHeap* heap) { michael@0: SkRefCnt_SafeAssign(fBitmapHeap, heap); michael@0: } michael@0: michael@0: void SkFlatController::setTypefaceSet(SkRefCntSet *set) { michael@0: SkRefCnt_SafeAssign(fTypefaceSet, set); michael@0: } michael@0: michael@0: void SkFlatController::setTypefacePlayback(SkTypefacePlayback* playback) { michael@0: fTypefacePlayback = playback; michael@0: } michael@0: michael@0: SkNamedFactorySet* SkFlatController::setNamedFactorySet(SkNamedFactorySet* set) { michael@0: SkRefCnt_SafeAssign(fFactorySet, set); michael@0: return set; michael@0: }