#include "SkStream.h"
#include "SkXMLParser.h"
+#include "SkImageRef_GlobalPool.h"
+
+static SkBitmap load_bitmap() {
+ SkStream* stream = new SkFILEStream("/skimages/sesame_street_ensemble-hp.jpg");
+ SkAutoUnref aur(stream);
+
+ SkBitmap bm;
+ if (SkImageDecoder::DecodeStream(stream, &bm, SkBitmap::kNo_Config,
+ SkImageDecoder::kDecodeBounds_Mode)) {
+ SkPixelRef* pr = new SkImageRef_GlobalPool(stream, bm.config(), 1);
+ bm.setPixelRef(pr)->unref();
+ }
+ return bm;
+}
+
static void drawCircle(SkCanvas* canvas, int r, SkColor color) {
SkPaint paint;
paint.setAntiAlias(true);
}
class PictureView : public SkView {
+ SkBitmap fBitmap;
public:
PictureView() {
+ SkImageRef_GlobalPool::SetRAMBudget(16 * 1024);
+
+ fBitmap = load_bitmap();
+
fPicture = new SkPicture;
SkCanvas* canvas = fPicture->beginRecording(100, 100);
SkPaint paint;
paint.setAntiAlias(true);
+ canvas->drawBitmap(fBitmap, 0, 0, NULL);
+
drawCircle(canvas, 50, SK_ColorBLACK);
fSubPicture = new SkPicture;
canvas->drawPicture(*fSubPicture);
void drawSomething(SkCanvas* canvas) {
SkPaint paint;
-
+
+ canvas->save();
+ canvas->scale(0.5f, 0.5f);
+ canvas->drawBitmap(fBitmap, 0, 0, NULL);
+ canvas->restore();
+
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
#include "SkTemplates.h"
#include "SkThread.h"
+//#define DUMP_IMAGEREF_LIFECYCLE
+
// can't be static, as SkImageRef_Pool needs to see it
SkMutex gImageRefMutex;
: INHERITED(buffer, &gImageRefMutex), fErrorInDecoding(false) {
fConfig = (SkBitmap::Config)buffer.readU8();
fSampleSize = buffer.readU8();
+ fDoDither = buffer.readBool();
+
size_t length = buffer.readU32();
fStream = SkNEW_ARGS(SkMemoryStream, (length));
buffer.read((void*)fStream->getMemoryBase(), length);
buffer.write8(fConfig);
buffer.write8(fSampleSize);
+ buffer.writeBool(fDoDither);
size_t length = fStream->getLength();
buffer.write32(length);
fStream->rewind();