Line data Source code
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 :
19 0 : SkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(nullptr) {}
20 :
21 0 : SkTypefacePlayback::~SkTypefacePlayback() {
22 0 : this->reset(nullptr);
23 0 : }
24 :
25 0 : void SkTypefacePlayback::reset(const SkRefCntSet* rec) {
26 0 : for (int i = 0; i < fCount; i++) {
27 0 : SkASSERT(fArray[i]);
28 0 : fArray[i]->unref();
29 : }
30 0 : delete[] fArray;
31 :
32 0 : if (rec!= nullptr && rec->count() > 0) {
33 0 : fCount = rec->count();
34 0 : fArray = new SkRefCnt* [fCount];
35 0 : rec->copyToArray(fArray);
36 0 : for (int i = 0; i < fCount; i++) {
37 0 : fArray[i]->ref();
38 : }
39 : } else {
40 0 : fCount = 0;
41 0 : fArray = nullptr;
42 : }
43 0 : }
44 :
45 0 : void SkTypefacePlayback::setCount(int count) {
46 0 : this->reset(nullptr);
47 :
48 0 : fCount = count;
49 0 : fArray = new SkRefCnt* [count];
50 0 : sk_bzero(fArray, count * sizeof(SkRefCnt*));
51 0 : }
52 :
53 0 : SkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) {
54 0 : SkASSERT((unsigned)index < (unsigned)fCount);
55 0 : SkRefCnt_SafeAssign(fArray[index], obj);
56 0 : return obj;
57 : }
|