4632N/A/*
4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A *
4632N/A * This code is free software; you can redistribute it and/or modify it
4632N/A * under the terms of the GNU General Public License version 2 only, as
4632N/A * published by the Free Software Foundation. Oracle designates this
4632N/A * particular file as subject to the "Classpath" exception as provided
4632N/A * by Oracle in the LICENSE file that accompanied this code.
4632N/A *
4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A * version 2 for more details (a copy is included in the LICENSE file that
4632N/A * accompanied this code).
4632N/A *
4632N/A * You should have received a copy of the GNU General Public License version
4632N/A * 2 along with this work; if not, write to the Free Software Foundation,
4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A *
4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4632N/A * or visit www.oracle.com if you need additional information or have any
4632N/A * questions.
4632N/A */
4632N/A
4632N/A#import <JavaNativeFoundation/JavaNativeFoundation.h>
4632N/A
4632N/A#import "AWTSurfaceLayers.h"
4632N/A
4632N/AJNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
4632N/A(JAWT_DrawingSurface* ds)
4632N/A{
4632N/A JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*)malloc(sizeof(JAWT_DrawingSurfaceInfo));
4632N/A
4632N/A JNIEnv *env = ds->env;
4632N/A jobject target = ds->target;
4632N/A
4632N/A static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
4632N/A static JNF_MEMBER_CACHE(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;");
4632N/A jobject peer = JNFGetObjectField(env, target, jf_peer);
4632N/A
4632N/A static JNF_CLASS_CACHE(jc_ComponentPeer, "sun/lwawt/LWComponentPeer");
4632N/A static JNF_MEMBER_CACHE(jf_platformComponent, jc_ComponentPeer,
4632N/A "platformComponent", "Lsun/lwawt/PlatformComponent;");
4632N/A jobject platformComponent = JNFGetObjectField(env, peer, jf_platformComponent);
4632N/A
4632N/A static JNF_CLASS_CACHE(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent");
4632N/A static JNF_MEMBER_CACHE(jm_getPointer, jc_PlatformComponent, "getPointer", "()J");
4632N/A AWTSurfaceLayers *surfaceLayers = jlong_to_ptr(JNFCallLongMethod(env, platformComponent, jm_getPointer));
4632N/A // REMIND: assert(surfaceLayers)
4632N/A
4632N/A dsi->platformInfo = surfaceLayers;
4632N/A dsi->ds = ds;
4632N/A
4632N/A static JNF_MEMBER_CACHE(jf_x, jc_Component, "x", "I");
4632N/A static JNF_MEMBER_CACHE(jf_y, jc_Component, "y", "I");
4632N/A static JNF_MEMBER_CACHE(jf_width, jc_Component, "width", "I");
4632N/A static JNF_MEMBER_CACHE(jf_height, jc_Component, "height", "I");
4632N/A
4632N/A dsi->bounds.x = JNFGetIntField(env, target, jf_x);
4632N/A dsi->bounds.y = JNFGetIntField(env, target, jf_y);
4632N/A dsi->bounds.width = JNFGetIntField(env, target, jf_width);
4632N/A dsi->bounds.height = JNFGetIntField(env, target, jf_height);
4632N/A
4632N/A dsi->clipSize = 1;
4632N/A dsi->clip = &(dsi->bounds);
4632N/A
4632N/A return dsi;
4632N/A}
4632N/A
4632N/AJNIEXPORT jint JNICALL awt_DrawingSurface_Lock
4632N/A(JAWT_DrawingSurface* ds)
4632N/A{
4632N/A // TODO: implement
4632N/A return 0;
4632N/A}
4632N/A
4632N/AJNIEXPORT void JNICALL awt_DrawingSurface_Unlock
4632N/A(JAWT_DrawingSurface* ds)
4632N/A{
4632N/A // TODO: implement
4632N/A}
4632N/A
4632N/AJNIEXPORT void JNICALL awt_DrawingSurface_FreeDrawingSurfaceInfo
4632N/A(JAWT_DrawingSurfaceInfo* dsi)
4632N/A{
4632N/A free(dsi);
4632N/A}
4632N/A
4632N/AJNIEXPORT JAWT_DrawingSurface* JNICALL awt_GetDrawingSurface
4632N/A(JNIEnv* env, jobject target)
4632N/A{
4632N/A JAWT_DrawingSurface* ds = (JAWT_DrawingSurface*)malloc(sizeof(JAWT_DrawingSurface));
4632N/A
4632N/A // TODO: "target instanceof" check
4632N/A
4632N/A ds->env = env;
4632N/A ds->target = (*env)->NewGlobalRef(env, target);
4632N/A ds->Lock = awt_DrawingSurface_Lock;
4632N/A ds->GetDrawingSurfaceInfo = awt_DrawingSurface_GetDrawingSurfaceInfo;
4632N/A ds->FreeDrawingSurfaceInfo = awt_DrawingSurface_FreeDrawingSurfaceInfo;
4632N/A ds->Unlock = awt_DrawingSurface_Unlock;
4632N/A
4632N/A return ds;
4632N/A}
4632N/A
4632N/AJNIEXPORT void JNICALL awt_FreeDrawingSurface
4632N/A(JAWT_DrawingSurface* ds)
4632N/A{
4632N/A JNIEnv *env = ds->env;
4632N/A (*env)->DeleteGlobalRef(env, ds->target);
4632N/A free(ds);
4632N/A}
4632N/A
4632N/AJNIEXPORT void JNICALL awt_Lock
4632N/A(JNIEnv* env)
4632N/A{
4632N/A // TODO: implement
4632N/A}
4632N/A
4632N/AJNIEXPORT void JNICALL awt_Unlock
4632N/A(JNIEnv* env)
4632N/A{
4632N/A // TODO: implement
4632N/A}
4632N/A
4632N/AJNIEXPORT jobject JNICALL awt_GetComponent
4632N/A(JNIEnv* env, void* platformInfo)
4632N/A{
4632N/A // TODO: implement
4632N/A return NULL;
4632N/A}