Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: src/pdf/SkPDFImage.cpp

Issue 305133006: use colortype instead of config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/opts/SkBlitMask_opts_arm.cpp ('k') | src/utils/SkBitmapHasher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFImage.cpp
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index f39dc5908502bef96dd70b40cbba248cd82ece61..77fd84eff94d0be5911f5bc67232d81fafe42453 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -27,16 +27,17 @@ static bool skip_compression(SkPDFCatalog* catalog) {
static size_t get_uncompressed_size(const SkBitmap& bitmap,
const SkIRect& srcRect) {
- switch (bitmap.config()) {
- case SkBitmap::kIndex8_Config:
+ switch (bitmap.colorType()) {
+ case kIndex_8_SkColorType:
return srcRect.width() * srcRect.height();
- case SkBitmap::kARGB_4444_Config:
+ case kARGB_4444_SkColorType:
return ((srcRect.width() * 3 + 1) / 2) * srcRect.height();
- case SkBitmap::kRGB_565_Config:
+ case kRGB_565_SkColorType:
return srcRect.width() * 3 * srcRect.height();
- case SkBitmap::kARGB_8888_Config:
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType:
return srcRect.width() * 3 * srcRect.height();
- case SkBitmap::kA8_Config:
+ case kAlpha_8_SkColorType:
return 1;
default:
SkASSERT(false);
@@ -208,9 +209,9 @@ static SkStream* create_black_image() {
static SkStream* extract_image_data(const SkBitmap& bitmap,
const SkIRect& srcRect,
bool extractAlpha, bool* isTransparent) {
- SkBitmap::Config config = bitmap.config();
- if (extractAlpha && (config == SkBitmap::kIndex8_Config ||
- config == SkBitmap::kRGB_565_Config)) {
+ SkColorType colorType = bitmap.colorType();
+ if (extractAlpha && (kIndex_8_SkColorType == colorType ||
+ kRGB_565_SkColorType == colorType)) {
if (isTransparent != NULL) {
*isTransparent = false;
}
@@ -221,26 +222,26 @@ static SkStream* extract_image_data(const SkBitmap& bitmap,
SkStream* stream = NULL;
bitmap.lockPixels();
- switch (config) {
- case SkBitmap::kIndex8_Config:
+ switch (colorType) {
+ case kIndex_8_SkColorType:
if (!extractAlpha) {
stream = extract_index8_image(bitmap, srcRect);
}
break;
- case SkBitmap::kARGB_4444_Config:
+ case kARGB_4444_SkColorType:
stream = extract_argb4444_data(bitmap, srcRect, extractAlpha,
&isOpaque, &transparent);
break;
- case SkBitmap::kRGB_565_Config:
+ case kRGB_565_SkColorType:
if (!extractAlpha) {
stream = extract_rgb565_image(bitmap, srcRect);
}
break;
- case SkBitmap::kARGB_8888_Config:
+ case kN32_SkColorType:
stream = extract_argb8888_data(bitmap, srcRect, extractAlpha,
&isOpaque, &transparent);
break;
- case SkBitmap::kA8_Config:
+ case kAlpha_8_SkColorType:
if (!extractAlpha) {
stream = create_black_image();
} else {
@@ -373,14 +374,13 @@ static uint16_t get_argb4444_neighbor_avg_color(const SkBitmap& bitmap,
static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
const SkIRect& srcRect) {
SkBitmap outBitmap;
- outBitmap.setConfig(bitmap.config(), srcRect.width(), srcRect.height());
- outBitmap.allocPixels();
+ outBitmap.allocPixels(bitmap.info().makeWH(srcRect.width(), srcRect.height()));
int dstRow = 0;
outBitmap.lockPixels();
bitmap.lockPixels();
- switch (bitmap.config()) {
- case SkBitmap::kARGB_4444_Config: {
+ switch (bitmap.colorType()) {
+ case kARGB_4444_SkColorType: {
for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
uint16_t* dst = outBitmap.getAddr16(0, dstRow);
uint16_t* src = bitmap.getAddr16(0, y);
@@ -408,7 +408,7 @@ static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
}
break;
}
- case SkBitmap::kARGB_8888_Config: {
+ case kN32_SkColorType: {
for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
uint32_t* dst = outBitmap.getAddr32(0, dstRow);
uint32_t* src = bitmap.getAddr32(0, y);
@@ -440,7 +440,7 @@ static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
const SkIRect& srcRect,
SkPicture::EncodeBitmap encoder) {
- if (bitmap.config() == SkBitmap::kNo_Config) {
+ if (bitmap.colorType() == kUnknown_SkColorType) {
return NULL;
}
@@ -459,9 +459,9 @@ SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
}
SkPDFImage* image;
- SkBitmap::Config config = bitmap.config();
- if (alphaData.get() != NULL && (config == SkBitmap::kARGB_8888_Config ||
- config == SkBitmap::kARGB_4444_Config)) {
+ SkColorType colorType = bitmap.colorType();
+ if (alphaData.get() != NULL && (kN32_SkColorType == colorType ||
+ kARGB_4444_SkColorType == colorType)) {
SkBitmap unpremulBitmap = unpremultiply_bitmap(bitmap, srcRect);
image = SkNEW_ARGS(SkPDFImage, (NULL, unpremulBitmap, false,
SkIRect::MakeWH(srcRect.width(), srcRect.height()),
@@ -518,12 +518,12 @@ SkPDFImage::SkPDFImage(SkStream* stream,
fStreamValid = false;
}
- SkBitmap::Config config = fBitmap.config();
+ SkColorType colorType = fBitmap.colorType();
insertName("Type", "XObject");
insertName("Subtype", "Image");
- bool alphaOnly = (config == SkBitmap::kA8_Config);
+ bool alphaOnly = (kAlpha_8_SkColorType == colorType);
if (!isAlpha && alphaOnly) {
// For alpha only images, we stretch a single pixel of black for
@@ -538,7 +538,7 @@ SkPDFImage::SkPDFImage(SkStream* stream,
if (isAlpha || alphaOnly) {
insertName("ColorSpace", "DeviceGray");
- } else if (config == SkBitmap::kIndex8_Config) {
+ } else if (kIndex_8_SkColorType == colorType) {
SkAutoLockPixels alp(fBitmap);
insert("ColorSpace",
make_indexed_color_space(fBitmap.getColorTable()))->unref();
@@ -547,12 +547,12 @@ SkPDFImage::SkPDFImage(SkStream* stream,
}
int bitsPerComp = 8;
- if (config == SkBitmap::kARGB_4444_Config) {
+ if (kARGB_4444_SkColorType == colorType) {
bitsPerComp = 4;
}
insertInt("BitsPerComponent", bitsPerComp);
- if (config == SkBitmap::kRGB_565_Config) {
+ if (kRGB_565_SkColorType == colorType) {
SkASSERT(!isAlpha);
SkAutoTUnref<SkPDFInt> zeroVal(new SkPDFInt(0));
SkAutoTUnref<SkPDFScalar> scale5Val(
@@ -592,8 +592,6 @@ bool SkPDFImage::populate(SkPDFCatalog* catalog) {
SkBitmap subset;
// Extract subset
if (!fBitmap.extractSubset(&subset, fSrcRect)) {
- // TODO(edisonn) It fails only for kA1_Config, if that is a
- // major concern we will fix it later, so far it is NYI.
return false;
}
size_t pixelRefOffset = 0;
« no previous file with comments | « src/opts/SkBlitMask_opts_arm.cpp ('k') | src/utils/SkBitmapHasher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698