Reason for revert: broken tests

TBR=
NOTREECHECKS=true
NOTRY=true
BUG=

Author: reed@google.com

Review URL: https://codereview.chromium.org/134843008

git-svn-id: http://skia.googlecode.com/svn/trunk@13058 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-01-13 20:39:14 +00:00
parent f0b56e7448
commit e13af711d4
15 changed files with 45 additions and 113 deletions

View File

@ -268,16 +268,6 @@ public:
*/ */
void setPixels(void* p, SkColorTable* ctable = NULL); void setPixels(void* p, SkColorTable* ctable = NULL);
/**
* Install the specified pixelref into the bitmap, with an optional rect
* for referencing a subset of the pixels in the pixelref. This sets the
* config/width/height/alphatype of the bitmap to match the pixelref.
*
* The subset rect, if not null, is intersected with the bounds of the
* pixelref (taken from its SkImageInfo).
*/
SkPixelRef* installPixelRef(SkPixelRef*, const SkIRect* subset = NULL);
/** Copies the bitmap's pixels to the location pointed at by dst and returns /** Copies the bitmap's pixels to the location pointed at by dst and returns
true if possible, returns false otherwise. true if possible, returns false otherwise.

View File

@ -109,60 +109,6 @@ struct SkImageInfo {
SkColorType fColorType; SkColorType fColorType;
SkAlphaType fAlphaType; SkAlphaType fAlphaType;
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at) {
SkASSERT(width >= 0);
SkASSERT(height >= 0);
SkImageInfo info = {
width, height, ct, at
};
return info;
}
/**
* Sets colortype to the native ARGB32 type.
*/
static SkImageInfo MakeN32(int width, int height, SkAlphaType at) {
SkASSERT(width >= 0);
SkASSERT(height >= 0);
SkImageInfo info = {
width, height, kPMColor_SkColorType, at
};
return info;
}
/**
* Sets colortype to the native ARGB32 type, and the alphatype to premul.
*/
static SkImageInfo MakeN32Premul(int width, int height) {
SkASSERT(width >= 0);
SkASSERT(height >= 0);
SkImageInfo info = {
width, height, kPMColor_SkColorType, kPremul_SkAlphaType
};
return info;
}
/**
* Sets colortype to the native ARGB32 type, and the alphatype to opaque.
*/
static SkImageInfo MakeN32Opaque(int width, int height) {
SkASSERT(width >= 0);
SkASSERT(height >= 0);
SkImageInfo info = {
width, height, kPMColor_SkColorType, kOpaque_SkAlphaType
};
return info;
}
static SkImageInfo MakeA8(int width, int height) {
SkASSERT(width >= 0);
SkASSERT(height >= 0);
SkImageInfo info = {
width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType
};
return info;
}
bool isOpaque() const { bool isOpaque() const {
return SkAlphaTypeIsOpaque(fAlphaType); return SkAlphaTypeIsOpaque(fAlphaType);
} }

View File

