Index: src/gpu/SkGrPixelRef.cpp |
=================================================================== |
--- src/gpu/SkGrPixelRef.cpp (revision 12666) |
+++ src/gpu/SkGrPixelRef.cpp (working copy) |
@@ -18,29 +18,24 @@ |
// to avoid deadlock with the default one provided by SkPixelRef. |
SK_DECLARE_STATIC_MUTEX(gROLockPixelsPixelRefMutex); |
-SkROLockPixelsPixelRef::SkROLockPixelsPixelRef(const SkImageInfo& info) |
- : INHERITED(info, &gROLockPixelsPixelRefMutex) { |
+SkROLockPixelsPixelRef::SkROLockPixelsPixelRef() : INHERITED(&gROLockPixelsPixelRefMutex) { |
} |
SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() { |
} |
-bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) { |
+void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) { |
+ if (ctable) { |
+ *ctable = NULL; |
+ } |
fBitmap.reset(); |
// SkDebugf("---------- calling readpixels in support of lockpixels\n"); |
if (!this->onReadPixels(&fBitmap, NULL)) { |
SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); |
- return false; |
+ return NULL; |
} |
fBitmap.lockPixels(); |
- if (NULL == fBitmap.getPixels()) { |
- return false; |
- } |
- |
- rec->fPixels = fBitmap.getPixels(); |
- rec->fColorTable = NULL; |
- rec->fRowBytes = fBitmap.rowBytes(); |
- return true; |
+ return fBitmap.getPixels(); |
} |
void SkROLockPixelsPixelRef::onUnlockPixels() { |
@@ -81,14 +76,6 @@ |
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig); |
- SkImageInfo info; |
- if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) { |
- return NULL; |
- } |
- info.fWidth = desc.fWidth; |
- info.fHeight = desc.fHeight; |
- info.fAlphaType = kPremul_SkAlphaType; |
- |
GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); |
if (NULL == dst) { |
return NULL; |
@@ -106,17 +93,14 @@ |
dst->releaseRenderTarget(); |
#endif |
- SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); |
+ SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst)); |
SkSafeUnref(dst); |
return pixelRef; |
} |
/////////////////////////////////////////////////////////////////////////////// |
-SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, |
- bool transferCacheLock) |
- : INHERITED(info) |
-{ |
+SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) { |
// TODO: figure out if this is responsible for Chrome canvas errors |
#if 0 |
// The GrTexture has a ref to the GrRenderTarget but not vice versa. |
@@ -133,6 +117,23 @@ |
SkSafeRef(surface); |
} |
+SkGrPixelRef::SkGrPixelRef(const SkImageInfo&, GrSurface* surface, bool transferCacheLock) { |
+ // TODO: figure out if this is responsible for Chrome canvas errors |
+#if 0 |
+ // The GrTexture has a ref to the GrRenderTarget but not vice versa. |
+ // If the GrTexture exists take a ref to that (rather than the render |
+ // target) |
+ fSurface = surface->asTexture(); |
+#else |
+ fSurface = NULL; |
+#endif |
+ if (NULL == fSurface) { |
+ fSurface = surface; |
+ } |
+ fUnlock = transferCacheLock; |
+ SkSafeRef(surface); |
+} |
+ |
SkGrPixelRef::~SkGrPixelRef() { |
if (fUnlock) { |
GrContext* context = fSurface->getContext(); |