skia2/experimental/pipe/SkRefSet.h
Mike Klein 60900b55f9 move skpipe to experimental
Nothing's using it except test tools.
I'd like to make that a bit clearer by getting it out of src.

Disabled the fuzzer.

Removed the bench so Android's building nanobench doesn't block this.

Bug: chromium:886713

Change-Id: I761f52c40171c27ff4b699409b32647e84684ec3
Reviewed-on: https://skia-review.googlesource.com/156240
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2018-09-21 17:20:25 +00:00

39 lines
881 B
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkRefSet_DEFINED
#define SkRefSet_DEFINED
#include "SkRefCnt.h"
#include "SkTArray.h"
template <typename T> class SkRefSet {
public:
T* get(int index) const {
SkASSERT((unsigned)index < (unsigned)fArray.count());
return fArray[index].get();
}
bool set(int index, sk_sp<T> value) {
if (index < fArray.count()) {
fArray[index] = std::move(value);
return true;
}
if (fArray.count() == index && value) {
fArray.emplace_back(std::move(value));
return true;
}
SkDebugf("SkRefSet: index [%d] out of range %d\n", index, fArray.count());
return false;
}
private:
SkTArray<sk_sp<T>> fArray;
};
#endif