@@ -613,7 +613,7 @@ android::Bitmap* GraphicsJNI::allocateAshmemPixelRef(JNIEnv* env, SkBitmap* bitm
613613 return nullptr ;
614614 }
615615
616- android::Bitmap* wrapper = new android::Bitmap (addr, fd, info, rowBytes, ctable);
616+ android::Bitmap* wrapper = new android::Bitmap (addr, fd, size, info, rowBytes, ctable);
617617 wrapper->getSkBitmap (bitmap);
618618 // since we're already allocated, we lockPixels right away
619619 // HeapAllocator behaves this way too
@@ -623,7 +623,7 @@ android::Bitmap* GraphicsJNI::allocateAshmemPixelRef(JNIEnv* env, SkBitmap* bitm
623623}
624624
625625android::Bitmap* GraphicsJNI::mapAshmemPixelRef (JNIEnv* env, SkBitmap* bitmap,
626- SkColorTable* ctable, int fd, void * addr, bool readOnly) {
626+ SkColorTable* ctable, int fd, void * addr, size_t size, bool readOnly) {
627627 const SkImageInfo& info = bitmap->info ();
628628 if (info.fColorType == kUnknown_SkColorType ) {
629629 doThrowIAE (env, " unknown bitmap configuration" );
@@ -633,7 +633,8 @@ android::Bitmap* GraphicsJNI::mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
633633 if (!addr) {
634634 // Map existing ashmem region if not already mapped.
635635 int flags = readOnly ? (PROT_READ) : (PROT_READ | PROT_WRITE);
636- addr = mmap (NULL , ashmem_get_size_region (fd), flags, MAP_SHARED, fd, 0 );
636+ size = ashmem_get_size_region (fd);
637+ addr = mmap (NULL , size, flags, MAP_SHARED, fd, 0 );
637638 if (addr == MAP_FAILED) {
638639 return nullptr ;
639640 }
@@ -643,7 +644,7 @@ android::Bitmap* GraphicsJNI::mapAshmemPixelRef(JNIEnv* env, SkBitmap* bitmap,
643644 // attempting to compute our own.
644645 const size_t rowBytes = bitmap->rowBytes ();
645646
646- android::Bitmap* wrapper = new android::Bitmap (addr, fd, info, rowBytes, ctable);
647+ android::Bitmap* wrapper = new android::Bitmap (addr, fd, size, info, rowBytes, ctable);
647648 wrapper->getSkBitmap (bitmap);
648649 if (readOnly) {
649650 bitmap->pixelRef ()->setImmutable ();
0 commit comments