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

Commit 480618ff authored by Jerome Gaillard's avatar Jerome Gaillard Committed by Android (Google) Code Review
Browse files

Merge "Build native android graphics library for desktop"

parents eb43884f 21e7e2d9
Loading
Loading
Loading
Loading
+258 −228
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ genrule {

cc_library_shared {
    name: "libandroid_runtime",

    host_supported: true,
    cflags: [
        "-Wno-unused-parameter",
        "-Wno-non-virtual-dtor",
@@ -31,6 +31,82 @@ cc_library_shared {

    cppflags: ["-Wno-conversion-null"],

    srcs: [
        "android_animation_PropertyValuesHolder.cpp",
        "android_graphics_Canvas.cpp",
        "android_graphics_ColorSpace.cpp",
        "android_graphics_drawable_AnimatedVectorDrawable.cpp",
        "android_graphics_drawable_VectorDrawable.cpp",
        "android_graphics_Picture.cpp",
        "android_nio_utils.cpp",
        "android_util_PathParser.cpp",
        "android/graphics/Bitmap.cpp",
        "android/graphics/BitmapFactory.cpp",
        "android/graphics/ByteBufferStreamAdaptor.cpp",
        "android/graphics/ColorFilter.cpp",
        "android/graphics/CreateJavaOutputStreamAdaptor.cpp",
        "android/graphics/FontFamily.cpp",
        "android/graphics/FontUtils.cpp",
        "android/graphics/Graphics.cpp",
        "android/graphics/ImageDecoder.cpp",
        "android/graphics/MaskFilter.cpp",
        "android/graphics/Matrix.cpp",
        "android/graphics/NinePatch.cpp",
        "android/graphics/NinePatchPeeker.cpp",
        "android/graphics/Paint.cpp",
        "android/graphics/PaintFilter.cpp",
        "android/graphics/Path.cpp",
        "android/graphics/PathEffect.cpp",
        "android/graphics/PathMeasure.cpp",
        "android/graphics/Picture.cpp",
        "android/graphics/Region.cpp",
        "android/graphics/Shader.cpp",
        "android/graphics/Typeface.cpp",
        "android/graphics/Utils.cpp",
        "android/graphics/fonts/Font.cpp",
        "android/graphics/fonts/FontFamily.cpp",
        "android/graphics/text/LineBreaker.cpp",
        "android/graphics/text/MeasuredText.cpp",
        "com_android_internal_util_VirtualRefBasePtr.cpp",
        "com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp",
    ],

    include_dirs: [
        // we need to access the private Bionic header
        // <bionic_tls.h> in com_google_android_gles_jni_GLImpl.cpp
        "bionic/libc/private",

        "external/skia/include/private",
        "external/skia/src/codec",
        "external/skia/src/core",
        "external/skia/src/effects",
        "external/skia/src/image",
        "external/skia/src/images",
        "frameworks/base/media/jni",
        "system/media/camera/include",
        "system/media/private/camera/include",
    ],

    shared_libs: [
        "libandroidicu",
        "libbase",
        "libcutils",
        "libharfbuzz_ng",
        "liblog",
        "libminikin",
        "libnativehelper",
        "libz",
        "libziparchive",
    ],

    local_include_dirs: ["android/graphics"],
    export_include_dirs: [
        ".",
        "include",
    ],

    target: {
        android: {
            srcs: [
                "AndroidRuntime.cpp",
                "com_android_internal_content_NativeLibraryHelper.cpp",
@@ -57,11 +133,6 @@ cc_library_shared {
                "android_database_SQLiteConnection.cpp",
                "android_database_SQLiteGlobal.cpp",
                "android_database_SQLiteDebug.cpp",
        "android_graphics_Canvas.cpp",
        "android_graphics_ColorSpace.cpp",
        "android_graphics_drawable_AnimatedVectorDrawable.cpp",
        "android_graphics_drawable_VectorDrawable.cpp",
        "android_graphics_Picture.cpp",
                "android_view_CompositionSamplingListener.cpp",
                "android_view_DisplayEventReceiver.cpp",
                "android_view_DisplayListCanvas.cpp",
@@ -106,60 +177,31 @@ cc_library_shared {
                "android_os_VintfRuntimeInfo.cpp",
                "android_net_LocalSocketImpl.cpp",
                "android_net_NetUtils.cpp",
        "android_nio_utils.cpp",
                "android_util_AssetManager.cpp",
                "android_util_Binder.cpp",
                "android_util_EventLog.cpp",
                "android_util_Log.cpp",
                "android_util_StatsLog.cpp",
                "android_util_MemoryIntArray.cpp",
        "android_util_PathParser.cpp",
                "android_util_Process.cpp",
                "android_util_StringBlock.cpp",
                "android_util_XmlBlock.cpp",
                "android_util_jar_StrictJarFile.cpp",
                "android/graphics/AnimatedImageDrawable.cpp",
        "android/graphics/Bitmap.cpp",
        "android/graphics/BitmapFactory.cpp",
        "android/graphics/ByteBufferStreamAdaptor.cpp",
                "android/graphics/Camera.cpp",
                "android/graphics/CanvasProperty.cpp",
        "android/graphics/ColorFilter.cpp",
        "android/graphics/FontFamily.cpp",
        "android/graphics/FontUtils.cpp",
        "android/graphics/CreateJavaOutputStreamAdaptor.cpp",
                "android/graphics/GIFMovie.cpp",
                "android/graphics/GraphicBuffer.cpp",
        "android/graphics/Graphics.cpp",
        "android/graphics/ImageDecoder.cpp",
                "android/graphics/Interpolator.cpp",
        "android/graphics/MaskFilter.cpp",
        "android/graphics/Matrix.cpp",
                "android/graphics/Movie.cpp",
                "android/graphics/MovieImpl.cpp",
        "android/graphics/NinePatch.cpp",
        "android/graphics/NinePatchPeeker.cpp",
        "android/graphics/Paint.cpp",
        "android/graphics/PaintFilter.cpp",
        "android/graphics/Path.cpp",
        "android/graphics/PathMeasure.cpp",
        "android/graphics/PathEffect.cpp",
        "android/graphics/Picture.cpp",
                "android/graphics/BitmapRegionDecoder.cpp",
        "android/graphics/Region.cpp",
        "android/graphics/Shader.cpp",
                "android/graphics/SurfaceTexture.cpp",
        "android/graphics/Typeface.cpp",
        "android/graphics/Utils.cpp",
                "android/graphics/YuvToJpegEncoder.cpp",
        "android/graphics/fonts/Font.cpp",
        "android/graphics/fonts/FontFamily.cpp",
                "android/graphics/pdf/PdfDocument.cpp",
                "android/graphics/pdf/PdfEditor.cpp",
                "android/graphics/pdf/PdfRenderer.cpp",
                "android/graphics/pdf/PdfUtils.cpp",
        "android/graphics/text/LineBreaker.cpp",
        "android/graphics/text/MeasuredText.cpp",
                "android_media_AudioEffectDescriptor.cpp",
                "android_media_AudioRecord.cpp",
                "android_media_AudioSystem.cpp",
@@ -202,37 +244,18 @@ cc_library_shared {
                "android_content_res_ApkAssets.cpp",
                "android_content_res_ObbScanner.cpp",
                "android_content_res_Configuration.cpp",
        "android_animation_PropertyValuesHolder.cpp",
                "android_security_Scrypt.cpp",
                "com_android_internal_os_AtomicDirectory.cpp",
                "com_android_internal_os_ClassLoaderFactory.cpp",
                "com_android_internal_os_FuseAppLoop.cpp",
                "com_android_internal_os_Zygote.cpp",
                "com_android_internal_os_ZygoteInit.cpp",
        "com_android_internal_util_VirtualRefBasePtr.cpp",
        "com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp",
                "hwbinder/EphemeralStorage.cpp",
                "fd_utils.cpp",
                "android_hardware_input_InputWindowHandle.cpp",
                "android_hardware_input_InputApplicationHandle.cpp",
            ],

    include_dirs: [
        // we need to access the private Bionic header
        // <bionic_tls.h> in com_google_android_gles_jni_GLImpl.cpp
        "bionic/libc/private",

        "external/skia/include/private",
        "external/skia/src/codec",
        "external/skia/src/core",
        "external/skia/src/effects",
        "external/skia/src/image",
        "external/skia/src/images",
        "frameworks/base/media/jni",
        "system/media/camera/include",
        "system/media/private/camera/include",
    ],

            static_libs: [
                "libasync_safe",
                "libgif",
@@ -249,10 +272,7 @@ cc_library_shared {
                "libmemtrack",
                "libandroidfw",
                "libappfuse",
        "libbase",
                "libcrypto",
        "libnativehelper",
        "liblog",
                "libcutils",
                "libdebuggerd_client",
                "libutils",
@@ -270,12 +290,10 @@ cc_library_shared {
                "libGLESv2",
                "libGLESv3",
                "libvulkan",
        "libziparchive",
                "libETC1",
                "libhardware",
                "libhardware_legacy",
                "libselinux",
        "libandroidicu",
                "libmedia",
                "libmedia_helper",
                "libmediametrics",
@@ -284,13 +302,10 @@ cc_library_shared {
                "libaudiopolicy",
                "libjpeg",
                "libusbhost",
        "libharfbuzz_ng",
        "libz",
                "libpdfium",
                "libimg_utils",
                "libnetd_client",
                "libsoundtrigger",
        "libminikin",
                "libprocessgroup",
                "libnativebridge_lazy",
                "libnativeloader_lazy",
@@ -306,14 +321,6 @@ cc_library_shared {
                "libstatslog",
                "server_configurable_flags",
            ],

    generated_sources: ["android_util_StatsLogInternal.cpp"],

    local_include_dirs: ["android/graphics"],
    export_include_dirs: [
        ".",
        "include",
    ],
            export_shared_lib_headers: [
                // AndroidRuntime.h depends on nativehelper/jni.h
                "libnativehelper",
@@ -324,4 +331,27 @@ cc_library_shared {
                // GraphicsJNI.h includes hwui headers
                "libhwui",
            ],
            generated_sources: ["android_util_StatsLogInternal.cpp"],
        },
        host: {
            cflags: [
                "-Wno-unused-const-variable",
                "-Wno-unused-function",
            ],
            srcs: [
                "LayoutlibLoader.cpp",
            ],
            include_dirs: [
                "external/vulkan-headers/include",
            ],
            shared_libs: [
                "libhwui-host",
            ],
            static_libs: [
                "libandroidfw",
                "libcompiler_rt",
                "libutils",
            ],
        },
    },
}
 No newline at end of file

core/jni/Android.mk

0 → 100644
+42 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2008 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.
#
LOCAL_PATH := $(call my-dir)
my_native_layoutlib_dependencies := \
    libandroid_runtime \
    libandroidicu-host \
    libbase \
    libc++ \
    libcutils \
    libdng_sdk \
    libexpat-host \
    libft2 \
    libharfbuzz_ng \
    libhwui-host \
    libicui18n-host \
    libicuuc-host \
    libjpeg \
    liblog \
    libminikin \
    libnativehelper \
    libpiex \
    libpng \
    libz-host \
    libziparchive
$(call dist-for-goals, layoutlib, \
    $(foreach m,$(my_native_layoutlib_dependencies), \
    $(HOST_LIBRARY_PATH)/$(m)$(HOST_SHLIB_SUFFIX):layoutlib_native/$(m)$(HOST_SHLIB_SUFFIX)))
$(call dist-for-goals, layoutlib, $(HOST_OUT)/com.android.runtime/etc/icu/icudt63l.dat:layoutlib_native/icu/icudt63l.dat)
my_native_layoutlib_dependencies :=
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -1235,6 +1235,10 @@ void AndroidRuntime::onVmCreated(JNIEnv* env)
    // If AndroidRuntime had anything to do here, we'd have done it in 'start'.
}

/*static*/ JavaVM* AndroidRuntime::getJavaVM() {
    return AndroidRuntime::mJavaVM;
}

/*
 * Get the JNIEnv pointer for this thread.
 *
+204 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 "jni.h"
#include "core_jni_helpers.h"

#include <unicode/putil.h>
#include <vector>

using namespace std;

/*
 * This is responsible for setting up the JNI environment for communication between
 * the Java and native parts of layoutlib, including registering native methods.
 * This is mostly achieved by copying the way it is done in the platform
 * (see AndroidRuntime.cpp).
 */

static JavaVM* javaVM;

extern int register_android_graphics_Bitmap(JNIEnv*);
extern int register_android_graphics_BitmapFactory(JNIEnv*);
extern int register_android_graphics_ByteBufferStreamAdaptor(JNIEnv* env);
extern int register_android_graphics_CreateJavaOutputStreamAdaptor(JNIEnv* env);
extern int register_android_graphics_Graphics(JNIEnv* env);
extern int register_android_graphics_ImageDecoder(JNIEnv*);
extern int register_android_graphics_MaskFilter(JNIEnv* env);
extern int register_android_graphics_NinePatch(JNIEnv*);
extern int register_android_graphics_PathEffect(JNIEnv* env);
extern int register_android_graphics_Shader(JNIEnv* env);
extern int register_android_graphics_Typeface(JNIEnv* env);

namespace android {

extern int register_android_animation_PropertyValuesHolder(JNIEnv *env);
extern int register_android_graphics_Canvas(JNIEnv* env);
extern int register_android_graphics_ColorFilter(JNIEnv* env);
extern int register_android_graphics_ColorSpace(JNIEnv* env);
extern int register_android_graphics_DrawFilter(JNIEnv* env);
extern int register_android_graphics_FontFamily(JNIEnv* env);
extern int register_android_graphics_Matrix(JNIEnv* env);
extern int register_android_graphics_Paint(JNIEnv* env);
extern int register_android_graphics_Path(JNIEnv* env);
extern int register_android_graphics_PathMeasure(JNIEnv* env);
extern int register_android_graphics_Picture(JNIEnv* env);
extern int register_android_graphics_Region(JNIEnv* env);
extern int register_android_graphics_drawable_AnimatedVectorDrawable(JNIEnv* env);
extern int register_android_graphics_drawable_VectorDrawable(JNIEnv* env);
extern int register_android_graphics_fonts_Font(JNIEnv* env);
extern int register_android_graphics_fonts_FontFamily(JNIEnv* env);
extern int register_android_graphics_text_LineBreaker(JNIEnv* env);
extern int register_android_graphics_text_MeasuredText(JNIEnv* env);
extern int register_android_util_PathParser(JNIEnv* env);
extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env);
extern int register_com_android_internal_view_animation_NativeInterpolatorFactoryHelper(JNIEnv *env);

#define REG_JNI(name)      { name }
struct RegJNIRec {
    int (*mProc)(JNIEnv*);
};

static const RegJNIRec gRegJNI[] = {
    REG_JNI(register_android_animation_PropertyValuesHolder),
    REG_JNI(register_android_graphics_Bitmap),
    REG_JNI(register_android_graphics_BitmapFactory),
    REG_JNI(register_android_graphics_ByteBufferStreamAdaptor),
    REG_JNI(register_android_graphics_Canvas),
    REG_JNI(register_android_graphics_ColorFilter),
    REG_JNI(register_android_graphics_ColorSpace),
    REG_JNI(register_android_graphics_CreateJavaOutputStreamAdaptor),
    REG_JNI(register_android_graphics_DrawFilter),
    REG_JNI(register_android_graphics_FontFamily),
    REG_JNI(register_android_graphics_Graphics),
    REG_JNI(register_android_graphics_ImageDecoder),
    REG_JNI(register_android_graphics_MaskFilter),
    REG_JNI(register_android_graphics_Matrix),
    REG_JNI(register_android_graphics_NinePatch),
    REG_JNI(register_android_graphics_Paint),
    REG_JNI(register_android_graphics_Path),
    REG_JNI(register_android_graphics_PathEffect),
    REG_JNI(register_android_graphics_PathMeasure),
    REG_JNI(register_android_graphics_Picture),
    REG_JNI(register_android_graphics_Region),
    REG_JNI(register_android_graphics_Shader),
    REG_JNI(register_android_graphics_Typeface),
    REG_JNI(register_android_graphics_drawable_AnimatedVectorDrawable),
    REG_JNI(register_android_graphics_drawable_VectorDrawable),
    REG_JNI(register_android_graphics_fonts_Font),
    REG_JNI(register_android_graphics_fonts_FontFamily),
    REG_JNI(register_android_graphics_text_LineBreaker),
    REG_JNI(register_android_graphics_text_MeasuredText),
    REG_JNI(register_android_util_PathParser),
    REG_JNI(register_com_android_internal_util_VirtualRefBasePtr),
    REG_JNI(register_com_android_internal_view_animation_NativeInterpolatorFactoryHelper),
};

// Vector to store the names of classes that need delegates of their native methods
static vector<string> classesToDelegate;

static int register_jni_procs(const RegJNIRec array[], size_t count, JNIEnv* env) {
    for (size_t i = 0; i < count; i++) {
        if (array[i].mProc(env) < 0) {
            return -1;
        }
    }
    return 0;
}

int AndroidRuntime::registerNativeMethods(JNIEnv* env,
        const char* className, const JNINativeMethod* gMethods, int numMethods) {

    string classNameString = string(className);
    if (find(classesToDelegate.begin(), classesToDelegate.end(), classNameString)
            != classesToDelegate.end()) {
        // Register native methods to the delegate class <classNameString>_NativeDelegate
        // by adding _Original to the name of each method.
        replace(classNameString.begin(), classNameString.end(), '$', '_');
        string delegateClassName = classNameString + "_NativeDelegate";
        jclass clazz = env->FindClass(delegateClassName.c_str());
        JNINativeMethod gTypefaceDelegateMethods[numMethods];
        for (int i = 0; i < numMethods; i++) {
            JNINativeMethod gTypefaceMethod = gMethods[i];
            string newName = string(gTypefaceMethod.name) + "_Original";
            gTypefaceDelegateMethods[i].name = strdup(newName.c_str());
            gTypefaceDelegateMethods[i].signature = gTypefaceMethod.signature;
            gTypefaceDelegateMethods[i].fnPtr = gTypefaceMethod.fnPtr;
        }
        int result = env->RegisterNatives(clazz, gTypefaceDelegateMethods, numMethods);
        for (int i = 0; i < numMethods; i++) {
            free((char*)gTypefaceDelegateMethods[i].name);
        }
        return result;
    }

    jclass clazz = env->FindClass(className);

    return env->RegisterNatives(clazz, gMethods, numMethods);
}

JNIEnv* AndroidRuntime::getJNIEnv()
{
    JNIEnv* env;
    if (javaVM->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
        return nullptr;
    return env;
}

JavaVM* AndroidRuntime::getJavaVM() {
    return javaVM;
}

} // namespace android

using namespace android;

JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
    javaVM = vm;
    JNIEnv* env = nullptr;
    if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
        return JNI_ERR;
    }

    // Get the names of classes that have to delegate their native methods
    jclass createInfo = FindClassOrDie(env, "com/android/tools/layoutlib/create/CreateInfo");
    jfieldID arrayId = GetStaticFieldIDOrDie(env, createInfo,
            "DELEGATE_CLASS_NATIVES_TO_NATIVES", "[Ljava/lang/String;");
    jobjectArray array = (jobjectArray) env->GetStaticObjectField(createInfo, arrayId);
    jsize size = env->GetArrayLength(array);

    for (int i=0; i < size; ++i) {
        jstring string = (jstring) env->GetObjectArrayElement(array, i);
        const char* charArray = env->GetStringUTFChars(string, 0);
        std::string className = std::string(charArray);
        std::replace(className.begin(), className.end(), '.', '/');
        classesToDelegate.push_back(className);
        env->ReleaseStringUTFChars(string, charArray);
    }

    if (register_jni_procs(gRegJNI, NELEM(gRegJNI), env) < 0) {
        return JNI_ERR;
    }

    // Set the location of ICU data
    jclass bridge = FindClassOrDie(env, "com/android/layoutlib/bridge/Bridge");
    jstring stringPath = (jstring) env->CallStaticObjectMethod(bridge,
            GetStaticMethodIDOrDie(env, bridge, "getIcuDataPath", "()Ljava/lang/String;"));
    const char* path = env->GetStringUTFChars(stringPath, 0);
    u_setDataDirectory(path);
    env->ReleaseStringUTFChars(stringPath, path);
    return JNI_VERSION_1_6;
}
+26 −4
Original line number Diff line number Diff line
#define LOG_TAG "Bitmap"
#include "Bitmap.h"

#include "GraphicBuffer.h"
#include "SkBitmap.h"
#include "SkPixelRef.h"
#include "SkImageEncoder.h"
@@ -11,19 +10,22 @@
#include "GraphicsJNI.h"
#include "SkStream.h"

#include <binder/Parcel.h>
#include "android_os_Parcel.h"
#include "android_util_Binder.h"
#include "android_nio_utils.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include <hwui/Paint.h>
#include <hwui/Bitmap.h>
#include <renderthread/RenderProxy.h>
#include <utils/Color.h>

#ifdef __ANDROID__ // Layoutlib does not support graphic buffer, parcel or render thread
#include "GraphicBuffer.h"
#include <binder/Parcel.h>
#include <renderthread/RenderProxy.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>

#include <private/android/AHardwareBufferHelpers.h>
#endif

#include "core_jni_helpers.h"

@@ -667,6 +669,7 @@ static void Bitmap_setHasMipMap(JNIEnv* env, jobject, jlong bitmapHandle,
static constexpr uint32_t kMaxColorSpaceSerializedBytes = 80;

static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
#ifdef __ANDROID__ // Layoutlib does not support parcel
    if (parcel == NULL) {
        SkDebugf("-------- unparcel parcel is NULL\n");
        return NULL;
@@ -783,12 +786,17 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {

    return createBitmap(env, nativeBitmap.release(),
            getPremulBitmapCreateFlags(isMutable), NULL, NULL, density);
#else
    doThrowRE(env, "Cannot use parcels outside of Android");
    return NULL;
#endif
}

static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
                                     jlong bitmapHandle,
                                     jboolean isMutable, jint density,
                                     jobject parcel) {
#ifdef __ANDROID__ // Layoutlib does not support parcel
    if (parcel == NULL) {
        SkDebugf("------- writeToParcel null parcel\n");
        return JNI_FALSE;
@@ -868,6 +876,10 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,

    blob.release();
    return JNI_TRUE;
#else
    doThrowRE(env, "Cannot use parcels outside of Android");
    return JNI_FALSE;
#endif
}

static jobject Bitmap_extractAlpha(JNIEnv* env, jobject clazz,
@@ -1085,9 +1097,11 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, jlong bm1Ha
}

static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) {
#ifdef __ANDROID__ // Layoutlib does not support render thread
    LocalScopedBitmap bitmapHandle(bitmapPtr);
    if (!bitmapHandle.valid()) return;
    android::uirenderer::renderthread::RenderProxy::prepareToDraw(bitmapHandle->bitmap());
#endif
}

static jint Bitmap_getAllocationByteCount(JNIEnv* env, jobject, jlong bitmapPtr) {
@@ -1114,6 +1128,7 @@ static jobject Bitmap_copyPreserveInternalConfig(JNIEnv* env, jobject, jlong bit

static jobject Bitmap_wrapHardwareBufferBitmap(JNIEnv* env, jobject, jobject hardwareBuffer,
                                               jlong colorSpacePtr) {
#ifdef __ANDROID__ // Layoutlib does not support graphic buffer
    AHardwareBuffer* hwBuf = android_hardware_HardwareBuffer_getNativeHardwareBuffer(env,
        hardwareBuffer);
    sp<GraphicBuffer> buffer(AHardwareBuffer_to_GraphicBuffer(hwBuf));
@@ -1125,9 +1140,13 @@ static jobject Bitmap_wrapHardwareBufferBitmap(JNIEnv* env, jobject, jobject har
        return NULL;
    }
    return bitmap::createBitmap(env, bitmap.release(), getPremulBitmapCreateFlags(false));
#else
    return NULL;
#endif
}

static jobject Bitmap_createGraphicBufferHandle(JNIEnv* env, jobject, jlong bitmapPtr) {
#ifdef __ANDROID__ // Layoutlib does not support graphic buffer
    LocalScopedBitmap bitmapHandle(bitmapPtr);
    LOG_ALWAYS_FATAL_IF(!bitmapHandle->isHardware(),
            "Hardware config is only supported config in Bitmap_getGraphicBuffer");
@@ -1135,9 +1154,12 @@ static jobject Bitmap_createGraphicBufferHandle(JNIEnv* env, jobject, jlong bitm
    Bitmap& hwuiBitmap = bitmapHandle->bitmap();
    sp<GraphicBuffer> buffer(hwuiBitmap.graphicBuffer());
    return createJavaGraphicBuffer(env, buffer);
#else
    return NULL;
#endif
}

static jboolean Bitmap_isImmutable(jlong bitmapHandle) {
static jboolean Bitmap_isImmutable(CRITICAL_JNI_PARAMS_COMMA jlong bitmapHandle) {
    LocalScopedBitmap bitmapHolder(bitmapHandle);
    if (!bitmapHolder.valid()) return JNI_FALSE;

Loading