com_android_internal_graphics_NativeUtils.cpp revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#define LOG_TAG "AWT" 18 19#include "jni.h" 20#include "JNIHelp.h" 21#include "GraphicsJNI.h" 22#include <android_runtime/AndroidRuntime.h> 23 24#include "SkCanvas.h" 25#include "SkDevice.h" 26#include "SkPicture.h" 27#include "SkTemplates.h" 28 29namespace android 30{ 31 32static jclass class_fileDescriptor; 33static jfieldID field_fileDescriptor_descriptor; 34static jmethodID method_fileDescriptor_init; 35 36 37static jboolean scrollRect(JNIEnv* env, jobject graphics2D, jobject canvas, jobject rect, int dx, int dy) { 38 if (canvas == NULL) { 39 jniThrowException(env, "java/lang/NullPointerException", NULL); 40 return false; 41 } 42 43 SkIRect src, *srcPtr = NULL; 44 if (NULL != rect) { 45 GraphicsJNI::jrect_to_irect(env, rect, &src); 46 srcPtr = &src; 47 } 48 SkCanvas* c = GraphicsJNI::getNativeCanvas(env, canvas); 49 const SkBitmap& bitmap = c->getDevice()->accessBitmap(true); 50 return bitmap.scrollRect(srcPtr, dx, dy, NULL); 51} 52 53static JNINativeMethod method_table[] = { 54 { "nativeScrollRect", 55 "(Landroid/graphics/Canvas;Landroid/graphics/Rect;II)Z", 56 (void*)scrollRect} 57}; 58 59int register_com_android_internal_graphics_NativeUtils(JNIEnv *env) { 60 return AndroidRuntime::registerNativeMethods( 61 env, "com/android/internal/graphics/NativeUtils", 62 method_table, NELEM(method_table)); 63} 64 65} 66