blob: 9cc43606fac5d76584ab4b6351fc01f2c37b5df6 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032static jboolean scrollRect(JNIEnv* env, jobject graphics2D, jobject canvas, jobject rect, int dx, int dy) {
33 if (canvas == NULL) {
Elliott Hughes69a017b2011-04-08 14:10:28 -070034 jniThrowNullPointerException(env, NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035 return false;
36 }
Elliott Hughes69a017b2011-04-08 14:10:28 -070037
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 SkIRect src, *srcPtr = NULL;
39 if (NULL != rect) {
40 GraphicsJNI::jrect_to_irect(env, rect, &src);
41 srcPtr = &src;
42 }
43 SkCanvas* c = GraphicsJNI::getNativeCanvas(env, canvas);
44 const SkBitmap& bitmap = c->getDevice()->accessBitmap(true);
45 return bitmap.scrollRect(srcPtr, dx, dy, NULL);
46}
47
48static JNINativeMethod method_table[] = {
49 { "nativeScrollRect",
50 "(Landroid/graphics/Canvas;Landroid/graphics/Rect;II)Z",
51 (void*)scrollRect}
52};
53
54int register_com_android_internal_graphics_NativeUtils(JNIEnv *env) {
55 return AndroidRuntime::registerNativeMethods(
56 env, "com/android/internal/graphics/NativeUtils",
57 method_table, NELEM(method_table));
58}
59
60}