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

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

Issue 335943002: [Android] Composited selection handle rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_final
Patch Set: Clean up paste popup interaction Created 6 years, 5 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
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/android/jni_string.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int height, 62 int height,
63 SkBitmap::Config bitmap_config) { 63 SkBitmap::Config bitmap_config) {
64 DCHECK_GT(width, 0); 64 DCHECK_GT(width, 0);
65 DCHECK_GT(height, 0); 65 DCHECK_GT(height, 0);
66 int java_bitmap_config = SkBitmapConfigToBitmapFormat(bitmap_config); 66 int java_bitmap_config = SkBitmapConfigToBitmapFormat(bitmap_config);
67 return Java_BitmapHelper_createBitmap( 67 return Java_BitmapHelper_createBitmap(
68 AttachCurrentThread(), width, height, java_bitmap_config); 68 AttachCurrentThread(), width, height, java_bitmap_config);
69 } 69 }
70 70
71 ScopedJavaLocalRef<jobject> CreateJavaBitmapFromAndroidResource( 71 ScopedJavaLocalRef<jobject> CreateJavaBitmapFromAndroidResource(
72 int resource_id) {
73 JNIEnv* env = AttachCurrentThread();
74 return Java_BitmapHelper_decodeDrawableResourceAGB_I(env, resource_id);
75 }
76
77 ScopedJavaLocalRef<jobject> CreateJavaBitmapFromAndroidResource(
78 const char* name) {
79 DCHECK(name);
80 JNIEnv* env = AttachCurrentThread();
81 ScopedJavaLocalRef<jstring> jname(ConvertUTF8ToJavaString(env, name));
82 return Java_BitmapHelper_decodeDrawableResourceAGB_JLS(env, jname.obj());
83 }
84
85 ScopedJavaLocalRef<jobject> CreateJavaBitmapFromAndroidResource(
72 const char* name, 86 const char* name,
73 gfx::Size size) { 87 gfx::Size size) {
74 DCHECK(name); 88 DCHECK(name);
75 DCHECK(!size.IsEmpty()); 89 DCHECK(!size.IsEmpty());
76 JNIEnv* env = AttachCurrentThread(); 90 JNIEnv* env = AttachCurrentThread();
77 ScopedJavaLocalRef<jstring> jname(ConvertUTF8ToJavaString(env, name)); 91 ScopedJavaLocalRef<jstring> jname(ConvertUTF8ToJavaString(env, name));
78 return Java_BitmapHelper_decodeDrawableResource( 92 return Java_BitmapHelper_decodeAndDownsampleDrawableResource(
79 env, jname.obj(), size.width(), size.height()); 93 env, jname.obj(), size.width(), size.height());
80 } 94 }
81 95
82 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { 96 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
83 DCHECK(skbitmap); 97 DCHECK(skbitmap);
84 DCHECK(!skbitmap->isNull()); 98 DCHECK(!skbitmap->isNull());
85 SkBitmap::Config bitmap_config = skbitmap->config(); 99 SkBitmap::Config bitmap_config = skbitmap->config();
86 DCHECK((bitmap_config == SkBitmap::kRGB_565_Config) || 100 DCHECK((bitmap_config == SkBitmap::kRGB_565_Config) ||
87 (bitmap_config == SkBitmap::kARGB_8888_Config)); 101 (bitmap_config == SkBitmap::kARGB_8888_Config));
88 ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap( 102 ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return SkBitmap::kARGB_8888_Config; 146 return SkBitmap::kARGB_8888_Config;
133 case BITMAP_FORMAT_RGB_565: 147 case BITMAP_FORMAT_RGB_565:
134 return SkBitmap::kRGB_565_Config; 148 return SkBitmap::kRGB_565_Config;
135 case BITMAP_FORMAT_NO_CONFIG: 149 case BITMAP_FORMAT_NO_CONFIG:
136 default: 150 default:
137 return SkBitmap::kNo_Config; 151 return SkBitmap::kNo_Config;
138 } 152 }
139 } 153 }
140 154
141 } // namespace gfx 155 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698