@ -333,30 +333,6 @@ bool SkBitmap::setAlphaType(SkAlphaType alphaType) {
return true; return true;
} }
SkPixelRef* SkBitmap::installPixelRef(SkPixelRef* pr, const SkIRect* subset) {
if (NULL == pr) {
this->reset();
return NULL;
}
const SkImageInfo& info = pr->info();
fConfig = SkColorTypeToBitmapConfig(info.fColorType);
fAlphaType = info.fAlphaType;
fBytesPerPixel = info.bytesPerPixel();
// not known until we're locked
fRowBytes = 0;
SkIRect bounds = { 0, 0, info.fWidth, info.fHeight };
if (subset && !bounds.intersect(*subset)) {
bounds.setEmpty();
}
fWidth = bounds.width();
fHeight = bounds.height();
return this->setPixelRef(pr, bounds.left(), bounds.top());
}
void SkBitmap::updatePixelsFromRef() const { void SkBitmap::updatePixelsFromRef() const {
if (NULL != fPixelRef) { if (NULL != fPixelRef) {
if (fPixelLockCount > 0) { if (fPixelLockCount > 0) {

View File

@ -15,8 +15,14 @@
#include "SkGr.h" #include "SkGr.h"
bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) { bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); SkImageInfo info = {
result->installPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); width,
height,
kPMColor_SkColorType,
kPremul_SkAlphaType,
};
result->setConfig(info);
result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
return true; return true;
} }

View File

@ -293,10 +293,14 @@ bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap,
return false; return false;
} }
SkImageInfo info = SkImageInfo::MakeN32(bitmap->width(), bitmap->height(), SkImageInfo info = {
bitmap->alphaType()); bitmap->width(),
bitmap->height(),
kPMColor_SkColorType,
bitmap->alphaType()
};
bitmap->installPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef, bitmap->setPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef,
(info, dm, bitmap->rowBytes())))->unref(); (info, dm, bitmap->rowBytes())))->unref();
bitmap->lockPixels(); bitmap->lockPixels();
return bitmap->readyToDraw(); return bitmap->readyToDraw();

View File

@ -583,7 +583,8 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
if (fMapper) { if (fMapper) {
// force our cahce32pixelref to be built // force our cahce32pixelref to be built
(void)this->getCache32(); (void)this->getCache32();
bitmap->installPixelRef(fCache32PixelRef); bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
bitmap->setPixelRef(fCache32PixelRef);
return; return;
} }
@ -623,7 +624,8 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
if (!gCache->find(storage.get(), size, bitmap)) { if (!gCache->find(storage.get(), size, bitmap)) {
// force our cahce32pixelref to be built // force our cahce32pixelref to be built
(void)this->getCache32(); (void)this->getCache32();
bitmap->installPixelRef(fCache32PixelRef); bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
bitmap->setPixelRef(fCache32PixelRef);
gCache->add(storage.get(), size, *bitmap); gCache->add(storage.get(), size, *bitmap);
} }

View File

