Merge "SkBitmap::Config is deprecated, use SkColorType"
This commit is contained in:
@@ -316,7 +316,7 @@ static int getPremulBitmapCreateFlags(bool isMutable) {
|
||||
static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors,
|
||||
jint offset, jint stride, jint width, jint height,
|
||||
jint configHandle, jboolean isMutable) {
|
||||
SkColorType colorType = SkBitmapConfigToColorType(static_cast<SkBitmap::Config>(configHandle));
|
||||
SkColorType colorType = GraphicsJNI::legacyBitmapConfigToColorType(configHandle);
|
||||
if (NULL != jColors) {
|
||||
size_t n = env->GetArrayLength(jColors);
|
||||
if (n < SkAbs32(stride) * (size_t)height) {
|
||||
@@ -350,11 +350,11 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors,
|
||||
static jobject Bitmap_copy(JNIEnv* env, jobject, jlong srcHandle,
|
||||
jint dstConfigHandle, jboolean isMutable) {
|
||||
const SkBitmap* src = reinterpret_cast<SkBitmap*>(srcHandle);
|
||||
SkBitmap::Config dstConfig = static_cast<SkBitmap::Config>(dstConfigHandle);
|
||||
SkColorType dstCT = GraphicsJNI::legacyBitmapConfigToColorType(dstConfigHandle);
|
||||
SkBitmap result;
|
||||
JavaPixelAllocator allocator(env);
|
||||
|
||||
if (!src->copyTo(&result, SkBitmapConfigToColorType(dstConfig), &allocator)) {
|
||||
if (!src->copyTo(&result, dstCT, &allocator)) {
|
||||
return NULL;
|
||||
}
|
||||
return GraphicsJNI::createBitmap(env, new SkBitmap(result), allocator.getStorageObj(),
|
||||
@@ -389,8 +389,7 @@ static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jlong bitmapHandle,
|
||||
jint width, jint height, jint configHandle, jint allocSize,
|
||||
jboolean requestPremul) {
|
||||
SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
|
||||
SkBitmap::Config config = static_cast<SkBitmap::Config>(configHandle);
|
||||
SkColorType colorType = SkBitmapConfigToColorType(config);
|
||||
SkColorType colorType = GraphicsJNI::legacyBitmapConfigToColorType(configHandle);
|
||||
|
||||
// ARGB_4444 is a deprecated format, convert automatically to 8888
|
||||
if (colorType == kARGB_4444_SkColorType) {
|
||||
@@ -494,7 +493,7 @@ static jint Bitmap_rowBytes(JNIEnv* env, jobject, jlong bitmapHandle) {
|
||||
|
||||
static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) {
|
||||
SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
|
||||
return static_cast<jint>(bitmap->config());
|
||||
return GraphicsJNI::colorTypeToLegacyBitmapConfig(bitmap->colorType());
|
||||
}
|
||||
|
||||
static jint Bitmap_getGenerationId(JNIEnv* env, jobject, jlong bitmapHandle) {
|
||||
@@ -810,7 +809,7 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,
|
||||
const SkBitmap* bm1 = reinterpret_cast<SkBitmap*>(bm1Handle);
|
||||
if (bm0->width() != bm1->width() ||
|
||||
bm0->height() != bm1->height() ||
|
||||
bm0->config() != bm1->config()) {
|
||||
bm0->colorType() != bm1->colorType()) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
@@ -822,7 +821,7 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if (bm0->config() == SkBitmap::kIndex8_Config) {
|
||||
if (bm0->colorType() == kIndex_8_SkColorType) {
|
||||
SkColorTable* ct0 = bm0->getColorTable();
|
||||
SkColorTable* ct1 = bm1->getColorTable();
|
||||
if (NULL == ct0 || NULL == ct1) {
|
||||
|
||||
@@ -291,6 +291,54 @@ void GraphicsJNI::point_to_jpointf(const SkPoint& r, JNIEnv* env, jobject obj)
|
||||
env->SetFloatField(obj, gPointF_yFieldID, SkScalarToFloat(r.fY));
|
||||
}
|
||||
|
||||
// This enum must keep these int values, to match the int values
|
||||
// in the java Bitmap.Config enum.
|
||||
enum LegacyBitmapConfig {
|
||||
kNo_LegacyBitmapConfig = 0,
|
||||
kA8_LegacyBitmapConfig = 1,
|
||||
kIndex8_LegacyBitmapConfig = 2,
|
||||
kRGB_565_LegacyBitmapConfig = 3,
|
||||
kARGB_4444_LegacyBitmapConfig = 4,
|
||||
kARGB_8888_LegacyBitmapConfig = 5,
|
||||
|
||||
kLastEnum_LegacyBitmapConfig = kARGB_8888_LegacyBitmapConfig
|
||||
};
|
||||
|
||||
jint GraphicsJNI::colorTypeToLegacyBitmapConfig(SkColorType colorType) {
|
||||
switch (colorType) {
|
||||
case kN32_SkColorType:
|
||||
return kARGB_8888_LegacyBitmapConfig;
|
||||
case kARGB_4444_SkColorType:
|
||||
return kARGB_4444_LegacyBitmapConfig;
|
||||
case kRGB_565_SkColorType:
|
||||
return kRGB_565_LegacyBitmapConfig;
|
||||
case kIndex_8_SkColorType:
|
||||
return kIndex8_LegacyBitmapConfig;
|
||||
case kAlpha_8_SkColorType:
|
||||
return kA8_LegacyBitmapConfig;
|
||||
case kUnknown_SkColorType:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return kNo_LegacyBitmapConfig;
|
||||
}
|
||||
|
||||
SkColorType GraphicsJNI::legacyBitmapConfigToColorType(jint legacyConfig) {
|
||||
const uint8_t gConfig2ColorType[] = {
|
||||
kUnknown_SkColorType,
|
||||
kAlpha_8_SkColorType,
|
||||
kIndex_8_SkColorType,
|
||||
kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType,
|
||||
kN32_SkColorType
|
||||
};
|
||||
|
||||
if (legacyConfig < 0 || legacyConfig > kLastEnum_LegacyBitmapConfig) {
|
||||
legacyConfig = kNo_LegacyBitmapConfig;
|
||||
}
|
||||
return static_cast<SkColorType>(gConfig2ColorType[legacyConfig]);
|
||||
}
|
||||
|
||||
SkBitmap* GraphicsJNI::getNativeBitmap(JNIEnv* env, jobject bitmap) {
|
||||
SkASSERT(env);
|
||||
SkASSERT(bitmap);
|
||||
@@ -308,10 +356,7 @@ SkColorType GraphicsJNI::getNativeBitmapColorType(JNIEnv* env, jobject jconfig)
|
||||
}
|
||||
SkASSERT(env->IsInstanceOf(jconfig, gBitmapConfig_class));
|
||||
int c = env->GetIntField(jconfig, gBitmapConfig_nativeInstanceID);
|
||||
if (c < 0 || c >= SkBitmap::kConfigCount) {
|
||||
c = kUnknown_SkColorType;
|
||||
}
|
||||
return SkBitmapConfigToColorType(static_cast<SkBitmap::Config>(c));
|
||||
return legacyBitmapConfigToColorType(c);
|
||||
}
|
||||
|
||||
SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {
|
||||
|
||||
@@ -58,6 +58,14 @@ public:
|
||||
// ref to its SkRasterizer* (or NULL).
|
||||
static SkRasterizer* refNativeRasterizer(jlong rasterizerHandle);
|
||||
|
||||
/*
|
||||
* LegacyBitmapConfig is the old enum in Skia that matched the enum int values
|
||||
* in Bitmap.Config. Skia no longer supports this config, but has replaced it
|
||||
* with SkColorType. These routines convert between the two.
|
||||
*/
|
||||
static SkColorType legacyBitmapConfigToColorType(jint legacyConfig);
|
||||
static jint colorTypeToLegacyBitmapConfig(SkColorType colorType);
|
||||
|
||||
/** Return the corresponding native colorType from the java Config enum,
|
||||
or kUnknown_SkColorType if the java object is null.
|
||||
*/
|
||||
|
||||
@@ -38,18 +38,18 @@
|
||||
#include <utils/Log.h>
|
||||
|
||||
static bool getColor(const SkBitmap& bitmap, int x, int y, SkColor* c) {
|
||||
switch (bitmap.config()) {
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
switch (bitmap.colorType()) {
|
||||
case kN32_SkColorType:
|
||||
*c = SkUnPreMultiply::PMColorToColor(*bitmap.getAddr32(x, y));
|
||||
break;
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
*c = SkPixel16ToPixel32(*bitmap.getAddr16(x, y));
|
||||
break;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
*c = SkUnPreMultiply::PMColorToColor(
|
||||
SkPixel4444ToPixel32(*bitmap.getAddr16(x, y)));
|
||||
break;
|
||||
case SkBitmap::kIndex8_Config: {
|
||||
case kIndex_8_SkColorType: {
|
||||
SkColorTable* ctable = bitmap.getColorTable();
|
||||
*c = SkUnPreMultiply::PMColorToColor(
|
||||
(*ctable)[*bitmap.getAddr8(x, y)]);
|
||||
|
||||
@@ -562,18 +562,18 @@ void setTracingLevel(JNIEnv *env, jclass clazz, jint level)
|
||||
setGLDebugLevel(level);
|
||||
}
|
||||
|
||||
static int checkFormat(SkBitmap::Config config, int format, int type)
|
||||
static int checkFormat(SkColorType colorType, int format, int type)
|
||||
{
|
||||
switch(config) {
|
||||
case SkBitmap::kIndex8_Config:
|
||||
switch(colorType) {
|
||||
case kIndex_8_SkColorType:
|
||||
if (format == GL_PALETTE8_RGBA8_OES)
|
||||
return 0;
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
case SkBitmap::kA8_Config:
|
||||
case kN32_SkColorType:
|
||||
case kAlpha_8_SkColorType:
|
||||
if (type == GL_UNSIGNED_BYTE)
|
||||
return 0;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
case kRGB_565_SkColorType:
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
case GL_UNSIGNED_SHORT_5_6_5:
|
||||
@@ -590,36 +590,36 @@ static int checkFormat(SkBitmap::Config config, int format, int type)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int getInternalFormat(SkBitmap::Config config)
|
||||
static int getInternalFormat(SkColorType colorType)
|
||||
{
|
||||
switch(config) {
|
||||
case SkBitmap::kA8_Config:
|
||||
switch(colorType) {
|
||||
case kAlpha_8_SkColorType:
|
||||
return GL_ALPHA;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
return GL_RGBA;
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
case kN32_SkColorType:
|
||||
return GL_RGBA;
|
||||
case SkBitmap::kIndex8_Config:
|
||||
case kIndex_8_SkColorType:
|
||||
return GL_PALETTE8_RGBA8_OES;
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
return GL_RGB;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int getType(SkBitmap::Config config)
|
||||
static int getType(SkColorType colorType)
|
||||
{
|
||||
switch(config) {
|
||||
case SkBitmap::kA8_Config:
|
||||
switch(colorType) {
|
||||
case kAlpha_8_SkColorType:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
return GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
case kN32_SkColorType:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case SkBitmap::kIndex8_Config:
|
||||
case kIndex_8_SkColorType:
|
||||
return -1; // No type for compressed data.
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
return GL_UNSIGNED_SHORT_5_6_5;
|
||||
default:
|
||||
return -1;
|
||||
@@ -631,9 +631,7 @@ static jint util_getInternalFormat(JNIEnv *env, jclass clazz,
|
||||
{
|
||||
SkBitmap const * nativeBitmap =
|
||||
(SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
|
||||
const SkBitmap& bitmap(*nativeBitmap);
|
||||
SkBitmap::Config config = bitmap.config();
|
||||
return getInternalFormat(config);
|
||||
return getInternalFormat(nativeBitmap->colorType());
|
||||
}
|
||||
|
||||
static jint util_getType(JNIEnv *env, jclass clazz,
|
||||
@@ -641,9 +639,7 @@ static jint util_getType(JNIEnv *env, jclass clazz,
|
||||
{
|
||||
SkBitmap const * nativeBitmap =
|
||||
(SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
|
||||
const SkBitmap& bitmap(*nativeBitmap);
|
||||
SkBitmap::Config config = bitmap.config();
|
||||
return getType(config);
|
||||
return getType(nativeBitmap->colorType());
|
||||
}
|
||||
|
||||
static jint util_texImage2D(JNIEnv *env, jclass clazz,
|
||||
@@ -653,14 +649,14 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz,
|
||||
SkBitmap const * nativeBitmap =
|
||||
(SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
|
||||
const SkBitmap& bitmap(*nativeBitmap);
|
||||
SkBitmap::Config config = bitmap.config();
|
||||
SkColorType colorType = bitmap.colorType();
|
||||
if (internalformat < 0) {
|
||||
internalformat = getInternalFormat(config);
|
||||
internalformat = getInternalFormat(colorType);
|
||||
}
|
||||
if (type < 0) {
|
||||
type = getType(config);
|
||||
type = getType(colorType);
|
||||
}
|
||||
int err = checkFormat(config, internalformat, type);
|
||||
int err = checkFormat(colorType, internalformat, type);
|
||||
if (err)
|
||||
return err;
|
||||
bitmap.lockPixels();
|
||||
@@ -702,13 +698,13 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz,
|
||||
SkBitmap const * nativeBitmap =
|
||||
(SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
|
||||
const SkBitmap& bitmap(*nativeBitmap);
|
||||
SkBitmap::Config config = bitmap.config();
|
||||
SkColorType colorType = bitmap.colorType();
|
||||
if (format < 0) {
|
||||
format = getInternalFormat(config);
|
||||
format = getInternalFormat(colorType);
|
||||
if (format == GL_PALETTE8_RGBA8_OES)
|
||||
return -1; // glCompressedTexSubImage2D() not supported
|
||||
}
|
||||
int err = checkFormat(config, format, type);
|
||||
int err = checkFormat(colorType, format, type);
|
||||
if (err)
|
||||
return err;
|
||||
bitmap.lockPixels();
|
||||
|
||||
@@ -257,13 +257,13 @@ static jlong jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject di
|
||||
return reinterpret_cast<jlong>(sur);
|
||||
}
|
||||
|
||||
static PixelFormat convertPixelFormat(SkBitmap::Config format)
|
||||
static PixelFormat convertPixelFormat(SkColorType format)
|
||||
{
|
||||
switch (format) {
|
||||
case SkBitmap::kARGB_8888_Config: return PIXEL_FORMAT_RGBA_8888;
|
||||
case SkBitmap::kARGB_4444_Config: return PIXEL_FORMAT_RGBA_4444;
|
||||
case SkBitmap::kRGB_565_Config: return PIXEL_FORMAT_RGB_565;
|
||||
default: return PIXEL_FORMAT_NONE;
|
||||
case kN32_SkColorType: return PIXEL_FORMAT_RGBA_8888;
|
||||
case kARGB_4444_SkColorType: return PIXEL_FORMAT_RGBA_4444;
|
||||
case kRGB_565_SkColorType: return PIXEL_FORMAT_RGB_565;
|
||||
default: return PIXEL_FORMAT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_
|
||||
pixmap.width = nativeBitmap->width();
|
||||
pixmap.height = nativeBitmap->height();
|
||||
pixmap.stride = nativeBitmap->rowBytes() / nativeBitmap->bytesPerPixel();
|
||||
pixmap.format = convertPixelFormat(nativeBitmap->config());
|
||||
pixmap.format = convertPixelFormat(nativeBitmap->colorType());
|
||||
pixmap.data = (uint8_t*)ref->pixels();
|
||||
|
||||
base = beginNativeAttribList(_env, attrib_list);
|
||||
|
||||
@@ -732,7 +732,7 @@ public:
|
||||
deferInfo.mergeable = state.mMatrix.isSimple() && state.mMatrix.positiveScale() &&
|
||||
!state.mClipSideFlags &&
|
||||
OpenGLRenderer::getXfermodeDirect(mPaint) == SkXfermode::kSrcOver_Mode &&
|
||||
(mBitmap->config() != SkBitmap::kA8_Config);
|
||||
(mBitmap->colorType() != kAlpha_8_SkColorType);
|
||||
}
|
||||
|
||||
const SkBitmap* bitmap() { return mBitmap; }
|
||||
|
||||
@@ -383,20 +383,20 @@ bool LayerRenderer::copyLayer(RenderState& renderState, Layer* layer, SkBitmap*
|
||||
GLenum error = GL_NO_ERROR;
|
||||
bool status = false;
|
||||
|
||||
switch (bitmap->config()) {
|
||||
case SkBitmap::kA8_Config:
|
||||
switch (bitmap->colorType()) {
|
||||
case kAlpha_8_SkColorType:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
break;
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
case kN32_SkColorType:
|
||||
default:
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
|
||||
@@ -1957,7 +1957,7 @@ status_t OpenGLRenderer::drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry*
|
||||
|
||||
const float x = (int) floorf(bounds.left + 0.5f);
|
||||
const float y = (int) floorf(bounds.top + 0.5f);
|
||||
if (CC_UNLIKELY(bitmap->config() == SkBitmap::kA8_Config)) {
|
||||
if (CC_UNLIKELY(bitmap->colorType() == kAlpha_8_SkColorType)) {
|
||||
drawAlpha8TextureMesh(x, y, x + bounds.getWidth(), y + bounds.getHeight(),
|
||||
texture->id, paint, &vertices[0].x, &vertices[0].u,
|
||||
GL_TRIANGLES, bitmapCount * 6, true,
|
||||
@@ -1986,7 +1986,7 @@ status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, float left, float to
|
||||
if (!texture) return DrawGlInfo::kStatusDone;
|
||||
const AutoTexture autoCleanup(texture);
|
||||
|
||||
if (CC_UNLIKELY(bitmap->config() == SkBitmap::kA8_Config)) {
|
||||
if (CC_UNLIKELY(bitmap->colorType() == kAlpha_8_SkColorType)) {
|
||||
drawAlphaBitmap(texture, left, top, paint);
|
||||
} else {
|
||||
drawTextureRect(left, top, right, bottom, texture, paint);
|
||||
@@ -2014,7 +2014,7 @@ status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, const SkMatrix& matr
|
||||
// to the vertex shader. The save/restore is a bit overkill.
|
||||
save(SkCanvas::kMatrix_SaveFlag);
|
||||
concatMatrix(matrix);
|
||||
if (CC_UNLIKELY(bitmap->config() == SkBitmap::kA8_Config)) {
|
||||
if (CC_UNLIKELY(bitmap->colorType() == kAlpha_8_SkColorType)) {
|
||||
drawAlphaBitmap(texture, 0.0f, 0.0f, paint);
|
||||
} else {
|
||||
drawTextureRect(0.0f, 0.0f, bitmap->width(), bitmap->height(), texture, paint);
|
||||
@@ -2037,7 +2037,7 @@ status_t OpenGLRenderer::drawBitmapData(const SkBitmap* bitmap, float left, floa
|
||||
Texture* texture = mCaches.textureCache.getTransient(bitmap);
|
||||
const AutoTexture autoCleanup(texture);
|
||||
|
||||
if (CC_UNLIKELY(bitmap->config() == SkBitmap::kA8_Config)) {
|
||||
if (CC_UNLIKELY(bitmap->colorType() == kAlpha_8_SkColorType)) {
|
||||
drawAlphaBitmap(texture, left, top, paint);
|
||||
} else {
|
||||
drawTextureRect(left, top, right, bottom, texture, paint);
|
||||
@@ -2232,7 +2232,7 @@ status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap,
|
||||
dstBottom = srcBottom - srcTop;
|
||||
}
|
||||
|
||||
if (CC_UNLIKELY(bitmap->config() == SkBitmap::kA8_Config)) {
|
||||
if (CC_UNLIKELY(bitmap->colorType() == kAlpha_8_SkColorType)) {
|
||||
drawAlpha8TextureMesh(dstLeft, dstTop, dstRight, dstBottom,
|
||||
texture->id, paint,
|
||||
&mMeshVertices[0].x, &mMeshVertices[0].u,
|
||||
|
||||
@@ -285,20 +285,20 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo
|
||||
|
||||
Caches::getInstance().bindTexture(texture->id);
|
||||
|
||||
switch (bitmap->config()) {
|
||||
case SkBitmap::kA8_Config:
|
||||
switch (bitmap->colorType()) {
|
||||
case kAlpha_8_SkColorType:
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
uploadToTexture(resize, GL_ALPHA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
|
||||
texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
|
||||
texture->blend = true;
|
||||
break;
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
|
||||
uploadToTexture(resize, GL_RGB, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
|
||||
texture->width, texture->height, GL_UNSIGNED_SHORT_5_6_5, bitmap->getPixels());
|
||||
texture->blend = false;
|
||||
break;
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
case kN32_SkColorType:
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
|
||||
uploadToTexture(resize, GL_RGBA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
|
||||
texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
|
||||
@@ -306,14 +306,14 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo
|
||||
// decoding happened
|
||||
texture->blend = !bitmap->isOpaque();
|
||||
break;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case SkBitmap::kIndex8_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
case kIndex_8_SkColorType:
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
|
||||
uploadLoFiTexture(resize, bitmap, texture->width, texture->height);
|
||||
texture->blend = !bitmap->isOpaque();
|
||||
break;
|
||||
default:
|
||||
ALOGW("Unsupported bitmap config: %d", bitmap->config());
|
||||
ALOGW("Unsupported bitmap colorType: %d", bitmap->colorType());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,17 +34,17 @@ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
|
||||
info->stride = bm->rowBytes();
|
||||
info->flags = 0;
|
||||
|
||||
switch (bm->config()) {
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
switch (bm->colorType()) {
|
||||
case kN32_SkColorType:
|
||||
info->format = ANDROID_BITMAP_FORMAT_RGBA_8888;
|
||||
break;
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
case kRGB_565_SkColorType:
|
||||
info->format = ANDROID_BITMAP_FORMAT_RGB_565;
|
||||
break;
|
||||
case SkBitmap::kARGB_4444_Config:
|
||||
case kARGB_4444_SkColorType:
|
||||
info->format = ANDROID_BITMAP_FORMAT_RGBA_4444;
|
||||
break;
|
||||
case SkBitmap::kA8_Config:
|
||||
case kAlpha_8_SkColorType:
|
||||
info->format = ANDROID_BITMAP_FORMAT_A_8;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user