aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkData.h
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-10 17:30:58 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-10 17:30:58 +0000
commit59f46b81f8bdd1b524f5cc43bc27603f9604c71a (patch)
treec074f4d76c87c4ab67e32405327a0c10201ed7e8 /include/core/SkData.h
parent676e66096c60615bac52f365111596de5c4ca8a6 (diff)
Fixed Windows compiler complaints
Diffstat (limited to 'include/core/SkData.h')
-rw-r--r--include/core/SkData.h31
1 files changed, 12 insertions, 19 deletions
diff --git a/include/core/SkData.h b/include/core/SkData.h
index 61b52c5480..301a4d88eb 100644
--- a/include/core/SkData.h
+++ b/include/core/SkData.h
@@ -108,7 +108,14 @@ private:
size_t fSize;
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
- ~SkData();
+ virtual ~SkData();
+
+ // This is here because SkAutoTUnref creates an internal helper class
+ // that derives from SkData (i.e., BlockRef) to prevent refs\unrefs.
+ // This helper class generates a compiler warning on Windows since the
+ // SkData's destructor is private. This friending gives the helper class
+ // access to the destructor.
+ friend class SkAutoTUnref<SkData>::BlockRef<SkData>;
typedef SkRefCnt INHERITED;
};
@@ -119,39 +126,25 @@ private:
*/
class SkAutoDataUnref : SkNoncopyable {
public:
- SkAutoDataUnref(SkData* data) : fRef(data) {
- if (data) {
- fData = data->data();
- fSize = data->size();
- } else {
- fData = NULL;
- fSize = 0;
- }
- }
+ SkAutoDataUnref(SkData* data) : fRef(data) {}
~SkAutoDataUnref() {
SkSafeUnref(fRef);
}
- const void* data() const { return fData; }
- const uint8_t* bytes() const {
- return reinterpret_cast<const uint8_t*> (fData);
- }
- size_t size() const { return fSize; }
SkData* get() const { return fRef; }
void release() {
if (fRef) {
fRef->unref();
fRef = NULL;
- fData = NULL;
- fSize = 0;
}
}
+ SkData *operator->() const { return fRef; }
+ operator SkData*() { return fRef; }
+
private:
SkData* fRef;
- const void* fData;
- size_t fSize;
};
#endif