#include "SkMipMap.h"
#include "SkRect.h"
+SkBitmap::Allocator* SkBitmapCache::GetAllocator() {
+ return SkResourceCache::GetAllocator();
+}
+
/**
This function finds the bounds of the bitmap *within its pixelRef*.
If the bitmap lacks a pixelRef, it will return an empty rect, since
// degenerate, and the key we use for mipmaps
return;
}
+ SkASSERT(result.isImmutable());
SkResourceCache::Add(SkNEW_ARGS(BitmapRec, (src.getGenerationID(), invScaleX, invScaleY,
get_bounds_from_bitmap(src), result)));
}
}
void SkBitmapCache::Add(uint32_t genID, int width, int height, const SkBitmap& result) {
+ SkASSERT(result.isImmutable());
SkResourceCache::Add(SkNEW_ARGS(BitmapRec, (genID, SK_Scalar1, SK_Scalar1,
SkIRect::MakeWH(width, height), result)));
}
#define SkBitmapCache_DEFINED
#include "SkScalar.h"
+#include "SkBitmap.h"
-class SkBitmap;
class SkMipMap;
class SkBitmapCache {
public:
+ /**
+ * Use this allocator for bitmaps, so they can use ashmem when available.
+ */
+ static SkBitmap::Allocator* GetAllocator();
+
/**
* Search based on the src bitmap and inverse scales in X and Y. If found, returns true and
* result will be set to the matching bitmap with its pixels already locked.
*/
static bool Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, SkBitmap* result);
+
+ /*
+ * result must be marked isImmutable()
+ */
static void Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY,
const SkBitmap& result);
* result will be set to the matching bitmap with its pixels already locked.
*/
static bool Find(uint32_t genID, int width, int height, SkBitmap* result);
+
+ /*
+ * result must be marked isImmutable()
+ */
static void Add(uint32_t genID, int width, int height, const SkBitmap& result);
};
}
SkASSERT(NULL != fScaledBitmap.getPixels());
+ fScaledBitmap.setImmutable();
SkBitmapCache::Add(fOrigBitmap, roundedDestWidth, roundedDestHeight, fScaledBitmap);
}
fErrorInDecoding = true;
return false;
}
+ fLockedBitmap.setImmutable();
SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, fLockedBitmap);
}