SkBitmap::Config is deprecated, use SkColorType

Change-Id: Ida181d2aac760072cf2d01409edac37699dea216
This commit is contained in:
Mike Reed
2014-07-07 18:06:18 -04:00
parent 95f621a1a4
commit 42a1d08df7
6 changed files with 28 additions and 29 deletions

View File

@@ -108,7 +108,7 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
return NO_INIT;
SkBitmap bitmap;
SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
&bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode);
&bitmap, kUnknown_SkColorType, SkImageDecoder::kDecodePixels_Mode);
asset->close();
delete asset;
@@ -127,20 +127,20 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
glGenTextures(1, &texture->name);
glBindTexture(GL_TEXTURE_2D, texture->name);
switch (bitmap.config()) {
case SkBitmap::kA8_Config:
switch (bitmap.colorType()) {
case kAlpha_8_SkColorType:
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
GL_UNSIGNED_BYTE, p);
break;
case SkBitmap::kARGB_4444_Config:
case kARGB_4444_SkColorType:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
GL_UNSIGNED_SHORT_4_4_4_4, p);
break;
case SkBitmap::kARGB_8888_Config:
case kN32_SkColorType:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
GL_UNSIGNED_BYTE, p);
break;
case SkBitmap::kRGB_565_Config:
case kRGB_565_SkColorType:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, p);
break;
@@ -166,7 +166,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
if (codec) {
codec->setDitherImage(false);
codec->decode(&stream, &bitmap,
SkBitmap::kARGB_8888_Config,
kN32_SkColorType,
SkImageDecoder::kDecodePixels_Mode);
delete codec;
}
@@ -190,8 +190,8 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
if (tw < w) tw <<= 1;
if (th < h) th <<= 1;
switch (bitmap.config()) {
case SkBitmap::kARGB_8888_Config:
switch (bitmap.colorType()) {
case kN32_SkColorType:
if (tw != w || th != h) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA,
GL_UNSIGNED_BYTE, 0);
@@ -203,7 +203,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame)
}
break;
case SkBitmap::kRGB_565_Config:
case kRGB_565_SkColorType:
if (tw != w || th != h) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0, GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, 0);

View File

