SkPictureFlat.cpp revision 07764cefbb18041a77897df3453903b0a2016583
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#include "SkPictureFlat.h" 8 9#include "SkChecksum.h" 10#include "SkColorFilter.h" 11#include "SkDrawLooper.h" 12#include "SkMaskFilter.h" 13#include "SkRasterizer.h" 14#include "SkShader.h" 15#include "SkTypeface.h" 16 17/////////////////////////////////////////////////////////////////////////////// 18 19SkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(nullptr) {} 20 21SkTypefacePlayback::~SkTypefacePlayback() { 22 this->reset(nullptr); 23} 24 25void SkTypefacePlayback::reset(const SkRefCntSet* rec) { 26 for (int i = 0; i < fCount; i++) { 27 SkASSERT(fArray[i]); 28 fArray[i]->unref(); 29 } 30 delete[] fArray; 31 32 if (rec!= nullptr && rec->count() > 0) { 33 fCount = rec->count(); 34 fArray = new SkRefCnt* [fCount]; 35 rec->copyToArray(fArray); 36 for (int i = 0; i < fCount; i++) { 37 fArray[i]->ref(); 38 } 39 } else { 40 fCount = 0; 41 fArray = nullptr; 42 } 43} 44 45void SkTypefacePlayback::setCount(int count) { 46 this->reset(nullptr); 47 48 fCount = count; 49 fArray = new SkRefCnt* [count]; 50 sk_bzero(fArray, count * sizeof(SkRefCnt*)); 51} 52 53SkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) { 54 SkASSERT((unsigned)index < (unsigned)fCount); 55 SkRefCnt_SafeAssign(fArray[index], obj); 56 return obj; 57} 58