These types are ref-counted, but don't otherwise need a vtable.
This makes them good candidates for SkNVRefCnt.
Destruction can be a little more direct, and if nothing else,
sizeof(T) will get a little smaller by dropping the vptr.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=
2232433002
Review-Url: https://codereview.chromium.org/
2232433002
* but the actual ptr that is returned (by data() or bytes()) is guaranteed
* to always be the same for the life of this instance.
*/
-class SK_API SkData : public SkRefCnt {
+class SK_API SkData final : public SkNVRefCnt<SkData> {
public:
/**
* Returns the number of bytes stored.
*/
static sk_sp<SkData> MakeWithCopy(const void* data, size_t length);
-
+
/**
* Create a new data with uninitialized contents. The caller should call writable_data()
* to write into the buffer, but this must be done before another ref() is made.
static sk_sp<SkData> MakeEmpty();
private:
+ friend class SkNVRefCnt<SkData>;
ReleaseProc fReleaseProc;
void* fReleaseProcContext;
void* fPtr;
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
explicit SkData(size_t size); // inplace new/delete
- virtual ~SkData();
+ ~SkData();
// Objects of this type are sometimes created in a custom fashion using sk_malloc_throw and
* logical verb or the last verb in memory).
*/
-class SK_API SkPathRef : public ::SkRefCnt {
+class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> {
public:
class Editor {
public:
*/
static void Rewind(SkAutoTUnref<SkPathRef>* pathRef);
- virtual ~SkPathRef();
+ ~SkPathRef();
int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; }
int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; }
int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeights.count(); }
friend class PathRefTest_Private;
friend class ForceIsRRect_Private; // unit test isRRect
- typedef SkRefCnt INHERITED;
};
#endif
SkTextBlob combines multiple text runs into an immutable, ref-counted structure.
*/
-class SK_API SkTextBlob : public SkRefCnt {
+class SK_API SkTextBlob final : public SkNVRefCnt<SkTextBlob> {
public:
/**
* Returns a conservative blob bounding box.
};
private:
+ friend class SkNVRefCnt<SkTextBlob>;
class RunRecord;
SkTextBlob(int runCount, const SkRect& bounds);
- virtual ~SkTextBlob();
+ ~SkTextBlob();
// Memory for objects of this class is created with sk_malloc rather than operator new and must
// be freed with sk_free.
#ifdef SK_DEBUG
void SkPathRef::validate() const {
- this->INHERITED::validate();
SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0);
SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints) >= 0);
SkASSERT((nullptr == fPoints) == (nullptr == fVerbs));