Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f213c8b authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge changes I487d4eef,Ia750811f

* changes:
  get rid of PixelFormatInfo and simplify things
  get rid of PIXEL_FORMAT_A_8
parents 54e5f0eb 2ca204e4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9509,10 +9509,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
+0 −2
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ static void usage(const char* pname)
static SkBitmap::Config flinger2skia(PixelFormat f)
{
    switch (f) {
        case PIXEL_FORMAT_A_8:
            return SkBitmap::kA8_Config;
        case PIXEL_FORMAT_RGB_565:
            return SkBitmap::kRGB_565_Config;
        case PIXEL_FORMAT_RGBA_4444:
+0 −1
Original line number Diff line number Diff line
@@ -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 \
+0 −2
Original line number Diff line number Diff line
@@ -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),
+0 −104
Original line number Diff line number Diff line
/*
 * 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));
}

};
Loading