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

Side by Side Diff: src/pipe/SkRefSet.h

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test for writeImage Created 4 years, 3 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 SkASSERT((unsigned)index < (unsigned)fArray.count());
20 return fArray[index];
21 }
22
23 bool set(int index, T* value) {
24 if ((unsigned)index < (unsigned)fArray.count()) {
25 SkRefCnt_SafeAssign(fArray[index], value);
26 return true;
27 }
28 if (fArray.count() == index && value) {
29 *fArray.append() = SkRef(value);
30 return true;
31 }
32 SkDebugf("SkRefSet: index [%d] out of range %d\n", index, fArray.count() );
33 return false;
34 }
35
36 private:
37 SkTDArray<T*> fArray;
38 };
39
40 #endif
OLDNEW
« src/core/SkPipe.h ('K') | « src/pipe/SkPipeReader.cpp ('k') | tests/PipeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698