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

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

Issue 157033007: API to Convert Java Bitmap Config to SkBitmap::Config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments. Created 6 years, 10 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
« ui/gfx/android/java_bitmap.h ('K') | « ui/gfx/android/java_bitmap.h ('k') | 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/android/jni_string.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "jni/BitmapHelper_jni.h" 11 #include "jni/BitmapHelper_jni.h"
12 #include "skia/ext/image_operations.h" 12 #include "skia/ext/image_operations.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
15 14
16 using base::android::AttachCurrentThread; 15 using base::android::AttachCurrentThread;
17 16
18 namespace gfx { 17 namespace gfx {
19 18
20 JavaBitmap::JavaBitmap(jobject bitmap) 19 JavaBitmap::JavaBitmap(jobject bitmap)
21 : bitmap_(bitmap), 20 : bitmap_(bitmap),
22 pixels_(NULL) { 21 pixels_(NULL) {
23 int err = AndroidBitmap_lockPixels(AttachCurrentThread(), bitmap_, &pixels_); 22 int err = AndroidBitmap_lockPixels(AttachCurrentThread(), bitmap_, &pixels_);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 env, jname.obj(), size.width(), size.height())); 94 env, jname.obj(), size.width(), size.height()));
96 if (jobj.is_null()) 95 if (jobj.is_null())
97 return SkBitmap(); 96 return SkBitmap();
98 97
99 JavaBitmap jbitmap(jobj.obj()); 98 JavaBitmap jbitmap(jobj.obj());
100 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap); 99 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap);
101 return skia::ImageOperations::Resize( 100 return skia::ImageOperations::Resize(
102 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); 101 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height());
103 } 102 }
104 103
104 SkBitmap::Config ConvertToSkiaConfig(jobject bitmap_config)
105 {
bulach 2014/02/17 10:33:58 nit: put { in the previous line
sivag 2014/02/18 16:06:22 Done.
106 int jbitmap_config =
107 static_cast<int>(Java_BitmapHelper_bitmapConfig(
bulach 2014/02/17 10:33:58 I think the static_cast is not needed..
sivag 2014/02/18 16:06:22 Done.
108 AttachCurrentThread(),
109 bitmap_config));
110
111 switch(jbitmap_config) {
112 case JavaBitmap::BITMAP_CONFIG_ALPHA_8:
113 return SkBitmap::kA8_Config;
114 case JavaBitmap::BITMAP_CONFIG_ARGB_4444:
115 return SkBitmap::kARGB_4444_Config;
116 case JavaBitmap::BITMAP_CONFIG_ARGB_8888:
117 return SkBitmap::kARGB_8888_Config;
118 case JavaBitmap::BITMAP_CONFIG_RGB_565:
119 return SkBitmap::kRGB_565_Config;
120 default:
121 return SkBitmap::kNo_Config;
122 }
123 }
124
105 } // namespace gfx 125 } // namespace gfx
OLDNEW
« ui/gfx/android/java_bitmap.h ('K') | « ui/gfx/android/java_bitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698