1 /* 2 * Copyright 2011 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "SkPictureFlat.h" 9 #include "SkChecksum.h" 10 #include "SkColorFilter.h" 11 #include "SkDrawLooper.h" 12 #include "SkMaskFilter.h" 13 #include "SkShader.h" 14 #include "SkTypeface.h" 15 16 /////////////////////////////////////////////////////////////////////////////// 17 SkTypefacePlayback()18SkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(nullptr) {} 19 ~SkTypefacePlayback()20SkTypefacePlayback::~SkTypefacePlayback() { 21 this->reset(nullptr); 22 } 23 reset(const SkRefCntSet * rec)24void SkTypefacePlayback::reset(const SkRefCntSet* rec) { 25 for (int i = 0; i < fCount; i++) { 26 SkASSERT(fArray[i]); 27 fArray[i]->unref(); 28 } 29 delete[] fArray; 30 31 if (rec!= nullptr && rec->count() > 0) { 32 fCount = rec->count(); 33 fArray = new SkRefCnt* [fCount]; 34 rec->copyToArray(fArray); 35 for (int i = 0; i < fCount; i++) { 36 fArray[i]->ref(); 37 } 38 } else { 39 fCount = 0; 40 fArray = nullptr; 41 } 42 } 43 setCount(int count)44void SkTypefacePlayback::setCount(int count) { 45 this->reset(nullptr); 46 47 fCount = count; 48 fArray = new SkRefCnt* [count]; 49 sk_bzero(fArray, count * sizeof(SkRefCnt*)); 50 } 51 set(int index,SkRefCnt * obj)52SkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) { 53 SkASSERT((unsigned)index < (unsigned)fCount); 54 SkRefCnt_SafeAssign(fArray[index], obj); 55 return obj; 56 } 57