aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmap.cpp33
-rw-r--r--src/core/SkBitmapDevice.cpp2
-rw-r--r--src/core/SkBitmapScaler.cpp6
-rw-r--r--src/core/SkCanvas.cpp2
-rw-r--r--src/core/SkDraw.cpp14
-rw-r--r--src/core/SkImageFilter.cpp2
-rw-r--r--src/core/SkMipMap.cpp23
-rw-r--r--src/core/SkReadBuffer.cpp2
-rw-r--r--src/core/SkScalerContext.cpp8
-rw-r--r--src/core/SkValidationUtils.h6
10 files changed, 43 insertions, 55 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 522dfb1ebb..07f6f177de 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -202,7 +202,7 @@ static bool validate_alphaType(SkColorType colorType, SkAlphaType alphaType,
return true;
}
-bool SkBitmap::setConfig(const SkImageInfo& origInfo, size_t rowBytes) {
+bool SkBitmap::setInfo(const SkImageInfo& origInfo, size_t rowBytes) {
SkImageInfo info = origInfo;
if (!validate_alphaType(info.fColorType, info.fAlphaType,
@@ -241,8 +241,7 @@ bool SkBitmap::setConfig(const SkImageInfo& origInfo, size_t rowBytes) {
bool SkBitmap::setConfig(Config config, int width, int height, size_t rowBytes,
SkAlphaType alphaType) {
SkColorType ct = SkBitmapConfigToColorType(config);
- return this->setConfig(SkImageInfo::Make(width, height, ct, alphaType),
- rowBytes);
+ return this->setInfo(SkImageInfo::Make(width, height, ct, alphaType), rowBytes);
}
bool SkBitmap::setAlphaType(SkAlphaType alphaType) {
@@ -419,7 +418,7 @@ bool SkBitmap::allocPixels(const SkImageInfo& info, SkPixelRefFactory* factory,
if (kIndex_8_SkColorType == info.fColorType && NULL == ctable) {
return reset_return_false(this);
}
- if (!this->setConfig(info)) {
+ if (!this->setInfo(info)) {
return reset_return_false(this);
}
@@ -444,7 +443,7 @@ bool SkBitmap::allocPixels(const SkImageInfo& info, SkPixelRefFactory* factory,
bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb, SkColorTable* ct,
void (*releaseProc)(void* addr, void* context), void* context) {
- if (!this->setConfig(info, rb)) {
+ if (!this->setInfo(info, rb)) {
this->reset();
return false;
}
@@ -884,8 +883,8 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
SkPixelRef* pixelRef = fPixelRef->deepCopy(this->config(), &subset);
if (pixelRef != NULL) {
SkBitmap dst;
- dst.setConfig(SkImageInfo::Make(subset.width(), subset.height(),
- this->colorType(), this->alphaType()));
+ dst.setInfo(SkImageInfo::Make(subset.width(), subset.height(),
+ this->colorType(), this->alphaType()));
dst.setIsVolatile(this->isVolatile());
dst.setPixelRef(pixelRef)->unref();
SkDEBUGCODE(dst.validate());
@@ -900,8 +899,8 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height()));
SkBitmap dst;
- dst.setConfig(SkImageInfo::Make(r.width(), r.height(), this->colorType(), this->alphaType()),
- this->rowBytes());
+ dst.setInfo(SkImageInfo::Make(r.width(), r.height(), this->colorType(), this->alphaType()),
+ this->rowBytes());
dst.setIsVolatile(this->isVolatile());
if (fPixelRef) {
@@ -994,7 +993,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType,
dstInfo.fColorType = dstColorType;
SkBitmap tmpDst;
- if (!tmpDst.setConfig(dstInfo)) {
+ if (!tmpDst.setInfo(dstInfo)) {
return false;
}
@@ -1102,13 +1101,13 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
// Use the same rowBytes as the original.
rowBytes = fRowBytes;
} else {
- // With the new config, an appropriate fRowBytes will be computed by setConfig.
+ // With the new config, an appropriate fRowBytes will be computed by setInfo.
rowBytes = 0;
}
SkImageInfo info = fInfo;
info.fColorType = dstCT;
- if (!dst->setConfig(info, rowBytes)) {
+ if (!dst->setInfo(info, rowBytes)) {
return false;
}
dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref();
@@ -1218,7 +1217,7 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
dstM.fRowBytes = SkAlign4(dstM.fBounds.width());
} else {
NO_FILTER_CASE:
- tmpBitmap.setConfig(SkImageInfo::MakeA8(this->width(), this->height()), srcM.fRowBytes);
+ tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), srcM.fRowBytes);
if (!tmpBitmap.allocPixels(allocator, NULL)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
@@ -1241,8 +1240,8 @@ bool SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
}
SkAutoMaskFreeImage dstCleanup(dstM.fImage);
- tmpBitmap.setConfig(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.height()),
- dstM.fRowBytes);
+ tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.height()),
+ dstM.fRowBytes);
if (!tmpBitmap.allocPixels(allocator, NULL)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
@@ -1334,7 +1333,7 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowBytes(),
ctable.get(), data.get()));
- bitmap->setConfig(pr->info());
+ bitmap->setInfo(pr->info());
bitmap->setPixelRef(pr, 0, 0);
return true;
}
@@ -1358,7 +1357,7 @@ void SkBitmap::legacyUnflatten(SkReadBuffer& buffer) {
return;
}
- bool configIsValid = this->setConfig(info, rowBytes);
+ bool configIsValid = this->setInfo(info, rowBytes);
buffer.validate(configIsValid);
int reftype = buffer.readInt();
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 109943598a..0f3cc2be50 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -78,7 +78,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
SkBitmap bitmap;
if (kUnknown_SkColorType == info.colorType()) {
- if (!bitmap.setConfig(info)) {
+ if (!bitmap.setInfo(info)) {
return NULL;
}
} else {
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index ebcccf2fe0..be32a891fc 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -296,9 +296,9 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
// Convolve into the result.
SkBitmap result;
- result.setConfig(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()),
- SkScalarCeilToInt(destSubset.height()),
- source.alphaType()));
+ result.setInfo(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()),
+ SkScalarCeilToInt(destSubset.height()),
+ source.alphaType()));
result.allocPixels(allocator, NULL);
if (!result.readyToDraw()) {
return false;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 7e10504fbd..6ed6a85780 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -499,7 +499,7 @@ SkCanvas::SkCanvas(int width, int height)
inc_canvas();
SkBitmap bitmap;
- bitmap.setConfig(SkImageInfo::MakeUnknown(width, height));
+ bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)))->unref();
}
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 5692fe11b3..fa2ac9863e 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1216,9 +1216,8 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
// now draw our bitmap(src) into mask(dst), transformed by the matrix
{
SkBitmap device;
- device.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(),
- mask.fBounds.height(), mask.fRowBytes);
- device.setPixels(mask.fImage);
+ device.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), mask.fBounds.height()),
+ mask.fImage, mask.fRowBytes);
SkCanvas c(device);
// need the unclipped top/left for the translate
@@ -1666,9 +1665,8 @@ void SkDraw1Glyph::blitMaskAsSprite(const SkMask& mask) const {
SkASSERT(SkMask::kARGB32_Format == mask.fFormat);
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config,
- mask.fBounds.width(), mask.fBounds.height(), mask.fRowBytes);
- bm.setPixels((SkPMColor*)mask.fImage);
+ bm.installPixels(SkImageInfo::MakeN32Premul(mask.fBounds.width(), mask.fBounds.height()),
+ (SkPMColor*)mask.fImage, mask.fRowBytes);
fDraw->drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), *fPaint);
}
@@ -2673,8 +2671,8 @@ static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
SkMatrix matrix;
SkPaint paint;
- bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), mask.fBounds.height(), mask.fRowBytes);
- bm.setPixels(mask.fImage);
+ bm.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), mask.fBounds.height()),
+ mask.fImage, mask.fRowBytes);
clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height()));
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 582f8992a3..6356c1a5dd 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -309,7 +309,7 @@ SkImageFilter::Cache* SkImageFilter::GetExternalCache() {
void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- result->setConfig(info);
+ result->setInfo(info);
result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
}
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index ff62f4d59d..cb88eb4596 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -123,21 +123,21 @@ SkMipMap::Level* SkMipMap::AllocLevels(int levelCount, size_t pixelSize) {
SkMipMap* SkMipMap::Build(const SkBitmap& src) {
void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src);
- const SkBitmap::Config config = src.config();
- switch (config) {
- case SkBitmap::kARGB_8888_Config:
+ const SkColorType ct = src.colorType();
+ const SkAlphaType at = src.alphaType();
+ switch (ct) {
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType:
proc = downsampleby2_proc32;
break;
- case SkBitmap::kRGB_565_Config:
+ case kRGB_565_SkColorType:
proc = downsampleby2_proc16;
break;
- case SkBitmap::kARGB_4444_Config:
+ case kARGB_4444_SkColorType:
proc = downsampleby2_proc4444;
break;
- case SkBitmap::kIndex8_Config:
- case SkBitmap::kA8_Config:
default:
- return NULL; // don't build mipmaps for these configs
+ return NULL; // don't build mipmaps for any other colortypes (yet)
}
SkAutoLockPixels alp(src);
@@ -157,7 +157,7 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src) {
if (0 == width || 0 == height) {
break;
}
- size += SkBitmap::ComputeRowBytes(config, width) * height;
+ size += SkColorTypeMinRowBytes(ct, width) * height;
countLevels += 1;
}
}
@@ -180,7 +180,7 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src) {
for (int i = 0; i < countLevels; ++i) {
width >>= 1;
height >>= 1;
- rowBytes = SkToU32(SkBitmap::ComputeRowBytes(config, width));
+ rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width));
levels[i].fPixels = addr;
levels[i].fWidth = width;
@@ -189,8 +189,7 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src) {
levels[i].fScale = (float)width / src.width();
SkBitmap dstBM;
- dstBM.setConfig(config, width, height, rowBytes);
- dstBM.setPixels(addr);
+ dstBM.installPixels(SkImageInfo::Make(width, height, ct, at), addr, rowBytes);
srcBM.lockPixels();
for (int y = 0; y < height; y++) {
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 88894d13ab..a3ae8ae9b9 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -276,7 +276,7 @@ bool SkReadBuffer::readBitmap(SkBitmap* bitmap) {
}
}
// Could not read the SkBitmap. Use a placeholder bitmap.
- bitmap->setConfig(SkImageInfo::MakeUnknown(width, height));
+ bitmap->setInfo(SkImageInfo::MakeUnknown(width, height));
return false;
}
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index fee1ff7908..3e20bf69ed 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -584,7 +584,6 @@ static void generateMask(const SkMask& mask, const SkPath& path,
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
-SkIntToScalar(mask.fBounds.fTop));
- SkBitmap::Config config = SkBitmap::kA8_Config;
paint.setAntiAlias(SkMask::kBW_Format != mask.fFormat);
switch (mask.fFormat) {
case SkMask::kBW_Format:
@@ -608,18 +607,17 @@ static void generateMask(const SkMask& mask, const SkPath& path,
SkRasterClip clip;
clip.setRect(SkIRect::MakeWH(dstW, dstH));
+ const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
SkBitmap bm;
- bm.setConfig(config, dstW, dstH, dstRB);
if (0 == dstRB) {
- if (!bm.allocPixels()) {
+ if (!bm.allocPixels(info)) {
// can't allocate offscreen, so empty the mask and return
sk_bzero(mask.fImage, mask.computeImageSize());
return;
}
- bm.lockPixels();
} else {
- bm.setPixels(mask.fImage);
+ bm.installPixels(info, mask.fImage, dstRB);
}
sk_bzero(bm.getPixels(), bm.getSafeSize());
diff --git a/src/core/SkValidationUtils.h b/src/core/SkValidationUtils.h
index 683da29c18..e9e59866ca 100644
--- a/src/core/SkValidationUtils.h
+++ b/src/core/SkValidationUtils.h
@@ -23,12 +23,6 @@ static inline bool SkIsValidMode(SkXfermode::Mode mode) {
return (mode >= 0) && (mode <= SkXfermode::kLastMode);
}
-/** Returns true if config's value is in the SkBitmap::Config enum.
- */
-static inline bool SkIsValidConfig(SkBitmap::Config config) {
- return (config >= 0) && (config <= static_cast<int>(SkBitmap::kConfigCount));
-}
-
/** Returns true if the rect's dimensions are between 0 and SK_MaxS32
*/
static inline bool SkIsValidIRect(const SkIRect& rect) {