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

Unified Diff: include/core/SkPixelRef.h

Issue 113193003: Revert of remvoe duplicate impl for SkImageInfo flattening (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPicture.h ('k') | include/gpu/GrSurface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixelRef.h
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 472599eeb3191c1da4a6f252ed98029e5583ef12..b87b0dc114b34958ff36f93ea3d464320334ae60 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -14,12 +14,9 @@
#include "SkRefCnt.h"
#include "SkString.h"
#include "SkFlattenable.h"
-#include "SkImageInfo.h"
#include "SkTDArray.h"
-//#define SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
-
-#define SK_SUPPORT_LEGACY_ONLOCKPIXELS
+#define SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
#ifdef SK_DEBUG
/**
@@ -70,24 +67,12 @@
/** Return the pixel memory returned from lockPixels, or null if the
lockCount is 0.
*/
- void* pixels() const { return fRec.fPixels; }
+ void* pixels() const { return fPixels; }
/** Return the current colorTable (if any) if pixels are locked, or null.
*/
- SkColorTable* colorTable() const { return fRec.fColorTable; }
-
- /**
- * To access the actual pixels of a pixelref, it must be "locked".
- * Calling lockPixels returns a LockRec struct (on success).
- */
- struct LockRec {
- void* fPixels;
- SkColorTable* fColorTable;
- size_t fRowBytes;
-
- void zero() { sk_bzero(this, sizeof(*this)); }
- };
-
+ SkColorTable* colorTable() const { return fColorTable; }
+
/**
* Returns true if the lockcount > 0
*/
@@ -95,19 +80,10 @@
SkDEBUGCODE(int getLockCount() const { return fLockCount; })
- /**
- * Call to access the pixel memory. Return true on success. Balance this
- * with a call to unlockPixels().
- */
- bool lockPixels();
-
- /**
- * Call to access the pixel memory. On success, return true and fill out
- * the specified rec. On failure, return false and ignore the rec parameter.
- * Balance this with a call to unlockPixels().
- */
- bool lockPixels(LockRec* rec);
-
+ /** Call to access the pixel memory, which is returned. Balance with a call
+ to unlockPixels().
+ */
+ void lockPixels();
/** Call to balanace a previous call to lockPixels(). Returns the pixels
(or null) after the unlock. NOTE: lock calls can be nested, but the
matching number of unlock calls must be made in order to free the
@@ -264,28 +240,14 @@
void addGenIDChangeListener(GenIDChangeListener* listener);
protected:
-#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
- virtual void* onLockPixels(SkColorTable**);
- virtual bool onNewLockPixels(LockRec*);
-#else
- /**
- * On success, returns true and fills out the LockRec for the pixels. On
- * failure returns false and ignores the LockRec parameter.
- *
- * The caller will have already acquired a mutex for thread safety, so this
- * method need not do that.
- */
- virtual bool onNewLockPixels(LockRec*) = 0;
-#endif
-
- /**
- * Balancing the previous successful call to onNewLockPixels. The locked
- * pixel address will no longer be referenced, so the subclass is free to
- * move or discard that memory.
- *
- * The caller will have already acquired a mutex for thread safety, so this
- * method need not do that.
- */
+ /** Called when the lockCount goes from 0 to 1. The caller will have already
+ acquire a mutex for thread safety, so this method need not do that.
+ */
+ virtual void* onLockPixels(SkColorTable**) = 0;
+ /** Called when the lock count goes from 1 to 0. The caller will have
+ already acquire a mutex for thread safety, so this method need not do
+ that.
+ */
virtual void onUnlockPixels() = 0;
/** Default impl returns true */
@@ -329,14 +291,14 @@
// only call from constructor. Flags this to always be locked, removing
// the need to grab the mutex and call onLockPixels/onUnlockPixels.
// Performance tweak to avoid those calls (esp. in multi-thread use case).
- void setPreLocked(void*, size_t rowBytes, SkColorTable*);
+ void setPreLocked(void* pixels, SkColorTable* ctable);
private:
SkBaseMutex* fMutex; // must remain in scope for the life of this object
SkImageInfo fInfo;
-
- // LockRec is only valid if we're in a locked state (isLocked())
- LockRec fRec;
+
+ void* fPixels;
+ SkColorTable* fColorTable; // we do not track ownership, subclass does
int fLockCount;
mutable uint32_t fGenerationID;
« no previous file with comments | « include/core/SkPicture.h ('k') | include/gpu/GrSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698