| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/android/java_bitmap.h" | 5 #include "ui/gfx/android/java_bitmap.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "jni/BitmapHelper_jni.h" | 10 #include "jni/BitmapHelper_jni.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 size_ = gfx::Size(info.width, info.height); | 28 size_ = gfx::Size(info.width, info.height); |
| 29 format_ = info.format; | 29 format_ = info.format; |
| 30 stride_ = info.stride; | 30 stride_ = info.stride; |
| 31 } | 31 } |
| 32 | 32 |
| 33 JavaBitmap::~JavaBitmap() { | 33 JavaBitmap::~JavaBitmap() { |
| 34 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_); | 34 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_); |
| 35 DCHECK(!err); | 35 DCHECK(!err); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void RegisterBitmapAndroid(JNIEnv* env) { | 38 // static |
| 39 ui::RegisterNativesImpl(env); | 39 bool JavaBitmap::RegisterJavaBitmap(JNIEnv* env) { |
| 40 return ui::RegisterNativesImpl(env); |
| 40 } | 41 } |
| 41 | 42 |
| 42 ScopedJavaLocalRef<jobject> CreateJavaBitmap(const gfx::Size& size) { | 43 ScopedJavaLocalRef<jobject> CreateJavaBitmap(const gfx::Size& size) { |
| 43 return ui::Java_BitmapHelper_createBitmap(AttachCurrentThread(), | 44 return ui::Java_BitmapHelper_createBitmap(AttachCurrentThread(), |
| 44 size.width(), size.height()); | 45 size.width(), size.height()); |
| 45 } | 46 } |
| 46 | 47 |
| 47 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { | 48 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { |
| 48 DCHECK(skbitmap); | 49 DCHECK(skbitmap); |
| 49 DCHECK_EQ(skbitmap->bytesPerPixel(), 4); | 50 DCHECK_EQ(skbitmap->bytesPerPixel(), 4); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 memcpy(dst_pixels, src_pixels, skbitmap.getSize()); | 85 memcpy(dst_pixels, src_pixels, skbitmap.getSize()); |
| 85 | 86 |
| 86 return skbitmap; | 87 return skbitmap; |
| 87 } | 88 } |
| 88 | 89 |
| 89 SkBitmap CreateSkBitmapFromResource(const char* name) { | 90 SkBitmap CreateSkBitmapFromResource(const char* name) { |
| 90 return ConvertToSkBitmap(CreateJavaBitmapFromResource(name)); | 91 return ConvertToSkBitmap(CreateJavaBitmapFromResource(name)); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace gfx | 94 } // namespace gfx |
| OLD | NEW |