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

Unified Diff: src/core/SkScaledImageCache.cpp

Issue 110593003: Add onNewLockPixels, that returns rowbytes and relies on info in pixelref (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 12 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 | « src/core/SkPixelRef.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScaledImageCache.cpp
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
index 45a568463853e050030a47a48da04b2990544013..5a772a7cd502681ea558acfd1dba98b4b86a289b 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -199,13 +199,11 @@ public:
SK_DECLARE_UNFLATTENABLE_OBJECT()
protected:
- virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
+ virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
virtual void onUnlockPixels() SK_OVERRIDE;
virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE;
private:
- SkImageInfo fInfo; // remove when SkPixelRef gets this in baseclass
-
SkDiscardableMemory* fDM;
size_t fRB;
bool fFirstTime;
@@ -220,8 +218,6 @@ SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
, fDM(dm)
, fRB(rowBytes)
{
- fInfo = info; // remove this redundant field when SkPixelRef has info
-
SkASSERT(dm->data());
fFirstTime = true;
}
@@ -230,26 +226,31 @@ SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
SkDELETE(fDM);
}
-void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
+bool SkOneShotDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
if (fFirstTime) {
// we're already locked
SkASSERT(fDM->data());
fFirstTime = false;
- return fDM->data();
+ goto SUCCESS;
}
// A previous call to onUnlock may have deleted our DM, so check for that
if (NULL == fDM) {
- return NULL;
+ return false;
}
if (!fDM->lock()) {
// since it failed, we delete it now, to free-up the resource
delete fDM;
fDM = NULL;
- return NULL;
+ return false;
}
- return fDM->data();
+
+SUCCESS:
+ rec->fPixels = fDM->data();
+ rec->fColorTable = NULL;
+ rec->fRowBytes = fRB;
+ return true;
}
void SkOneShotDiscardablePixelRef::onUnlockPixels() {
@@ -258,7 +259,7 @@ void SkOneShotDiscardablePixelRef::onUnlockPixels() {
}
size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {
- return fInfo.fHeight * fRB;
+ return this->info().getSafeSize(fRB);
}
class SkScaledImageCacheDiscardableAllocator : public SkBitmap::Allocator {
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698