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

Unified Diff: src/core/SkBitmap.cpp

Issue 139463007: no need to refcnt colortables, since pixelrefs own them (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 months 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/SkBitmap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 27ea35e974b8c4423ed58671e4b22b936cf00c75..9a5f1f26dcacaf6faa8310b4424ef83640491426 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -101,15 +101,7 @@ SkBitmap& SkBitmap::operator=(const SkBitmap& src) {
// we reset our locks if we get blown away
fPixelLockCount = 0;
- /* The src could be in 3 states
- 1. no pixelref, in which case we just copy/ref the pixels/ctable
- 2. unlocked pixelref, pixels/ctable should be null
- 3. locked pixelref, we should lock the ref again ourselves
- */
- if (NULL == fPixelRef) {
- // leave fPixels as it is
- SkSafeRef(fColorTable); // ref the user's ctable if present
- } else { // we have a pixelref, so pixels/ctable reflect it
+ if (fPixelRef) {
// ignore the values from the memcpy
fPixels = NULL;
fColorTable = NULL;
@@ -345,14 +337,11 @@ void SkBitmap::updatePixelsFromRef() const {
+ fPixelRefOrigin.fX * fBytesPerPixel;
}
fPixels = p;
- SkRefCnt_SafeAssign(fColorTable, fPixelRef->colorTable());
+ fColorTable = fPixelRef->colorTable();
} else {
SkASSERT(0 == fPixelLockCount);
fPixels = NULL;
- if (fColorTable) {
- fColorTable->unref();
- fColorTable = NULL;
- }
+ fColorTable = NULL;
}
}
}
@@ -510,11 +499,6 @@ void SkBitmap::freePixels() {
// if we're gonna free the pixels, we certainly need to free the mipmap
this->freeMipMap();
- if (fColorTable) {
- fColorTable->unref();
- fColorTable = NULL;
- }
-
if (NULL != fPixelRef) {
if (fPixelLockCount > 0) {
fPixelRef->unlockPixels();
@@ -525,6 +509,7 @@ void SkBitmap::freePixels() {
}
fPixelLockCount = 0;
fPixels = NULL;
+ fColorTable = NULL;
}
void SkBitmap::freeMipMap() {
@@ -1610,7 +1595,6 @@ void SkBitmap::validate() const {
#endif
SkASSERT(fFlags <= allFlags);
SkASSERT(fPixelLockCount >= 0);
- SkASSERT(NULL == fColorTable || (unsigned)fColorTable->getRefCnt() < 10000);
SkASSERT((uint8_t)ComputeBytesPerPixel((Config)fConfig) == fBytesPerPixel);
if (fPixels) {
« no previous file with comments | « include/core/SkBitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698