@@ -201,7 +201,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
int sampleSize = 1;
SkImageDecoder::Mode decodeMode = SkImageDecoder::kDecodePixels_Mode;
SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;
SkColorType prefColorType = kN32_SkColorType;
bool doDither = true;
bool isMutable = false;
@@ -223,7 +223,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
env->SetObjectField(options, gOptions_mimeFieldID, 0);
jobject jconfig = env->GetObjectField(options, gOptions_configFieldID);
prefConfig = GraphicsJNI::getNativeBitmapConfig(env, jconfig);
prefColorType = GraphicsJNI::getNativeBitmapColorType(env, jconfig);
isMutable = env->GetBooleanField(options, gOptions_mutableFieldID);
doDither = env->GetBooleanField(options, gOptions_ditherFieldID);
preferQualityOverSpeed = env->GetBooleanField(options,
@@ -305,7 +305,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
}
SkBitmap decodingBitmap;
if (!decoder->decode(stream, &decodingBitmap, prefConfig, decodeMode)) {
if (!decoder->decode(stream, &decodingBitmap, prefColorType, decodeMode)) {
return nullObjectReturn("decoder->decode returned false");
}

View File

@@ -60,7 +60,7 @@ public:
}
bool decodeRegion(SkBitmap* bitmap, const SkIRect& rect,
SkBitmap::Config pref, int sampleSize) {
SkColorType pref, int sampleSize) {
fDecoder->setSampleSize(sampleSize);
return fDecoder->decodeSubset(bitmap, rect, pref);
}
@@ -175,7 +175,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
jobject tileBitmap = NULL;
SkImageDecoder *decoder = brd->getDecoder();
int sampleSize = 1;
SkBitmap::Config prefConfig = SkBitmap::kNo_Config;
SkColorType prefColorType = kUnknown_SkColorType;
bool doDither = true;
bool preferQualityOverSpeed = false;
bool requireUnpremultiplied = false;
@@ -188,7 +188,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
env->SetObjectField(options, gOptions_mimeFieldID, 0);
jobject jconfig = env->GetObjectField(options, gOptions_configFieldID);
prefConfig = GraphicsJNI::getNativeBitmapConfig(env, jconfig);
prefColorType = GraphicsJNI::getNativeBitmapColorType(env, jconfig);
doDither = env->GetBooleanField(options, gOptions_ditherFieldID);
preferQualityOverSpeed = env->GetBooleanField(options,
gOptions_preferQualityOverSpeedFieldID);
@@ -226,7 +226,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
adb.reset(bitmap);
}
if (!brd->decodeRegion(bitmap, region, prefConfig, sampleSize)) {
if (!brd->decodeRegion(bitmap, region, prefColorType, sampleSize)) {
return nullObjectReturn("decoder->decodeRegion returned false");
}

View File

@@ -301,18 +301,17 @@ SkBitmap* GraphicsJNI::getNativeBitmap(JNIEnv* env, jobject bitmap) {
return b;
}
SkBitmap::Config GraphicsJNI::getNativeBitmapConfig(JNIEnv* env,
jobject jconfig) {
SkColorType GraphicsJNI::getNativeBitmapColorType(JNIEnv* env, jobject jconfig) {
SkASSERT(env);
if (NULL == jconfig) {
return SkBitmap::kNo_Config;
return kUnknown_SkColorType;
}
SkASSERT(env->IsInstanceOf(jconfig, gBitmapConfig_class));
int c = env->GetIntField(jconfig, gBitmapConfig_nativeInstanceID);
if (c < 0 || c >= SkBitmap::kConfigCount) {
c = SkBitmap::kNo_Config;
c = kUnknown_SkColorType;
}
return static_cast<SkBitmap::Config>(c);
return SkBitmapConfigToColorType(static_cast<SkBitmap::Config>(c));
}
SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {

View File

@@ -58,10 +58,10 @@ public:
// ref to its SkRasterizer* (or NULL).
static SkRasterizer* refNativeRasterizer(jlong rasterizerHandle);
/** Return the corresponding native config from the java Config enum,
or kNo_Config if the java object is null.
/** Return the corresponding native colorType from the java Config enum,
or kUnknown_SkColorType if the java object is null.
*/
static SkBitmap::Config getNativeBitmapConfig(JNIEnv*, jobject jconfig);
static SkColorType getNativeBitmapColorType(JNIEnv*, jobject jconfig);
/** Create a java Bitmap object given the native bitmap (required) and optional
storage array (may be null).

View File

@@ -52,11 +52,11 @@ static int64_t getNowUs() {
int testDecodeBounds(SkImageDecoder* decoder, SkStream* stream,
SkBitmap* bitmap) {
int64_t startTime = getNowUs();
SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;
SkColorType prefColorType = kN32_SkColorType;
SkImageDecoder::Mode decodeMode = SkImageDecoder::kDecodeBounds_Mode;
// Decode the input stream and then use the bitmap.
if (!decoder->decode(stream, bitmap, prefConfig, decodeMode)) {
if (!decoder->decode(stream, bitmap, prefColorType, decodeMode)) {
return nullObjectReturn("decoder->decode returned false");
} else {
int64_t delay = getNowUs() - startTime;
@@ -69,11 +69,11 @@ int testDecodeBounds(SkImageDecoder* decoder, SkStream* stream,
int testDecodePixels(SkImageDecoder* decoder, SkStream* stream,
SkBitmap* bitmap) {
int64_t startTime = getNowUs();
SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;
SkColorType prefColorType = kN32_SkColorType;
SkImageDecoder::Mode decodeMode = SkImageDecoder::kDecodePixels_Mode;
// Decode the input stream and then use the bitmap.
if (!decoder->decode(stream, bitmap, prefConfig, decodeMode)) {
if (!decoder->decode(stream, bitmap, prefColorType, decodeMode)) {
return nullObjectReturn("decoder->decode returned false");
} else {
int64_t delay = getNowUs() - startTime;