OSDN Git Service

Ensure munmap matches mmap am: aa394dd42c am: 068403a842 am: d073e28853 am: c9cf811b50
authorJohn Reck <jreck@google.com>
Tue, 13 Sep 2016 20:47:01 +0000 (20:47 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Tue, 13 Sep 2016 20:47:01 +0000 (20:47 +0000)
am: b74a6f60d1

Change-Id: I76f992080c2a7be15bf2518f2d914cb82f3aa30f

1  2 
core/jni/android/graphics/Bitmap.cpp

@@@ -18,7 -18,6 +18,7 @@@
  #include "CreateJavaOutputStreamAdaptor.h"
  #include <Caches.h>
  #include <hwui/Paint.h>
 +#include <renderthread/RenderProxy.h>
  
  #include "core_jni_helpers.h"
  
@@@ -151,12 -150,12 +151,12 @@@ Bitmap::Bitmap(void* address, void* con
      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
@@@ -1027,7 -1026,7 +1027,7 @@@ static jobject Bitmap_createFromParcel(
  
          // 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);
@@@ -1362,14 -1361,6 +1362,14 @@@ static jlong Bitmap_refPixelRef(JNIEnv
      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)