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

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

Issue 176943004: [Android] Implement asynchronous zero-copy bitmap capture API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 24 matching lines...) Expand all
35 JavaBitmap::~JavaBitmap() { 35 JavaBitmap::~JavaBitmap() {
36 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_); 36 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_);
37 DCHECK(!err); 37 DCHECK(!err);
38 } 38 }
39 39
40 // static 40 // static
41 bool JavaBitmap::RegisterJavaBitmap(JNIEnv* env) { 41 bool JavaBitmap::RegisterJavaBitmap(JNIEnv* env) {
42 return RegisterNativesImpl(env); 42 return RegisterNativesImpl(env);
43 } 43 }
44 44
45 static ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width, int height, 45 ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width,
46 bool is565_config) { 46 int height,
47 bool is565_config) {
47 return Java_BitmapHelper_createBitmap(AttachCurrentThread(), 48 return Java_BitmapHelper_createBitmap(AttachCurrentThread(),
48 width, height, is565_config); 49 width, height, is565_config);
49 } 50 }
50 51
51 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { 52 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
52 DCHECK(skbitmap); 53 DCHECK(skbitmap);
53 SkBitmap::Config config = skbitmap->getConfig(); 54 SkBitmap::Config config = skbitmap->getConfig();
54 DCHECK((config == SkBitmap::kRGB_565_Config) || 55 DCHECK((config == SkBitmap::kRGB_565_Config) ||
55 (config == SkBitmap::kARGB_8888_Config)); 56 (config == SkBitmap::kARGB_8888_Config));
56 // If the Config is not RGB565 it is default i.e ARGB8888 57 // If the Config is not RGB565 it is default i.e ARGB8888
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (jobj.is_null()) 97 if (jobj.is_null())
97 return SkBitmap(); 98 return SkBitmap();
98 99
99 JavaBitmap jbitmap(jobj.obj()); 100 JavaBitmap jbitmap(jobj.obj());
100 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap); 101 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap);
101 return skia::ImageOperations::Resize( 102 return skia::ImageOperations::Resize(
102 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); 103 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height());
103 } 104 }
104 105
105 } // namespace gfx 106 } // namespace gfx
OLDNEW
« content/port/browser/render_widget_host_view_port.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