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

Commit 19419ccc authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Android (Google) Code Review
Browse files

Merge "Move GraphicBuffer back into libandroid_runtime."

parents bb748c59 e78f7c9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ cc_library_shared {
                "android_database_SQLiteConnection.cpp",
                "android_database_SQLiteGlobal.cpp",
                "android_database_SQLiteDebug.cpp",
                "android_graphics_GraphicBuffer.cpp",
                "android_view_CompositionSamplingListener.cpp",
                "android_view_DisplayEventReceiver.cpp",
                "android_view_InputChannel.cpp",
@@ -421,7 +422,6 @@ cc_library_static {
                "android_view_ThreadedRenderer.cpp",
                "android/graphics/BitmapRegionDecoder.cpp",
                "android/graphics/GIFMovie.cpp",
                "android/graphics/GraphicBuffer.cpp",
                "android/graphics/Movie.cpp",
                "android/graphics/MovieImpl.cpp",
                "android/graphics/SurfaceTexture.cpp",
+6 −10
Original line number Diff line number Diff line
@@ -19,11 +19,10 @@
#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_graphics_GraphicBuffer.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>

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

@@ -1129,11 +1128,9 @@ 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,
    AHardwareBuffer* buffer = android_hardware_HardwareBuffer_getNativeHardwareBuffer(env,
        hardwareBuffer);
    sp<GraphicBuffer> buffer(AHardwareBuffer_to_GraphicBuffer(hwBuf));
    SkColorType ct = uirenderer::PixelFormatToColorType(buffer->getPixelFormat());
    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer, ct,
    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer,
                                              GraphicsJNI::getNativeColorSpace(colorSpacePtr));
    if (!bitmap.get()) {
        ALOGW("failed to create hardware bitmap from hardware buffer");
@@ -1151,9 +1148,8 @@ static jobject Bitmap_createGraphicBufferHandle(JNIEnv* env, jobject, jlong bitm
    LOG_ALWAYS_FATAL_IF(!bitmapHandle->isHardware(),
            "Hardware config is only supported config in Bitmap_getGraphicBuffer");

    Bitmap& hwuiBitmap = bitmapHandle->bitmap();
    sp<GraphicBuffer> buffer(hwuiBitmap.graphicBuffer());
    return createJavaGraphicBuffer(env, buffer);
    Bitmap& bitmap = bitmapHandle->bitmap();
    return android_graphics_GraphicBuffer_createFromAHardwareBuffer(env, bitmap.hardwareBuffer());
#else
    return NULL;
#endif
+6 −4
Original line number Diff line number Diff line
@@ -21,10 +21,10 @@
#include <inttypes.h>

#include "android_os_Parcel.h"
#include "GraphicBuffer.h"
#include "GraphicsJNI.h"
#include "android/graphics/GraphicsJNI.h"

#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_graphics_GraphicBuffer.h>

#include <binder/Parcel.h>

@@ -266,7 +266,7 @@ static jlong android_graphics_GraphicBuffer_read(JNIEnv* env, jobject clazz,
// External helpers
// ----------------------------------------------------------------------------

sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) {
sp<GraphicBuffer> android_graphics_GraphicBuffer_getNativeGraphicsBuffer(JNIEnv* env, jobject obj) {
    if (obj) {
        jlong nativeObject = env->GetLongField(obj, gGraphicBufferClassInfo.mNativeObject);
        GraphicBufferWrapper* wrapper = (GraphicBufferWrapper*) nativeObject;
@@ -278,7 +278,9 @@ sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) {
    return NULL;
}

jobject createJavaGraphicBuffer(JNIEnv* env, const sp<GraphicBuffer>& buffer) {
jobject android_graphics_GraphicBuffer_createFromAHardwareBuffer(JNIEnv* env,
                                                                 AHardwareBuffer* hardwareBuffer) {
    GraphicBuffer* buffer = GraphicBuffer::fromAHardwareBuffer(hardwareBuffer);
    GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer);
    jobject obj = env->NewObject(gGraphicBufferClassInfo.mClass,
            gGraphicBufferClassInfo.mConstructorMethodID, buffer->getWidth(), buffer->getHeight(),
+3 −2
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@
#include <nativehelper/JNIHelp.h>

#include "android_os_Parcel.h"
#include "android/graphics/GraphicBuffer.h"

#include <android/hardware_buffer.h>
#include <android_runtime/android_graphics_GraphicBuffer.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/Log.h>
@@ -97,7 +97,8 @@ static jlong android_hardware_HardwareBuffer_create(JNIEnv* env, jobject clazz,
}

static jlong android_hardware_HardwareBuffer_createFromGraphicBuffer(JNIEnv* env, jobject clazz, jobject graphicBuffer) {
    sp<GraphicBuffer> buffer(graphicBufferForJavaObject(env, graphicBuffer));
    sp<GraphicBuffer> buffer(android_graphics_GraphicBuffer_getNativeGraphicsBuffer(env,
                                                                                    graphicBuffer));
    GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer);
    return reinterpret_cast<jlong>(wrapper);
}
+6 −4
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@
#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include "android_os_Parcel.h"
#include "android/graphics/GraphicBuffer.h"
#include "android/graphics/GraphicsJNI.h"

#include "core_jni_helpers.h"
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_graphics_GraphicBuffer.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/Log.h>

#include <binder/Parcel.h>
@@ -35,6 +35,7 @@
#include <gui/view/Surface.h>
#include <gui/SurfaceControl.h>

#include <ui/GraphicBuffer.h>
#include <ui/Rect.h>
#include <ui/Region.h>

@@ -432,8 +433,9 @@ static jint nativeForceScopedDisconnect(JNIEnv *env, jclass clazz, jlong nativeO
static jint nativeAttachAndQueueBufferWithColorSpace(JNIEnv *env, jclass clazz, jlong nativeObject,
        jobject graphicBuffer, jint colorSpaceId) {
    Surface* surface = reinterpret_cast<Surface*>(nativeObject);
    sp<GraphicBuffer> bp = graphicBufferForJavaObject(env, graphicBuffer);
    int err = Surface::attachAndQueueBufferWithDataspace(surface, bp,
    sp<GraphicBuffer> gb(android_graphics_GraphicBuffer_getNativeGraphicsBuffer(env,
                                                                                graphicBuffer));
    int err = Surface::attachAndQueueBufferWithDataspace(surface, gb,
            fromNamedColorSpaceValueToDataspace(colorSpaceId));
    return err;
}
Loading