eliminate code related to SkBitmap::Config

BUG=skia:
R=reed@google.com, mike@reedtribe.org

Author: reed@chromium.org

Review URL: https://codereview.chromium.org/483593002
This commit is contained in:
reed 2014-08-18 08:13:02 -07:00 committed by Commit bot
parent ad77e55cc0
commit bbe7a2ad32
7 changed files with 0 additions and 194 deletions

View File

@ -38,29 +38,6 @@ class SK_API SkBitmap {
public:
class SK_API Allocator;
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
enum Config {
kNo_Config, //!< bitmap has not been configured
kA8_Config, //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
kIndex8_Config, //!< 8-bits per pixel, using SkColorTable to specify the colors
kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
kARGB_4444_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
kARGB_8888_Config, //!< 32-bits per pixel, (see SkColorPriv.h for packing)
};
// do not add this to the Config enum, otherwise the compiler will let us
// pass this as a valid parameter for Config.
enum {
kConfigCount = kARGB_8888_Config + 1
};
/** Return the config for the bitmap. */
Config config() const;
SK_ATTR_DEPRECATED("use config()")
Config getConfig() const { return this->config(); }
#endif
/**
* Default construct creates a bitmap with zero width and height, and no pixels.
* Its colortype is set to kUnknown_SkColorType.
@ -865,13 +842,4 @@ inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const {
return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
}
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
///////////////////////////////////////////////////////////////////////////////
//
// Helpers until we can fully deprecate SkBitmap::Config
//
SK_API SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType);
SK_API SkColorType SkBitmapConfigToColorType(SkBitmap::Config);
#endif
#endif

View File

@ -160,52 +160,6 @@ public:
Chooser* setChooser(Chooser*);
#endif
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
/**
* Optional table describing the caller's preferred config based on
* information about the src data. Each field should be set to the
* preferred config for a src described in the name of the field. The
* src attributes are described in terms of depth (8-index,
* 8bit-grayscale, or 8-bits/component) and whether there is per-pixel
* alpha (does not apply to grayscale). If the caller has no preference
* for a particular src type, its slot should be set to kNo_Config.
*
* NOTE ABOUT PREFERRED CONFIGS:
* If a config is preferred, either using a pref table or as a parameter
* to some flavor of decode, it is still at the discretion of the codec
* as to what output config is actually returned, as it may not be able
* to support the caller's preference.
*
* If a bitmap is decoded into SkBitmap::A8_Config, the resulting bitmap
* will either be a conversion of the grayscale in the case of a
* grayscale source or the alpha channel in the case of a source with
* an alpha channel.
*/
struct PrefConfigTable {
SkBitmap::Config fPrefFor_8Index_NoAlpha_src;
SkBitmap::Config fPrefFor_8Index_YesAlpha_src;
SkBitmap::Config fPrefFor_8Gray_src;
SkBitmap::Config fPrefFor_8bpc_NoAlpha_src;
SkBitmap::Config fPrefFor_8bpc_YesAlpha_src;
};
/**
* Set an optional table for specifying the caller's preferred config
* based on information about the src data.
*
* The default is no preference, which will assume the config set by
* decode is preferred.
*/
void setPrefConfigTable(const PrefConfigTable&);
/**
* Do not use a PrefConfigTable to determine the output config. This
* is the default, so there is no need to call unless a PrefConfigTable
* was previously set.
*/
void resetPrefConfigTable() { fUsePrefTable = false; }
#endif
/**
* By default, the codec will try to comply with the "pref" colortype
* that is passed to decode() or decodeSubset(). However, this can be called
@ -467,10 +421,6 @@ private:
SkBitmap::Allocator* fAllocator;
int fSampleSize;
SkColorType fDefaultPref; // use if fUsePrefTable is false
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
PrefConfigTable fPrefTable; // use if fUsePrefTable is true
bool fUsePrefTable;
#endif
bool fPreserveSrcDepth;
bool fDitherImage;
bool fSkipWritingZeroes;

View File

@ -44,13 +44,6 @@ GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkXfermode::kIDA_Coeff);
#include "SkColorPriv.h"
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
/**
* Convert the SkBitmap::Config to the corresponding PixelConfig, or
* kUnknown_PixelConfig if the conversion cannot be done.
*/
GrPixelConfig SkBitmapConfig2GrPixelConfig(SkBitmap::Config);
#endif
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType);
static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {

View File

@ -91,12 +91,6 @@ void SkBitmap::reset() {
sk_bzero(this, sizeof(*this));
}
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
SkBitmap::Config SkBitmap::config() const {
return SkColorTypeToBitmapConfig(fInfo.colorType());
}
#endif
void SkBitmap::getBounds(SkRect* bounds) const {
SkASSERT(bounds);
bounds->set(0, 0,

View File

@ -428,26 +428,6 @@ void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) {
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
GrPixelConfig SkBitmapConfig2GrPixelConfig(SkBitmap::Config config) {
switch (config) {
case SkBitmap::kA8_Config:
return kAlpha_8_GrPixelConfig;
case SkBitmap::kIndex8_Config:
return kIndex_8_GrPixelConfig;
case SkBitmap::kRGB_565_Config:
return kRGB_565_GrPixelConfig;
case SkBitmap::kARGB_4444_Config:
return kRGBA_4444_GrPixelConfig;
case SkBitmap::kARGB_8888_Config:
return kSkia8888_GrPixelConfig;
default:
// kNo_Config, kA1_Config missing
return kUnknown_GrPixelConfig;
}
}
#endif
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
// alpha info, that will be considered.
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) {

View File

@ -9,45 +9,6 @@
#include "SkCanvas.h"
#include "SkPicture.h"
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) {
switch (colorType) {
case kAlpha_8_SkColorType:
return SkBitmap::kA8_Config;
case kARGB_4444_SkColorType:
return SkBitmap::kARGB_4444_Config;
case kRGB_565_SkColorType:
return SkBitmap::kRGB_565_Config;
case kN32_SkColorType:
return SkBitmap::kARGB_8888_Config;
case kIndex_8_SkColorType:
return SkBitmap::kIndex8_Config;
default:
// break for unsupported colortypes
break;
}
return SkBitmap::kNo_Config;
}
SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) {
static const SkColorType gCT[] = {
kUnknown_SkColorType, // kNo_Config
kAlpha_8_SkColorType, // kA8_Config
kIndex_8_SkColorType, // kIndex8_Config
kRGB_565_SkColorType, // kRGB_565_Config
kARGB_4444_SkColorType, // kARGB_4444_Config
kN32_SkColorType, // kARGB_8888_Config
};
SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT));
return gCT[config];
}
#endif
SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
const SkImageInfo info = bm.info();
if (kUnknown_SkColorType == info.colorType()) {

View File

@ -24,9 +24,6 @@ SkImageDecoder::SkImageDecoder()
, fDefaultPref(kUnknown_SkColorType)
, fPreserveSrcDepth(false)
, fDitherImage(true)
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
, fUsePrefTable(false)
#endif
, fSkipWritingZeroes(false)
, fPreferQualityOverSpeed(false)
, fRequireUnpremultipliedColors(false) {
@ -50,13 +47,6 @@ void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) {
#endif
other->setAllocator(fAllocator);
other->setSampleSize(fSampleSize);
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
if (fUsePrefTable) {
other->setPrefConfigTable(fPrefTable);
} else {
other->fDefaultPref = fDefaultPref;
}
#endif
other->setPreserveSrcDepth(fPreserveSrcDepth);
other->setDitherImage(fDitherImage);
other->setSkipWritingZeroes(fSkipWritingZeroes);
@ -148,38 +138,8 @@ bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap,
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
fUsePrefTable = true;
fPrefTable = prefTable;
}
#endif
// TODO: use colortype in fPrefTable, fDefaultPref so we can stop using SkBitmapConfigToColorType()
//
SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha) const {
SkColorType ct = fDefaultPref;
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG
if (fUsePrefTable) {
// Until we kill or change the PrefTable, we have to go into Config land for a moment.
SkBitmap::Config config = SkBitmap::kNo_Config;
switch (srcDepth) {
case kIndex_SrcDepth:
config = srcHasAlpha ? fPrefTable.fPrefFor_8Index_YesAlpha_src
: fPrefTable.fPrefFor_8Index_NoAlpha_src;
break;
case k8BitGray_SrcDepth:
config = fPrefTable.fPrefFor_8Gray_src;
break;
case k32Bit_SrcDepth:
config = srcHasAlpha ? fPrefTable.fPrefFor_8bpc_YesAlpha_src
: fPrefTable.fPrefFor_8bpc_NoAlpha_src;
break;
}
// now return to SkColorType land
ct = SkBitmapConfigToColorType(config);
}
#endif
if (fPreserveSrcDepth) {
switch (srcDepth) {
case kIndex_SrcDepth: