1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef AWT_DRAWING_SURFACE_H
  27 #define AWT_DRAWING_SURFACE_H
  28 
  29 #include "stdhdrs.h"
  30 #include <jawt.h>
  31 #include <jawt_md.h>
  32 #include "awt_Component.h"
  33 #include <ddraw.h>
  34 
  35 class JAWTDrawingSurface;
  36 class JAWTOffscreenDrawingSurface;
  37 class JAWTOffscreenDrawingSurfaceInfo;
  38 
  39 /*
  40  * New structure for 1.4.1_02 release that allows access to
  41  * offscreen drawing surfaces.
  42  * This structure is slightly different from the old Win32
  43  * structure because the type of information we pass back
  44  * to the caller is dependent upon runtime configuration.
  45  * For example, we may have a DirectX7 surface pointer if
  46  * the runtime system had DX7 installed, but we may only have
  47  * a DirectX5 surface if that was the latest version installed.
  48  * We may also, in the future, offer different types of
  49  * surface, such as OpenGL surfaces, based on runtime
  50  * configuration and user options.
  51  * Given this variability, the correct usage of this structure
  52  * involves checking the surfaceType variable to see what type
  53  * of pointer we have returned and then casting the lpSurface
  54  * variable and using it based on the surfaceType.
  55  */
  56 typedef struct jawt_Win32OffscreenDrawingSurfaceInfo {
  57     IDirectDrawSurface  *dxSurface;
  58     IDirectDrawSurface7 *dx7Surface;
  59 } JAWT_Win32OffscreenDrawingSurfaceInfo;
  60 
  61 
  62 /*
  63  * Drawing surface info houses the important drawing information.
  64  * Here we multiply inherit from both structures, the platform-specific
  65  * and the platform-independent versions, so they are treated as the
  66  * same object.
  67  */
  68 class JAWTDrawingSurfaceInfo : public JAWT_Win32DrawingSurfaceInfo,
  69     public JAWT_DrawingSurfaceInfo {
  70 public:
  71     jint Init(JAWTDrawingSurface* parent);
  72 public:
  73     JAWT_Rectangle clipRect;
  74 };
  75 
  76 /*
  77  * Same as above except for offscreen surfaces instead of onscreen
  78  * Components.
  79  */
  80 class JAWTOffscreenDrawingSurfaceInfo :
  81     public JAWT_Win32OffscreenDrawingSurfaceInfo,
  82     public JAWT_DrawingSurfaceInfo
  83 {
  84 public:
  85     jint Init(JAWTOffscreenDrawingSurface* parent);
  86 
  87 };
  88 
  89 /*
  90  * The drawing surface wrapper.
  91  */
  92 class JAWTDrawingSurface : public JAWT_DrawingSurface {
  93 public:
  94     JAWTDrawingSurface() {}
  95     JAWTDrawingSurface(JNIEnv* env, jobject rTarget);
  96     virtual ~JAWTDrawingSurface();
  97 
  98 public:
  99     JAWTDrawingSurfaceInfo info;
 100 
 101 // Static function pointers
 102 public:
 103     static jint JNICALL LockSurface
 104         (JAWT_DrawingSurface* ds);
 105 
 106     static JAWT_DrawingSurfaceInfo* JNICALL GetDSI
 107         (JAWT_DrawingSurface* ds);
 108 
 109     static void JNICALL FreeDSI
 110         (JAWT_DrawingSurfaceInfo* dsi);
 111 
 112     static void JNICALL UnlockSurface
 113         (JAWT_DrawingSurface* ds);
 114 };
 115 
 116 /*
 117  * Same as above except for offscreen surfaces instead of onscreen
 118  * Components.
 119  */
 120 class JAWTOffscreenDrawingSurface : public JAWTDrawingSurface {
 121 public:
 122     JAWTOffscreenDrawingSurface() {}
 123     JAWTOffscreenDrawingSurface(JNIEnv* env, jobject rTarget);
 124     virtual ~JAWTOffscreenDrawingSurface();
 125 
 126 public:
 127     JAWTOffscreenDrawingSurfaceInfo info;
 128 
 129 // Static function pointers
 130 public:
 131     static JAWT_DrawingSurfaceInfo* JNICALL GetDSI
 132         (JAWT_DrawingSurface* ds);
 133 
 134     static void JNICALL FreeDSI
 135         (JAWT_DrawingSurfaceInfo* dsi);
 136 
 137     static jint JNICALL LockSurface
 138         (JAWT_DrawingSurface* ds);
 139 
 140     static void JNICALL UnlockSurface
 141         (JAWT_DrawingSurface* ds);
 142 };
 143 
 144 #ifdef __cplusplus
 145 extern "C" {
 146 #endif
 147     _JNI_IMPORT_OR_EXPORT_
 148     JAWT_DrawingSurface* JNICALL DSGetDrawingSurface
 149         (JNIEnv* env, jobject target);
 150 
 151     _JNI_IMPORT_OR_EXPORT_
 152     void JNICALL DSFreeDrawingSurface
 153         (JAWT_DrawingSurface* ds);
 154 
 155     _JNI_IMPORT_OR_EXPORT_
 156     void JNICALL DSLockAWT(JNIEnv* env);
 157 
 158     _JNI_IMPORT_OR_EXPORT_
 159     void JNICALL DSUnlockAWT(JNIEnv* env);
 160 
 161     _JNI_IMPORT_OR_EXPORT_
 162     jobject JNICALL DSGetComponent(
 163         JNIEnv* env, void* platformInfo);
 164 
 165 #ifdef __cplusplus
 166 } /* extern "C" */
 167 #endif
 168 
 169 #endif /* AWT_DRAWING_SURFACE_H */