#include "CreateJavaOutputStreamAdaptor.h"
#include <Caches.h>
#include <hwui/Paint.h>
+#include <renderthread/RenderProxy.h>
#include "core_jni_helpers.h"
mPixelRef->unref();
}
- Bitmap::Bitmap(void* address, int fd,
+ Bitmap::Bitmap(void* address, int fd, size_t mappedSize,
const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable)
: mPixelStorageType(PixelStorageType::Ashmem) {
mPixelStorage.ashmem.address = address;
mPixelStorage.ashmem.fd = fd;
- mPixelStorage.ashmem.size = ashmem_get_size_region(fd);
+ mPixelStorage.ashmem.size = mappedSize;
mPixelRef.reset(new WrappedPixelRef(this, address, info, rowBytes, ctable));
// Note: this will trigger a call to onStrongRefDestroyed(), but
// we want the pixel ref to have a ref count of 0 at this point
// Map the pixels in place and take ownership of the ashmem region.
nativeBitmap = GraphicsJNI::mapAshmemPixelRef(env, bitmap.get(),
- ctable, dupFd, const_cast<void*>(blob.data()), !isMutable);
+ ctable, dupFd, const_cast<void*>(blob.data()), size, !isMutable);
SkSafeUnref(ctable);
if (!nativeBitmap) {
close(dupFd);
return reinterpret_cast<jlong>(pixelRef);
}
+static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) {
+ LocalScopedBitmap bitmapHandle(bitmapPtr);
+ if (!bitmapHandle.valid()) return;
+ SkBitmap bitmap;
+ bitmapHandle->getSkBitmap(&bitmap);
+ android::uirenderer::renderthread::RenderProxy::prepareToDraw(bitmap);
+}
+
///////////////////////////////////////////////////////////////////////////////
static const JNINativeMethod gBitmapMethods[] = {
(void*)Bitmap_copyPixelsFromBuffer },
{ "nativeSameAs", "(JJ)Z", (void*)Bitmap_sameAs },
{ "nativeRefPixelRef", "(J)J", (void*)Bitmap_refPixelRef },
+ { "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw },
};
int register_android_graphics_Bitmap(JNIEnv* env)