#include "SkFlattenable.h"
#include "SkTDArray.h"
-//#define SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
-
#ifdef SK_DEBUG
/**
* Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref
public:
SK_DECLARE_INST_COUNT(SkPixelRef)
-#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
- // DEPRECATED -- use a constructor that takes SkImageInfo
- explicit SkPixelRef(SkBaseMutex* mutex = NULL);
-#endif
-
explicit SkPixelRef(const SkImageInfo&);
SkPixelRef(const SkImageInfo&, SkBaseMutex* mutex);
virtual ~SkPixelRef();
private:
SkBaseMutex* fMutex; // must remain in scope for the life of this object
- // FIXME: fInfo should be const once we remove old constructor that does
- // not set it.
- SkImageInfo fInfo;
+
+ const SkImageInfo fInfo;
void* fPixels;
SkColorTable* fColorTable; // we do not track ownership, subclass does
// just need a > 0 value, so pick a funny one to aid in debugging
#define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789
-SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) {
+SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(info) {
this->setMutex(mutex);
- fInfo = info;
fPixels = NULL;
fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;
fPreLocked = false;
}
-SkPixelRef::SkPixelRef(const SkImageInfo& info) {
+SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) {
this->setMutex(NULL);
- fInfo = info;
fPixels = NULL;
fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;
fPreLocked = false;
}
-#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
-// THIS GUY IS DEPRECATED -- don't use me!
-SkPixelRef::SkPixelRef(SkBaseMutex* mutex) {
- this->setMutex(mutex);
- // Fill with dummy values.
- sk_bzero(&fInfo, sizeof(fInfo));
- fPixels = NULL;
- fColorTable = NULL; // we do not track ownership of this
- fLockCount = 0;
- this->needsNewGenID();
- fIsImmutable = false;
- fPreLocked = false;
+static SkImageInfo read_info(SkFlattenableReadBuffer& buffer) {
+ SkImageInfo info;
+ info.unflatten(buffer);
+ return info;
}
-#endif
SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
- : INHERITED(buffer) {
+ : INHERITED(buffer)
+ , fInfo(read_info(buffer))
+{
this->setMutex(mutex);
- fInfo.unflatten(buffer);
fPixels = NULL;
fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;