2c7c7ee47d
Removed SkBitmapFactory since no clients were using it. New cache selection mechanism can simply pass a SkDiscardableMemory::Factory into the SkDiscardablePixelRef if non-default SkDiscardableMemory should be used. Removed BitmapFactoryTest. SkDiscardableMemory::Factory interface. Android will need this functionality in the future inside their BitmapFactory. Removed SkLazyPixelRef, since it's functionality is now subsumed into SkDiscardablePixelRef. Removed LazyPixelRef test. Modified SkDiscardablePixelRef to optionally allow it to use a SkDiscardableMemory::Factory. This tiny change makes it a replacement for SkLazyPixelRef. This functioanlity is also necessary for moving Android over to SkDiscardablePixelRef from SkImageRef in a later CL. Added a test for this. SkDecodingImageGenerator::Install can optionally pass a factory in to SkDiscardablePixelRef. Removed SkImageCache, SkLruImageCache, and SkPurgeableImageCache. This functionality can be handled much more cleanly by SkDiscardableMemory. New SkDiscardableMemoryPool class to replace SkLruImageCache. In a later CL, we will replace SkImageRef_GlobalPool (used by android) as well. This is a concrete implementation of SkDiscardableMemory::Factory. Added a test for this. modified gm/factory.cpp to remove dependnce on SkBitmapFactory + SkLruImageCache. Now uses SkDecodingImageGenerator + SkDiscardablePixelRef + SkDiscardableMemoryPool. SkImageDecoder::Target replaces SkBitmapFactory::Target. The DecodeMemoryToTarget function may disappear in the future. Moved SkLazyCachingPixelRef::DecodeProc replaces SkBitmapFactory::DecodeProc. This is a short term change, since another CL changes SkLazyCachingPixelRef to use SkImageGenerator instead of DecodeProc. Modified DrawBitmapRectTest to use SkDiscardablePixelRef instead of SkLazyPixelRef. tools/LazyDecodeBitmap.cpp now uses SkDecodingImageGenerator + SkDiscardablePixelRef instead of a SkBitmapFactory. bench_pictures uses the Global SkDiscardableMemoryPool instead of a global gLruImageCache. R=reed@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/103033002 git-svn-id: http://skia.googlecode.com/svn/trunk@12515 2bbb7eff-a529-9590-31e7-b0007b416f81
72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkData.h"
|
|
#include "SkDecodingImageGenerator.h"
|
|
#include "SkDiscardableMemoryPool.h"
|
|
#include "SkDiscardablePixelRef.h"
|
|
#include "SkImageDecoder.h"
|
|
#include "SkOSFile.h"
|
|
#include "SkStream.h"
|
|
|
|
namespace skiagm {
|
|
|
|
/**
|
|
* Draw a PNG created by SkBitmapFactory.
|
|
*/
|
|
class FactoryGM : public GM {
|
|
public:
|
|
FactoryGM() {}
|
|
|
|
protected:
|
|
virtual void onOnceBeforeDraw() SK_OVERRIDE {
|
|
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
|
|
SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath.c_str(),
|
|
"plane.png");
|
|
SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str()));
|
|
if (NULL != data.get()) {
|
|
// Create a cache which will boot the pixels out anytime the
|
|
// bitmap is unlocked.
|
|
SkAutoTUnref<SkDiscardableMemoryPool> pool(
|
|
SkNEW_ARGS(SkDiscardableMemoryPool, (1)));
|
|
SkAssertResult(SkDecodingImageGenerator::Install(data,
|
|
&fBitmap, pool));
|
|
}
|
|
}
|
|
|
|
virtual SkString onShortName() {
|
|
return SkString("factory");
|
|
}
|
|
|
|
virtual SkISize onISize() {
|
|
return make_isize(640, 480);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
canvas->drawBitmap(fBitmap, 0, 0);
|
|
}
|
|
|
|
// Skip cross process pipe due to https://code.google.com/p/skia/issues/detail?id=1520
|
|
virtual uint32_t onGetFlags() const {
|
|
return INHERITED::onGetFlags() | kSkipPipeCrossProcess_Flag;
|
|
}
|
|
|
|
private:
|
|
SkBitmap fBitmap;
|
|
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return new FactoryGM; }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|