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

Commit 8275ce52 authored by ctso's avatar ctso
Browse files

Merge branch 'eclair' of git://github.com/cyanogen/android_frameworks_base into eclair

parents 15a45929 7bb25767
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1444,6 +1444,11 @@ public final class Settings {
         */
        public static final String TRACKBALL_WAKE_SCREEN = "trackball_wake_screen";

        /**
         * Whether to show the 4 columns or 5 columns on the launcher.
         * @hide
         */
        public static final String LAUNCHER_COLUMN_NUMBER = "launcher_column_number";
        /**
         * Whether to show the battery level percentage overlayed on the icon.
         * @hide
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,10 @@ LOCAL_C_INCLUDES += \

LOCAL_CFLAGS +=

ifdef BOARD_GL_TEX_POW2_DIMENSION_REQUIRED
    LOCAL_CFLAGS += -DBOARD_GL_TEX_POW2_DIMENSION_REQUIRED
endif

LOCAL_LDLIBS := -lpthread
LOCAL_ADDITIONAL_DEPENDENCIES := $(addprefix $(rs_generated_include_dir)/,rsgApiFuncDecl.h)
LOCAL_MODULE:= librs_jni
+49 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <ui/Surface.h>

#include <core/SkBitmap.h>
#include <core/SkCanvas.h>
#include <core/SkPixelRef.h>
#include <core/SkStream.h>
#include <core/SkTemplates.h>
@@ -40,6 +41,7 @@

#include <RenderScript.h>
#include <RenderScriptEnv.h>
#include <rsUtils.h>

//#define LOG_API LOGE
#define LOG_API(...)
@@ -520,6 +522,49 @@ nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, jint dstFmt, jbool
    return 0;
}

static int
nAllocationCreateFromBitmapStretched(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    SkBitmap const * nativeBitmap =
            (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
    const SkBitmap& bitmap(*nativeBitmap);
    SkBitmap::Config config = bitmap.getConfig();

    RsElement e = SkBitmapToPredefined(config);

    if (e) {
        const int w = bitmap.width();
        const int h = bitmap.height();
        const int w2 = android::renderscript::rsHigherPow2(w);
        const int h2 = android::renderscript::rsHigherPow2(h);

        if ((w2 != w) || (h2 != h)) {
            SkBitmap resized;
            resized.setConfig(config, w2, h2);
            resized.allocPixels();
            SkCanvas canvas(resized);
            canvas.drawColor(0, SkXfermode::kClear_Mode);
            SkRect rect;
            rect.set(0, 0, w2, h2);
            canvas.drawBitmapRect(bitmap, NULL, rect);
            resized.lockPixels();
            const void* ptr = resized.getPixels();
            jint id = (jint)rsAllocationCreateFromBitmap(con, w2, h2, (RsElement)dstFmt, e, genMips, ptr);
            resized.unlockPixels();
            return id;
        }
        else {
            bitmap.lockPixels();
            const void* ptr = bitmap.getPixels();
            jint id = (jint)rsAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
            bitmap.unlockPixels();
            return id;
        }
    }
    return 0;
}

static int
nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap)
{
@@ -543,7 +588,6 @@ nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jbool
    return 0;
}


static void
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
{
@@ -1358,7 +1402,11 @@ static JNINativeMethod methods[] = {
{"nTypeSetupFields",               "(Landroid/renderscript/Type;[I[I[Ljava/lang/reflect/Field;)V", (void*)nTypeSetupFields },

{"nAllocationCreateTyped",         "(I)I",                                 (void*)nAllocationCreateTyped },
#ifndef BOARD_GL_TEX_POW2_DIMENSION_REQUIRED
{"nAllocationCreateFromBitmap",    "(IZLandroid/graphics/Bitmap;)I",       (void*)nAllocationCreateFromBitmap },
#else
{"nAllocationCreateFromBitmap",    "(IZLandroid/graphics/Bitmap;)I",       (void*)nAllocationCreateFromBitmapStretched },
#endif
{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I",      (void*)nAllocationCreateFromBitmapBoxed },
{"nAllocationCreateFromAssetStream","(IZI)I",                              (void*)nAllocationCreateFromAssetStream },
{"nAllocationUploadToTexture",     "(II)V",                                (void*)nAllocationUploadToTexture },