| 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 bool RegisterBitmapAndroid(JNIEnv* env) { |
| 39 ui::RegisterNativesImpl(env); | 39 return ui::RegisterNativesImpl(env); |
| 40 } | 40 } |
| 41 | 41 |
| 42 ScopedJavaLocalRef<jobject> CreateJavaBitmap(const gfx::Size& size) { | 42 ScopedJavaLocalRef<jobject> CreateJavaBitmap(const gfx::Size& size) { |
| 43 return ui::Java_BitmapHelper_createBitmap(AttachCurrentThread(), | 43 return ui::Java_BitmapHelper_createBitmap(AttachCurrentThread(), |
| 44 size.width(), size.height()); | 44 size.width(), size.height()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { | 47 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { |
| 48 DCHECK(skbitmap); | 48 DCHECK(skbitmap); |
| 49 DCHECK_EQ(skbitmap->bytesPerPixel(), 4); | 49 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()); | 84 memcpy(dst_pixels, src_pixels, skbitmap.getSize()); |
| 85 | 85 |
| 86 return skbitmap; | 86 return skbitmap; |
| 87 } | 87 } |
| 88 | 88 |
| 89 SkBitmap CreateSkBitmapFromResource(const char* name) { | 89 SkBitmap CreateSkBitmapFromResource(const char* name) { |
| 90 return ConvertToSkBitmap(CreateJavaBitmapFromResource(name)); | 90 return ConvertToSkBitmap(CreateJavaBitmapFromResource(name)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace gfx | 93 } // namespace gfx |
| OLD | NEW |