Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: include/private/SkRefSet.h

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawVertices and drawTextOnPath Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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 #ifndef SkRefSet_DEFINED
9 #define SkRefSet_DEFINED
10
11 #include "SkRefCnt.h"
12 #include "SkTDArray.h"
13
14 template <typename T> class SkRefSet {
15 public:
16 ~SkRefSet() { fArray.unrefAll(); }
17
18 T* get(int index) const {
19 return (unsigned)index < (unsigned)fArray.count() ? fArray[index] : null ptr;
20 }
21
22 bool set(int index, T* value) {
23 if ((unsigned)index < (unsigned)fArray.count()) {
24 SkRefCnt_SafeAssign(fArray[index], value);
25 return true;
26 }
27 if (fArray.count() == index && value) {
28 *fArray.append() = SkRef(value);
29 return true;
30 }
31 SkDebugf("SkRefSet: index [%d] out of range %d\n", index, fArray.count() );
32 return false;
33 }
34
35 private:
36 SkTDArray<T*> fArray;
37 };
38
39 #endif
OLDNEW
« no previous file with comments | « include/core/SkWriteBuffer.h ('k') | samplecode/SampleApp.h » ('j') | src/core/SkReadBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698