aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmap.cpp24
-rw-r--r--src/core/SkImageFilterUtils.cpp10
-rw-r--r--src/core/SkScaledImageCache.cpp12
-rw-r--r--src/effects/gradients/SkGradientShader.cpp6
-rw-r--r--src/image/SkImagePriv.cpp2
-rw-r--r--src/image/SkImagePriv.h3
-rw-r--r--src/image/SkImage_Base.h1
-rw-r--r--src/image/SkImage_Raster.cpp17
-rw-r--r--src/image/SkSurface_Raster.cpp9
-rw-r--r--src/lazy/SkCachingPixelRef.cpp6
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp2
11 files changed, 44 insertions, 48 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 6615b1c52b..f950e28cdc 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -333,30 +333,6 @@ bool SkBitmap::setAlphaType(SkAlphaType alphaType) {
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 {
if (NULL != fPixelRef) {
if (fPixelLockCount > 0) {
diff --git a/src/core/SkImageFilterUtils.cpp b/src/core/SkImageFilterUtils.cpp
index 076ef9bb91..92fe67e84c 100644
--- a/src/core/SkImageFilterUtils.cpp
+++ b/src/core/SkImageFilterUtils.cpp
@@ -15,8 +15,14 @@
#include "SkGr.h"
bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- result->installPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
+ SkImageInfo info = {
+ width,
+ height,
+ kPMColor_SkColorType,
+ kPremul_SkAlphaType,
+ };
+ result->setConfig(info);
+ result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
return true;
}
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
index 68663f03b0..fc3148bdd8 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -293,10 +293,14 @@ bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap,
return false;
}
- SkImageInfo info = SkImageInfo::MakeN32(bitmap->width(), bitmap->height(),
- bitmap->alphaType());
-
- bitmap->installPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef,
+ SkImageInfo info = {
+ bitmap->width(),
+ bitmap->height(),
+ kPMColor_SkColorType,
+ bitmap->alphaType()
+ };
+
+ bitmap->setPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef,
(info, dm, bitmap->rowBytes())))->unref();
bitmap->lockPixels();
return bitmap->readyToDraw();
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 8ed40a7dda..6925ad2e4b 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -583,7 +583,8 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
if (fMapper) {
// force our cahce32pixelref to be built
(void)this->getCache32();
- bitmap->installPixelRef(fCache32PixelRef);
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
+ bitmap->setPixelRef(fCache32PixelRef);
return;
}
@@ -623,7 +624,8 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
if (!gCache->find(storage.get(), size, bitmap)) {
// force our cahce32pixelref to be built
(void)this->getCache32();
- bitmap->installPixelRef(fCache32PixelRef);
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
+ bitmap->setPixelRef(fCache32PixelRef);
gCache->add(storage.get(), size, *bitmap);
}
diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp
index af15a7599b..43cc44b2fa 100644
--- a/src/image/SkImagePriv.cpp
+++ b/src/image/SkImagePriv.cpp
@@ -74,7 +74,7 @@ SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
SkImage* image = NULL;
if (canSharePixelRef || bm.isImmutable()) {
- image = SkNewImageFromPixelRef(bm.pixelRef());
+ image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
} else {
bm.lockPixels();
if (bm.getPixels()) {
diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h
index 2812a8f72d..7c19c734c2 100644
--- a/src/image/SkImagePriv.h
+++ b/src/image/SkImagePriv.h
@@ -18,7 +18,8 @@ extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType);
extern bool SkBitmapConfigToColorType(SkBitmap::Config, SkColorType* ctOut);
// 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
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 5574f451fe..7bd1f7e6c9 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -13,7 +13,6 @@
class SkImage_Base : public SkImage {
public:
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 onDrawRectToRect(SkCanvas*, const SkRect* src,
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index b80fbb3a54..32d53fc52e 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -58,7 +58,7 @@ public:
virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
- SkImage_Raster(SkPixelRef*);
+ SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes);
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)
: INHERITED(info.fWidth, info.fHeight) {
+ fBitmap.setConfig(info, rowBytes);
SkAutoTUnref<SkPixelRef> ref(
SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0));
- fBitmap.installPixelRef(ref);
+ fBitmap.setPixelRef(ref);
fBitmap.setImmutable();
}
-SkImage_Raster::SkImage_Raster(SkPixelRef* pr)
- : INHERITED(pr->info())
+SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes)
+ : INHERITED(info.fWidth, info.fHeight)
{
- fBitmap.installPixelRef(pr);
+ fBitmap.setConfig(info, rowBytes);
+ fBitmap.setPixelRef(pr);
}
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));
}
-SkImage* SkNewImageFromPixelRef(SkPixelRef* pr) {
- return SkNEW_ARGS(SkImage_Raster, (pr));
+SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
+ size_t rowBytes) {
+ return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
}
SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 7010b5fb2a..1b218eb446 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -85,12 +85,15 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t
}
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;
- if (!pr->info().isOpaque()) {
+ if (!info.isOpaque()) {
fBitmap.eraseColor(SK_ColorTRANSPARENT);
}
}
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
index f5026c7365..f1510fb67c 100644
--- a/src/lazy/SkCachingPixelRef.cpp
+++ b/src/lazy/SkCachingPixelRef.cpp
@@ -12,13 +12,15 @@ bool SkCachingPixelRef::Install(SkImageGenerator* generator,
SkBitmap* dst) {
SkImageInfo info;
SkASSERT(dst != NULL);
- if (!generator || !generator->getInfo(&info)) {
+ if ((NULL == generator)
+ || !(generator->getInfo(&info))
+ || !dst->setConfig(info, 0)) {
SkDELETE(generator);
return false;
}
SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef,
(info, generator, dst->rowBytes())));
- dst->installPixelRef(ref);
+ dst->setPixelRef(ref);
return true;
}
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index eb5c2f9ab3..abd80f2e0a 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -94,6 +94,6 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
SkAutoTUnref<SkDiscardablePixelRef> ref(
SkNEW_ARGS(SkDiscardablePixelRef,
(info, autoGenerator.detach(), dst->rowBytes(), factory)));
- dst->installPixelRef(ref);
+ dst->setPixelRef(ref);
return true;
}