Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: ui/gfx/android/java_bitmap.cc

Issue 23597042: Android: Remove JNIEnv::NewStringUTF call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/android/jni_string.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "jni/BitmapHelper_jni.h" 11 #include "jni/BitmapHelper_jni.h"
11 #include "skia/ext/image_operations.h" 12 #include "skia/ext/image_operations.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
14 15
15 using base::android::AttachCurrentThread; 16 using base::android::AttachCurrentThread;
16 17
17 namespace gfx { 18 namespace gfx {
18 19
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void* src_pixels = skbitmap->getPixels(); 58 void* src_pixels = skbitmap->getPixels();
58 void* dst_pixels = dst_lock.pixels(); 59 void* dst_pixels = dst_lock.pixels();
59 memcpy(dst_pixels, src_pixels, skbitmap->getSize()); 60 memcpy(dst_pixels, src_pixels, skbitmap->getSize());
60 61
61 return jbitmap; 62 return jbitmap;
62 } 63 }
63 64
64 static ScopedJavaLocalRef<jobject> CreateJavaBitmapFromResource( 65 static ScopedJavaLocalRef<jobject> CreateJavaBitmapFromResource(
65 const char* name, gfx::Size requested_size) { 66 const char* name, gfx::Size requested_size) {
66 JNIEnv* env = AttachCurrentThread(); 67 JNIEnv* env = AttachCurrentThread();
67 ScopedJavaLocalRef<jstring> jname(env, env->NewStringUTF(name)); 68 ScopedJavaLocalRef<jstring> jname(
69 base::android::ConvertUTF8ToJavaString(env, name));
68 return ui::Java_BitmapHelper_decodeDrawableResource(env, 70 return ui::Java_BitmapHelper_decodeDrawableResource(env,
69 jname.obj(), 71 jname.obj(),
70 requested_size.width(), 72 requested_size.width(),
71 requested_size.height()); 73 requested_size.height());
72 } 74 }
73 75
74 static SkBitmap ConvertToSkBitmap(ScopedJavaLocalRef<jobject> jbitmap) { 76 static SkBitmap ConvertToSkBitmap(ScopedJavaLocalRef<jobject> jbitmap) {
75 if (jbitmap.is_null()) 77 if (jbitmap.is_null())
76 return SkBitmap(); 78 return SkBitmap();
77 79
(...skipping 22 matching lines...) Expand all
100 ConvertToSkBitmap(CreateJavaBitmapFromResource(name, size)); 102 ConvertToSkBitmap(CreateJavaBitmapFromResource(name, size));
101 if (bitmap.isNull()) 103 if (bitmap.isNull())
102 return bitmap; 104 return bitmap;
103 // RESIZE_BOX has sufficient downsampling quality with minimal runtime cost. 105 // RESIZE_BOX has sufficient downsampling quality with minimal runtime cost.
104 return skia::ImageOperations::Resize(bitmap, 106 return skia::ImageOperations::Resize(bitmap,
105 skia::ImageOperations::RESIZE_BOX, 107 skia::ImageOperations::RESIZE_BOX,
106 size.width(), size.height()); 108 size.width(), size.height());
107 } 109 }
108 110
109 } // namespace gfx 111 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698