@ -74,7 +74,7 @@ SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
SkImage* image = NULL; SkImage* image = NULL;
if (canSharePixelRef || bm.isImmutable()) { if (canSharePixelRef || bm.isImmutable()) {
image = SkNewImageFromPixelRef(bm.pixelRef()); image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
} else { } else {
bm.lockPixels(); bm.lockPixels();
if (bm.getPixels()) { if (bm.getPixels()) {

View File

@ -18,7 +18,8 @@ extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType);
extern bool SkBitmapConfigToColorType(SkBitmap::Config, SkColorType* ctOut); extern bool SkBitmapConfigToColorType(SkBitmap::Config, SkColorType* ctOut);
// Call this if you explicitly want to use/share this pixelRef in the image // Call this if you explicitly want to use/share this pixelRef in the image
extern SkImage* SkNewImageFromPixelRef(SkPixelRef*); extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*,
size_t rowBytes);
/** /**
* Examines the bitmap to decide if it can share the existing pixelRef, or * Examines the bitmap to decide if it can share the existing pixelRef, or

View File

@ -13,7 +13,6 @@
class SkImage_Base : public SkImage { class SkImage_Base : public SkImage {
public: public:
SkImage_Base(int width, int height) : INHERITED(width, height) {} SkImage_Base(int width, int height) : INHERITED(width, height) {}
SkImage_Base(const SkImageInfo& info) : INHERITED(info.fWidth, info.fHeight) {}
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) = 0; virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) = 0;
virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, virtual void onDrawRectToRect(SkCanvas*, const SkRect* src,

View File

@ -58,7 +58,7 @@ public:
virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef // exposed for SkSurface_Raster via SkNewImageFromPixelRef
SkImage_Raster(SkPixelRef*); SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes);
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
@ -84,16 +84,18 @@ SkImage* SkImage_Raster::NewEmpty() {
SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes)
: INHERITED(info.fWidth, info.fHeight) { : INHERITED(info.fWidth, info.fHeight) {
fBitmap.setConfig(info, rowBytes);
SkAutoTUnref<SkPixelRef> ref( SkAutoTUnref<SkPixelRef> ref(
SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0)); SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0));
fBitmap.installPixelRef(ref); fBitmap.setPixelRef(ref);
fBitmap.setImmutable(); fBitmap.setImmutable();
} }
SkImage_Raster::SkImage_Raster(SkPixelRef* pr) SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes)
: INHERITED(pr->info()) : INHERITED(info.fWidth, info.fHeight)
{ {
fBitmap.installPixelRef(pr); fBitmap.setConfig(info, rowBytes);
fBitmap.setPixelRef(pr);
} }
SkImage_Raster::~SkImage_Raster() {} SkImage_Raster::~SkImage_Raster() {}
@ -153,8 +155,9 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* pixelData, size
return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes)); return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes));
} }
SkImage* SkNewImageFromPixelRef(SkPixelRef* pr) { SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
return SkNEW_ARGS(SkImage_Raster, (pr)); size_t rowBytes) {
return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
} }
SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {

View File

@ -85,12 +85,15 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t
} }
SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr) SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr)
: INHERITED(pr->info()) : INHERITED(pr->info().fWidth, pr->info().fHeight)
{ {
fBitmap.installPixelRef(pr); const SkImageInfo& info = pr->info();
fBitmap.setConfig(info, info.minRowBytes());
fBitmap.setPixelRef(pr);
fWeOwnThePixels = true; fWeOwnThePixels = true;
if (!pr->info().isOpaque()) { if (!info.isOpaque()) {
fBitmap.eraseColor(SK_ColorTRANSPARENT); fBitmap.eraseColor(SK_ColorTRANSPARENT);
} }
} }

View File

@ -12,13 +12,15 @@ bool SkCachingPixelRef::Install(SkImageGenerator* generator,
SkBitmap* dst) { SkBitmap* dst) {
SkImageInfo info; SkImageInfo info;
SkASSERT(dst != NULL); SkASSERT(dst != NULL);
if (!generator || !generator->getInfo(&info)) { if ((NULL == generator)
|| !(generator->getInfo(&info))
|| !dst->setConfig(info, 0)) {
SkDELETE(generator); SkDELETE(generator);
return false; return false;
} }
SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef,
(info, generator, dst->rowBytes()))); (info, generator, dst->rowBytes())));
dst->installPixelRef(ref); dst->setPixelRef(ref);
return true; return true;
} }

View File

@ -94,6 +94,6 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
SkAutoTUnref<SkDiscardablePixelRef> ref( SkAutoTUnref<SkDiscardablePixelRef> ref(
SkNEW_ARGS(SkDiscardablePixelRef, SkNEW_ARGS(SkDiscardablePixelRef,
(info, autoGenerator.detach(), dst->rowBytes(), factory))); (info, autoGenerator.detach(), dst->rowBytes(), factory)));
dst->installPixelRef(ref); dst->setPixelRef(ref);
return true; return true;
} }

View File

@ -23,7 +23,7 @@ static void set_to_one_proc(void*, void* context) {
*/ */
DEF_TEST(MallocPixelRef, reporter) { DEF_TEST(MallocPixelRef, reporter) {
REPORTER_ASSERT(reporter, true); REPORTER_ASSERT(reporter, true);
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13); SkImageInfo info = {10, 13, kPMColor_SkColorType, kPremul_SkAlphaType};
{ {
SkAutoTUnref<SkMallocPixelRef> pr( SkAutoTUnref<SkMallocPixelRef> pr(
SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, NULL)); SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, NULL));

View File

@ -51,7 +51,7 @@ private:
} // namespace } // namespace
DEF_TEST(PixelRef_GenIDChange, r) { DEF_TEST(PixelRef_GenIDChange, r) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType };
SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NULL)); SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NULL));