summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-07-25 19:25:10 -0700
committerMathias Agopian <mathias@google.com>2013-07-25 19:25:10 -0700
commit2ca204e4c0ba805c8fa0db79eeac9608d01cf5b4 (patch)
treef5619d2405b25c23a516a899649da4ec395ec980
parent6f7b58917104916ee6afd6f246c251c1d7a2102a (diff)
downloadframeworks_base-2ca204e4c0ba805c8fa0db79eeac9608d01cf5b4.zip
frameworks_base-2ca204e4c0ba805c8fa0db79eeac9608d01cf5b4.tar.gz
frameworks_base-2ca204e4c0ba805c8fa0db79eeac9608d01cf5b4.tar.bz2
get rid of PixelFormatInfo and simplify things
Change-Id: I487d4eef7db0095ace4babf5bb100a8769711257
-rw-r--r--api/current.txt4
-rw-r--r--core/jni/Android.mk1
-rw-r--r--core/jni/AndroidRuntime.cpp2
-rw-r--r--core/jni/android_graphics_PixelFormat.cpp104
-rw-r--r--graphics/java/android/graphics/PixelFormat.java45
5 files changed, 40 insertions, 116 deletions
diff --git a/api/current.txt b/api/current.txt
index 9b5c376..2a3d330 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9474,10 +9474,10 @@ package android.graphics {
ctor public PixelFormat();
method public static boolean formatHasAlpha(int);
method public static void getPixelFormatInfo(int, android.graphics.PixelFormat);
- field public static final int A_8 = 8; // 0x8
+ field public static final deprecated int A_8 = 8; // 0x8
field public static final deprecated int JPEG = 256; // 0x100
field public static final deprecated int LA_88 = 10; // 0xa
- field public static final int L_8 = 9; // 0x9
+ field public static final deprecated int L_8 = 9; // 0x9
field public static final int OPAQUE = -1; // 0xffffffff
field public static final deprecated int RGBA_4444 = 7; // 0x7
field public static final deprecated int RGBA_5551 = 6; // 0x6
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index d60fa18..84c28e6 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -110,7 +110,6 @@ LOCAL_SRC_FILES:= \
android/graphics/Path.cpp \
android/graphics/PathMeasure.cpp \
android/graphics/PathEffect.cpp \
- android_graphics_PixelFormat.cpp \
android/graphics/Picture.cpp \
android/graphics/PorterDuff.cpp \
android/graphics/BitmapRegionDecoder.cpp \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 1299579..71395c7 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -116,7 +116,6 @@ extern int register_android_graphics_Rasterizer(JNIEnv* env);
extern int register_android_graphics_Region(JNIEnv* env);
extern int register_android_graphics_SurfaceTexture(JNIEnv* env);
extern int register_android_graphics_Xfermode(JNIEnv* env);
-extern int register_android_graphics_PixelFormat(JNIEnv* env);
extern int register_android_view_DisplayEventReceiver(JNIEnv* env);
extern int register_android_view_GraphicBuffer(JNIEnv* env);
extern int register_android_view_GLES20DisplayList(JNIEnv* env);
@@ -1124,7 +1123,6 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_os_Parcel),
REG_JNI(register_android_view_DisplayEventReceiver),
REG_JNI(register_android_nio_utils),
- REG_JNI(register_android_graphics_PixelFormat),
REG_JNI(register_android_graphics_Graphics),
REG_JNI(register_android_view_GraphicBuffer),
REG_JNI(register_android_view_GLES20DisplayList),
diff --git a/core/jni/android_graphics_PixelFormat.cpp b/core/jni/android_graphics_PixelFormat.cpp
deleted file mode 100644
index 1fc363b..0000000
--- a/core/jni/android_graphics_PixelFormat.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <assert.h>
-
-#include <ui/PixelFormat.h>
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include <android_runtime/AndroidRuntime.h>
-#include <utils/misc.h>
-
-// ----------------------------------------------------------------------------
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-struct offsets_t {
- jfieldID bytesPerPixel;
- jfieldID bitsPerPixel;
-};
-
-static offsets_t offsets;
-
-// ----------------------------------------------------------------------------
-
-static void android_graphics_getPixelFormatInfo(
- JNIEnv* env, jobject clazz, jint format, jobject pixelFormatObject)
-{
- PixelFormatInfo info;
- status_t err;
-
- // we need this for backward compatibility with PixelFormat's
- // deprecated constants
- switch (format) {
- case HAL_PIXEL_FORMAT_YCbCr_422_SP:
- // defined as the bytes per pixel of the Y plane
- info.bytesPerPixel = 1;
- info.bitsPerPixel = 16;
- goto done;
- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
- // defined as the bytes per pixel of the Y plane
- info.bytesPerPixel = 1;
- info.bitsPerPixel = 12;
- goto done;
- case HAL_PIXEL_FORMAT_YCbCr_422_I:
- // defined as the bytes per pixel of the Y plane
- info.bytesPerPixel = 1;
- info.bitsPerPixel = 16;
- goto done;
- }
-
- err = getPixelFormatInfo(format, &info);
- if (err < 0) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return;
- }
-
-done:
- env->SetIntField(pixelFormatObject, offsets.bytesPerPixel, info.bytesPerPixel);
- env->SetIntField(pixelFormatObject, offsets.bitsPerPixel, info.bitsPerPixel);
-}
-// ----------------------------------------------------------------------------
-
-const char* const kClassPathName = "android/graphics/PixelFormat";
-
-static void nativeClassInit(JNIEnv* env, jclass clazz);
-
-static JNINativeMethod gMethods[] = {
- { "nativeClassInit", "()V",
- (void*)nativeClassInit },
- { "getPixelFormatInfo", "(ILandroid/graphics/PixelFormat;)V",
- (void*)android_graphics_getPixelFormatInfo
- }
-};
-
-void nativeClassInit(JNIEnv* env, jclass clazz)
-{
- offsets.bytesPerPixel = env->GetFieldID(clazz, "bytesPerPixel", "I");
- offsets.bitsPerPixel = env->GetFieldID(clazz, "bitsPerPixel", "I");
-}
-
-int register_android_graphics_PixelFormat(JNIEnv* env)
-{
- return AndroidRuntime::registerNativeMethods(env,
- kClassPathName, gMethods, NELEM(gMethods));
-}
-
-};
diff --git a/graphics/java/android/graphics/PixelFormat.java b/graphics/java/android/graphics/PixelFormat.java
index f7c202f..0230583 100644
--- a/graphics/java/android/graphics/PixelFormat.java
+++ b/graphics/java/android/graphics/PixelFormat.java
@@ -43,7 +43,9 @@ public class PixelFormat
public static final int RGBA_5551 = 6;
@Deprecated
public static final int RGBA_4444 = 7;
+ @Deprecated
public static final int A_8 = 8;
+ @Deprecated
public static final int L_8 = 9;
@Deprecated
public static final int LA_88 = 0xA;
@@ -79,14 +81,43 @@ public class PixelFormat
@Deprecated
public static final int JPEG = 0x100;
- /*
- * We use a class initializer to allow the native code to cache some
- * field offsets.
- */
- native private static void nativeClassInit();
- static { nativeClassInit(); }
+ public static void getPixelFormatInfo(int format, PixelFormat info) {
+ switch (format) {
+ case RGBA_8888:
+ case RGBX_8888:
+ info.bitsPerPixel = 32;
+ info.bytesPerPixel = 4;
+ break;
+ case RGB_888:
+ info.bitsPerPixel = 24;
+ info.bytesPerPixel = 3;
+ break;
+ case RGB_565:
+ case RGBA_5551:
+ case RGBA_4444:
+ info.bitsPerPixel = 16;
+ info.bytesPerPixel = 2;
+ break;
+ case A_8:
+ case L_8:
+ case RGB_332:
+ info.bitsPerPixel = 8;
+ info.bytesPerPixel = 1;
+ break;
+ case YCbCr_422_SP:
+ case YCbCr_422_I:
+ info.bitsPerPixel = 16;
+ info.bytesPerPixel = 1;
+ break;
+ case YCbCr_420_SP:
+ info.bitsPerPixel = 12;
+ info.bytesPerPixel = 1;
+ break;
+ default:
+ throw new IllegalArgumentException("unkonwon pixel format " + format);
+ }
+ }
- public static native void getPixelFormatInfo(int format, PixelFormat info);
public static boolean formatHasAlpha(int format) {
switch (format) {
case PixelFormat.A_8: