jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 7489 9136c8c7d74c
child 18232 b538b71fb429
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7489
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1954
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    26
#include "sun_java2d_windows_GDIWindowSurfaceData.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    28
#include "GDIWindowSurfaceData.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "Region.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "Disposer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "WindowsFlags.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_Palette.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "awt_Win32GraphicsDevice.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "Devices.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    42
static LockFunc GDIWinSD_Lock;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    43
static GetRasInfoFunc GDIWinSD_GetRasInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    44
static UnlockFunc GDIWinSD_Unlock;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    45
static DisposeFunc GDIWinSD_Dispose;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    46
static SetupFunc GDIWinSD_Setup;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    47
static GetDCFunc GDIWinSD_GetDC;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    48
static ReleaseDCFunc GDIWinSD_ReleaseDC;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    49
static InvalidateSDFunc GDIWinSD_InvalidateSD;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
static HBRUSH   nullbrush;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
static HPEN     nullpen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
static jclass xorCompClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
static jboolean beingShutdown = JNI_FALSE;
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    57
static volatile LONG timeStamp = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
extern CriticalSection windowMoveLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
extern "C"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
GeneralDisposeFunc DisposeThreadGraphicsInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
jobject JNI_GetCurrentThread(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
int threadInfoIndex = TLS_OUT_OF_INDEXES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
static jclass threadClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
static jmethodID currentThreadMethodID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    69
void SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    J2dTraceLn(J2D_TRACE_INFO, "SetupThreadGraphicsInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // REMIND: handle error when creation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    ThreadGraphicsInfo *info =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        (ThreadGraphicsInfo*)TlsGetValue(threadInfoIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    if (info == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        info = new ThreadGraphicsInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        ZeroMemory(info, sizeof(ThreadGraphicsInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        TlsSetValue(threadInfoIndex, (LPVOID)info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        J2dTraceLn2(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                    "  current batch limit for for thread 0x%x is %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                     GetCurrentThreadId(), ::GdiGetBatchLimit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        J2dTraceLn(J2D_TRACE_VERBOSE, "  setting to the limit to 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        // Fix for bug 4374079
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        ::GdiSetBatchLimit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        Disposer_AddRecord(env, JNI_GetCurrentThread(env),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                           DisposeThreadGraphicsInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                           ptr_to_jlong(info));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    HDC oldhDC = info->hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    // the hDC is NULL for offscreen surfaces - we don't store it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // in TLS as it must be created new every time.
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    94
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    95
    if( ((oldhDC == NULL) && wsdo->window != NULL) ||
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    96
         (info->wsdo != wsdo) ||
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    97
         (info->wsdoTimeStamp != wsdo->timeStamp) )
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
    98
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // Init graphics state, either because this is our first time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // using it in this thread or because this thread is now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        // dealing with a different window than it was last time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   104
        //check extra condition:
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   105
        //(info->wsdoTimeStamp != wsdo->timeStamp).
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   106
        //Checking memory addresses (info->wsdo != wsdo) will not detect
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   107
        //that wsdo points to a newly allocated structure in case
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   108
        //that structure just got allocated at a "recycled" memory location
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   109
        //which previously was pointed by info->wsdo
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   110
        //see bug# 6859086
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   111
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // Release cached DC. We use deferred DC releasing mechanism because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        // the DC is associated with cached wsdo and component peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // which may've been disposed by this time, and we have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // no means of checking against it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        if (oldhDC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            MoveDCToPassiveList(oldhDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            info->hDC = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (wsdo->window != NULL){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            HDC hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            // This is a window surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            // First, init the HDC object
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   125
            AwtComponent *comp = GDIWindowSurfaceData_GetComp(env, wsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            if (comp == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            hDC = comp->GetDCFromComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            if (hDC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                ::SelectObject(hDC, nullbrush);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                ::SelectObject(hDC, nullpen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                ::SelectClipRgn(hDC, (HRGN) NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                ::SetROP2(hDC, R2_COPYPEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                wsdo->device->SelectPalette(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                // Note that on NT4 we don't need to do a realize here: the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                // palette-sharing takes care of color issues for us.  But
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                // on win98 if we don't realize a DC's palette, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                // palette does not appear to have correct access to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                // logical->system mapping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                wsdo->device->RealizePalette(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                // Second, init the rest of the graphics state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                ::GetClientRect(wsdo->window, &info->bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                // Make window-relative from client-relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                ::OffsetRect(&info->bounds, wsdo->insets.left, wsdo->insets.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                //Likewise, translate GDI calls from client-relative to window-relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                ::OffsetViewportOrgEx(hDC, -wsdo->insets.left, -wsdo->insets.top, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            // Finally, set these new values in the info for this thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            info->hDC = hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        // cached brush and pen are not associated with any DC, and can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // reused, but have to set type to 0 to indicate that no pen/brush
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // were set to the new hdc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        info->type = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (info->clip != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            env->DeleteWeakGlobalRef(info->clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        info->clip = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (info->comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            env->DeleteWeakGlobalRef(info->comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        info->comp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        info->xorcolor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        info->patrop = PATCOPY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   173
        //store the address and time stamp of newly allocated GDIWinSDOps structure
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        info->wsdo = wsdo;
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   175
        info->wsdoTimeStamp = wsdo->timeStamp;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * Releases native data stored in Thread local storage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * Called by the Disposer when the associated thread dies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
void DisposeThreadGraphicsInfo(JNIEnv *env, jlong tgi) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    J2dTraceLn(J2D_TRACE_INFO, "DisposeThreadGraphicsInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    ThreadGraphicsInfo *info = (ThreadGraphicsInfo*)jlong_to_ptr(tgi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    if (info != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (info->hDC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            // move the DC from the active dcs list to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            // the passive dc list to be released later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            MoveDCToPassiveList(info->hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        if (info->clip != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            env->DeleteWeakGlobalRef(info->clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (info->comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            env->DeleteWeakGlobalRef(info->comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        if (info->brush != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            info->brush->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (info->pen != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            info->pen->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        delete info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * Returns current Thread object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
jobject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
JNI_GetCurrentThread(JNIEnv *env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    return env->CallStaticObjectMethod(threadClass, currentThreadMethodID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
} /* JNI_GetCurrentThread() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * Return the data associated with this thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * NOTE: This function assumes that the SetupThreadGraphicsInfo()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * function has already been called for this situation (thread,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * window, etc.), so we can assume that the thread info contains
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   224
 * a valid hDC.  This should usually be the case since GDIWinSD_Setup
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * is called as part of the GetOps() process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
ThreadGraphicsInfo *GetThreadGraphicsInfo(JNIEnv *env,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   228
                                          GDIWinSDOps *wsdo) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    return (ThreadGraphicsInfo*)TlsGetValue(threadInfoIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   232
__inline HDC GetThreadDC(JNIEnv *env, GDIWinSDOps *wsdo) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    ThreadGraphicsInfo *info =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        (ThreadGraphicsInfo *)GetThreadGraphicsInfo(env, wsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    if (!info) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return (HDC) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    return info->hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
} // extern "C"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * This source file contains support code for loops using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * SurfaceData interface to talk to a Win32 drawable from native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 * code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   249
static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                     SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                     HDC hDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    HWND hW = wsdo->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    BOOL retCode = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   256
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_CheckMonitorArea");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    int numScreens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        Devices::InstanceAccess devices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        numScreens = devices->GetNumDevices();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    if( numScreens > 1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 888
diff changeset
   264
        LPMONITORINFO miInfo;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        RECT rSect ={0,0,0,0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        RECT rView ={bounds->x1, bounds->y1, bounds->x2, bounds->y2};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        retCode = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        miInfo = wsdo->device->GetMonitorInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        POINT ptOrig = {0, 0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        ::ClientToScreen(hW, &ptOrig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        ::OffsetRect(&rView,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            (ptOrig.x), (ptOrig.y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 888
diff changeset
   276
        ::IntersectRect(&rSect,&rView,&(miInfo->rcMonitor));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if( FALSE == ::IsRectEmpty(&rSect) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            if( TRUE == ::EqualRect(&rSect,&rView) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                retCode = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    return retCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
initThreadInfoIndex()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    if (threadInfoIndex == TLS_OUT_OF_INDEXES) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        threadInfoIndex = TlsAlloc();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   297
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   298
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   299
 * Utility function to make sure that native and java-level
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   300
 * surface depths are matched.  They can be mismatched when display-depths
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   301
 * change, either between the creation of the Java surfaceData structure
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   302
 * and the native ddraw surface, or later when a surface is automatically
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   303
 * adjusted to be the new display depth (even if it was created in a different
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   304
 * depth to begin with)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   305
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   306
BOOL SurfaceDepthsCompatible(int javaDepth, int nativeDepth)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   307
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   308
    if (nativeDepth != javaDepth) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   309
        switch (nativeDepth) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   310
        case 0: // Error condition: something is wrong with the surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   311
        case 8:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   312
        case 24:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   313
            // Java and native surface depths should match exactly for
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   314
            // these cases
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   315
            return FALSE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   316
            break;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   317
        case 16:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   318
            // Java surfaceData should be 15 or 16 bits
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   319
            if (javaDepth < 15 || javaDepth > 16) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   320
                return FALSE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   321
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   322
            break;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   323
        case 32:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   324
            // Could have this native depth for either 24- or 32-bit
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   325
            // Java surfaceData
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   326
            if (javaDepth != 24 && javaDepth != 32) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   327
                return FALSE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   328
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   329
            break;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   330
        default:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   331
            // should not get here, but if we do something is odd, so
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   332
            // just register a failure
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   333
            return FALSE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   334
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   335
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   336
    return TRUE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   337
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   338
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   339
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
/*
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   341
 * Class:     sun_java2d_windows_GDIWindowSurfaceData
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
JNIEXPORT void JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   346
Java_sun_java2d_windows_GDIWindowSurfaceData_initIDs(JNIEnv *env, jclass wsd,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                                                 jclass XORComp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    jclass tc;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   350
    J2dTraceLn(J2D_TRACE_INFO, "GDIWindowSurfaceData_initIDs");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    nullbrush = (HBRUSH) ::GetStockObject(NULL_BRUSH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    nullpen = (HPEN) ::GetStockObject(NULL_PEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    initThreadInfoIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    xorCompClass = (jclass)env->NewGlobalRef(XORComp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    tc = env->FindClass("java/lang/Thread");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    DASSERT(tc != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    threadClass = (jclass)env->NewGlobalRef(tc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    DASSERT(threadClass != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    currentThreadMethodID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        env->GetStaticMethodID(threadClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                               "currentThread",  "()Ljava/lang/Thread;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    DASSERT(currentThreadMethodID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
/*
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   369
 * Class:     sun_java2d_windows_GDIWindowSurfaceData
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * Method:    initOps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * Signature: (Ljava/lang/Object;IIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
JNIEXPORT void JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   374
Java_sun_java2d_windows_GDIWindowSurfaceData_initOps(JNIEnv *env, jobject wsd,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                                 jobject peer, jint depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                                 jint redMask, jint greenMask,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   377
                                                 jint blueMask, jint screen)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   379
    J2dTraceLn(J2D_TRACE_INFO, "GDIWindowSurfaceData_initOps");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   380
    GDIWinSDOps *wsdo = (GDIWinSDOps *)SurfaceData_InitOps(env, wsd, sizeof(GDIWinSDOps));
5938
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
   381
    if (wsdo == NULL) {
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
   382
        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
   383
        return;
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
   384
    }
7489
9136c8c7d74c 6859086: Dialog created by JOptionPane.showMessageDialog does not repaint sometimes
miroslawzn
parents: 5938
diff changeset
   385
    wsdo->timeStamp = InterlockedIncrement(&timeStamp); //creation time stamp
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   386
    wsdo->sdOps.Lock = GDIWinSD_Lock;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   387
    wsdo->sdOps.GetRasInfo = GDIWinSD_GetRasInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   388
    wsdo->sdOps.Unlock = GDIWinSD_Unlock;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   389
    wsdo->sdOps.Dispose = GDIWinSD_Dispose;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   390
    wsdo->sdOps.Setup = GDIWinSD_Setup;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   391
    wsdo->GetDC = GDIWinSD_GetDC;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   392
    wsdo->ReleaseDC = GDIWinSD_ReleaseDC;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   393
    wsdo->InvalidateSD = GDIWinSD_InvalidateSD;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    wsdo->invalid = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    wsdo->peer = env->NewWeakGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    wsdo->depth = depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    wsdo->pixelMasks[0] = redMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    wsdo->pixelMasks[1] = greenMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    wsdo->pixelMasks[2] = blueMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    // Init the DIB pixelStride and pixel masks according to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    // the pixel depth. In the 8-bit case, there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    // masks as a palette DIB is used instead. Likewise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    // in the 24-bit case, Windows doesn't expect the masks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    switch (depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        case 8:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            wsdo->pixelStride = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        case 15: //555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            wsdo->pixelStride = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        case 16: //565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            wsdo->pixelStride = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        case 24:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            wsdo->pixelStride = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        case 32: //888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            wsdo->pixelStride = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   422
    // GDIWindowSurfaceData_GetWindow will throw NullPointerException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    // if wsdo->window is NULL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   424
    wsdo->window = GDIWindowSurfaceData_GetWindow(env, wsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  wsdo=0x%x wsdo->window=0x%x",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                wsdo, wsdo->window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        Devices::InstanceAccess devices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        wsdo->device = devices->GetDeviceReference(screen, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    if (wsdo->device == NULL ||
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   433
        !SurfaceDepthsCompatible(depth, wsdo->device->GetBitDepth()))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        if (wsdo->device != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            J2dTraceLn2(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   437
                        "GDIWindowSurfaceData_initOps: Surface depth mismatch: "\
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                        "wsdo->depth=%d device depth=%d. Surface invalidated.",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                        wsdo->depth, wsdo->device->GetBitDepth());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            J2dTraceLn1(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   442
                        "GDIWindowSurfaceData_initOps: Incorrect "\
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        "screen number (screen=%d). Surface invalidated.",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        wsdo->invalid = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    wsdo->surfaceLock = new CriticalSection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    wsdo->bitmap = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    wsdo->bmdc = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    wsdo->bmCopyToScreen = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   455
JNIEXPORT GDIWinSDOps * JNICALL
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   456
GDIWindowSurfaceData_GetOps(JNIEnv *env, jobject sData)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    SurfaceDataOps *ops = SurfaceData_GetOps(env, sData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    // REMIND: There was originally a condition check here to make sure
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   460
    // that we were really dealing with a GDIWindowSurfaceData object, but
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    // it did not allow for the existence of other win32-accelerated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    // surface data objects (e.g., Win32OffScreenSurfaceData).  I've
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    // removed the check for now, but we should replace it with another,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    // more general check against Win32-related surfaces.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   465
    return (GDIWinSDOps *) ops;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   468
JNIEXPORT GDIWinSDOps * JNICALL
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   469
GDIWindowSurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    // use the 'no setup' version of GetOps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    SurfaceDataOps *ops = SurfaceData_GetOpsNoSetup(env, sData);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
    return (GDIWinSDOps *) ops;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
JNIEXPORT AwtComponent * JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   477
GDIWindowSurfaceData_GetComp(JNIEnv *env, GDIWinSDOps *wsdo)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    jobject localObj = env->NewLocalRef(wsdo->peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    if (localObj == NULL || (pData = JNI_GET_PDATA(localObj)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        J2dTraceLn1(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   484
                    "GDIWindowSurfaceData_GetComp: Null pData? pData=0x%x",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                    pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        if (beingShutdown == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            wsdo->invalid = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            return (AwtComponent *) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            AwtToolkit::GetInstance().VerifyActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        } catch (awt_toolkit_shutdown&) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            beingShutdown = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            wsdo->invalid = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            return (AwtComponent *) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        if (wsdo->invalid == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            SurfaceData_ThrowInvalidPipeException(env,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   499
                "GDIWindowSurfaceData: bounds changed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            JNU_ThrowNullPointerException(env, "component argument pData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        return (AwtComponent *) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    return static_cast<AwtComponent*>(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
JNIEXPORT HWND JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   509
GDIWindowSurfaceData_GetWindow(JNIEnv *env, GDIWinSDOps *wsdo)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    HWND window = wsdo->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    if (window == (HWND) NULL) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   514
        AwtComponent *comp = GDIWindowSurfaceData_GetComp(env, wsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        if (comp == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            J2dTraceLn(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   517
                   "GDIWindowSurfaceData_GetWindow: null component");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            return (HWND) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        comp->GetInsets(&wsdo->insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        window = comp->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (::IsWindow(window) == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            J2dRlsTraceLn(J2D_TRACE_ERROR,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   524
                          "GDIWindowSurfaceData_GetWindow: disposed component");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            JNU_ThrowNullPointerException(env, "disposed component");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            return (HWND) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        wsdo->window = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   536
static jboolean GDIWinSD_SimpleClip(JNIEnv *env, GDIWinSDOps *wsdo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                                   SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                                   HDC hDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    RECT rClip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   542
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_SimpleClip");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    if (hDC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    int nComplexity = ::GetClipBox(hDC, &rClip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    switch (nComplexity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    case COMPLEXREGION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            J2dTraceLn(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                       "  complex clipping region");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            // if complex user/system clip, more detailed testing required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            // check to see if the view itself has a complex clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            // ::GetClipBox is only API which returns overlapped window status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            // so we set the rView as our clip, and then see if resulting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            // clip is complex.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            // Only other way to figure this out would be to walk the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            // overlapping windows (no API to get the actual visible clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            // list).  Then we'd still have to merge that info with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            // clip region for the dc (if it exists).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            // REMIND: we can cache the CreateRectRgnIndirect result,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            // and only override with ::SetRectRgn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            // First, create a region handle (need existing HRGN for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            // the following call).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            HRGN rgnSave = ::CreateRectRgn(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            int  clipStatus = ::GetClipRgn(hDC, rgnSave);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            if (-1 == clipStatus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                J2dTraceLn(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   572
                           "GDIWinSD_SimpleClip: failed due to clip status");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                ::DeleteObject(rgnSave);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            HRGN rgnBounds = ::CreateRectRgn(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                bounds->x1 - wsdo->insets.left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                bounds->y1 - wsdo->insets.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                bounds->x2 - wsdo->insets.left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                bounds->y2 - wsdo->insets.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            ::SelectClipRgn(hDC, rgnBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            nComplexity = ::GetClipBox(hDC, &rClip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            ::SelectClipRgn(hDC, clipStatus? rgnSave: NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            ::DeleteObject(rgnSave);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            ::DeleteObject(rgnBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            // Now, test the new clip box.  If it's still not a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            // SIMPLE region, then our bounds must intersect part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            // the clipping article
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            if (SIMPLEREGION != nComplexity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                J2dTraceLn(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   592
                           "GDIWinSD_SimpleClip: failed due to complexity");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        // NOTE: No break here - we want to fall through into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        // SIMPLE case, adjust our bounds by the new rClip rect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        // and make sure that our locking bounds are not empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    case SIMPLEREGION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        J2dTraceLn(J2D_TRACE_VERBOSE, "  simple clipping region");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        // Constrain the bounds to the given clip box
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        if (bounds->x1 < rClip.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            bounds->x1 = rClip.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        if (bounds->y1 < rClip.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            bounds->y1 = rClip.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        if (bounds->x2 > rClip.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            bounds->x2 = rClip.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        if (bounds->y2 > rClip.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            bounds->y2 = rClip.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        // If the bounds are 0 or negative, then the bounds have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        // been obscured by the clip box, so return FALSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        if ((bounds->x2 <= bounds->x1) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            (bounds->y2 <= bounds->y1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            // REMIND: We should probably do something different here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            // instead of simply returning FALSE.  Since the bounds are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            // empty we won't end up drawing anything, so why spend the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            // effort of returning false and having GDI do a LOCK_BY_DIB?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            // Perhaps we need a new lock code that will indicate that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            // shouldn't bother drawing?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            J2dTraceLn(J2D_TRACE_WARNING,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   625
                       "GDIWinSD_SimpleClip: failed due to empty bounds");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    case NULLREGION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    case ERROR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        J2dTraceLn1(J2D_TRACE_ERROR,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   633
                   "GDIWinSD_SimpleClip: failed due to incorrect complexity=%d",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                    nComplexity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   641
static jint GDIWinSD_Lock(JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                         SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                         SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                         jint lockflags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   646
    GDIWinSDOps *wsdo = (GDIWinSDOps *) ops;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    int ret = SD_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    HDC hDC;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   649
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_Lock");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    /* This surfaceLock replaces an earlier implementation which used a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    monitor associated with the peer.  That implementation was prone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    to deadlock problems, so it was replaced by a lock that does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    have dependencies outside of this thread or object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    However, this lock doesn't necessarily do all that we want.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    For example, a user may issue a call which results in a DIB lock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    and another call which results in a DDraw Blt.  We can't guarantee
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    what order these operations happen in (they are driver and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    video-card dependent), so locking around the issue of either of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    those calls won't necessarily guarantee a particular result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    The real solution might be to move away from mixing our
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    rendering API's.  That is, if we only used DDraw, then we could
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    guarantee that all rendering operations would happen in a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    order.  Similarly for GDI.  But by mixing them, we leave our
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    code at the mercy of driver bugs.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    wsdo->surfaceLock->Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    if (wsdo->invalid == JNI_TRUE) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   668
        J2dTraceLn(J2D_TRACE_WARNING, "GDIWinSD_Lock: surface is invalid");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        wsdo->surfaceLock->Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        if (beingShutdown != JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            SurfaceData_ThrowInvalidPipeException(env,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   672
                "GDIWindowSurfaceData: bounds changed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    if (wsdo->lockType != WIN32SD_LOCK_UNLOCKED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        wsdo->surfaceLock->Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        if (!safe_ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            JNU_ThrowInternalError(env, "Win32 LockRasData cannot nest locks");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    hDC = wsdo->GetDC(env, wsdo, 0, NULL, NULL, NULL, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    if (hDC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        wsdo->surfaceLock->Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        if (beingShutdown != JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            JNU_ThrowNullPointerException(env, "HDC for component");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    if (lockflags & SD_LOCK_RD_WR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        // Do an initial clip to the client region of the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        RECT crect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        ::GetClientRect(wsdo->window, &crect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        // Translate to window coords
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        crect.left += wsdo->insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        crect.top += wsdo->insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        crect.right += wsdo->insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        crect.bottom += wsdo->insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        SurfaceDataBounds *bounds = &pRasInfo->bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        if (bounds->x1 < crect.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            bounds->x1 = crect.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        if (bounds->y1 < crect.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            bounds->y1 = crect.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        if (bounds->x2 > crect.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            bounds->x2 = crect.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        if (bounds->y2 > crect.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            bounds->y2 = crect.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   719
        if (bounds->x2 > bounds->x1 && bounds->y2 > bounds->y1) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   720
            wsdo->lockType = WIN32SD_LOCK_BY_DIB;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   721
            if (lockflags & SD_LOCK_FASTEST) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   722
                ret = SD_SLOWLOCK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   724
            J2dTraceLn(J2D_TRACE_VERBOSE, " locked by DIB");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            wsdo->ReleaseDC(env, wsdo, hDC);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   727
            wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   728
            wsdo->surfaceLock->Leave();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   729
            ret = SD_FAILURE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   730
            J2dTraceLn(J2D_TRACE_ERROR,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   731
                       "GDIWinSD_Lock: error locking by DIB");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   734
        J2dTraceLn(J2D_TRACE_VERBOSE, "GDIWinSD_Lock: surface wasn't locked");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        /* They didn't lock for anything - we won't give them anything */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        wsdo->ReleaseDC(env, wsdo, hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        wsdo->surfaceLock->Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        ret = SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    wsdo->lockFlags = lockflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   746
static void GDIWinSD_GetRasInfo(JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                               SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                               SurfaceDataRasInfo *pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   750
    GDIWinSDOps *wsdo = (GDIWinSDOps *) ops;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    jint lockflags = wsdo->lockFlags;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   752
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_GetRasInfo");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    HDC hDC = GetThreadDC(env, wsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    if (wsdo->lockType == WIN32SD_LOCK_UNLOCKED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        memset(pRasInfo, 0, sizeof(*pRasInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   760
    if (wsdo->lockType == WIN32SD_LOCK_BY_DIB) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        int x, y, w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        int pixelStride = wsdo->pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        // do not subtract insets from x,y as we take care of it in SD_GetDC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        x = pRasInfo->bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        y = pRasInfo->bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        w = pRasInfo->bounds.x2 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        h = pRasInfo->bounds.y2 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        struct tagBitmapheader  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            BITMAPINFOHEADER bmiHeader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                DWORD           dwMasks[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                RGBQUAD         palette[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            } colors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        } bmi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        // Need to create bitmap if we don't have one already or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        // if the existing one is not large enough for this operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        // or if we are in 8 bpp display mode (because we need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        // make sure that the latest palette info gets loaded into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        // the bitmap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        // REMIND: we should find some way to dynamically force bitmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        // recreation only when the palette changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        if (pixelStride == 1 || !wsdo->bitmap || (w > wsdo->bmWidth) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            (h > wsdo->bmHeight))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            if (wsdo->bitmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                // delete old objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                J2dTraceLn(J2D_TRACE_VERBOSE,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   790
                           "GDIWinSD_GetRasInfo: recreating GDI bitmap");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                if (wsdo->bmdc) {   // should not be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                    ::SelectObject(wsdo->bmdc, wsdo->oldmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                    ::DeleteDC(wsdo->bmdc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                    wsdo->bmdc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                ::DeleteObject(wsdo->bitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                wsdo->bitmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            bmi.bmiHeader.biWidth = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            bmi.bmiHeader.biHeight = -h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            wsdo->bmWidth = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            wsdo->bmHeight = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            bmi.bmiHeader.biPlanes = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            bmi.bmiHeader.biBitCount = pixelStride * 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            // 1,3 byte use BI_RGB, 2,4 byte use BI_BITFIELD...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            bmi.bmiHeader.biCompression =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                (pixelStride & 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                    ? BI_RGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                    : BI_BITFIELDS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            bmi.bmiHeader.biSizeImage = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            bmi.bmiHeader.biXPelsPerMeter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            bmi.bmiHeader.biYPelsPerMeter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            bmi.bmiHeader.biClrUsed = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            bmi.bmiHeader.biClrImportant = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            if (pixelStride == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                // we can use systemEntries here because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                // RGBQUAD is xRGB and systemEntries are stored as xRGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                memcpy(bmi.colors.palette, wsdo->device->GetSystemPaletteEntries(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                       sizeof(bmi.colors.palette));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                // For non-index cases, init the masks for the pixel depth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                for (int i = 0; i < 3; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                    bmi.colors.dwMasks[i] = wsdo->pixelMasks[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            // REMIND: This would be better if moved to the Lock function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            // so that errors could be dealt with.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            wsdo->bitmap = ::CreateDIBSection(hDC, (BITMAPINFO *) &bmi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                                              DIB_RGB_COLORS, &wsdo->bmBuffer, NULL, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            if (wsdo->bitmap != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                // scanStride is cached along with reuseable bitmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                // Round up to the next DWORD boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                wsdo->bmScanStride = (wsdo->bmWidth * pixelStride + 3) & ~3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                wsdo->bmdc = ::CreateCompatibleDC(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                if (wsdo->bmdc == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                    ::DeleteObject(wsdo->bitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                    wsdo->bitmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                    wsdo->oldmap = (HBITMAP) ::SelectObject(wsdo->bmdc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                                                            wsdo->bitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        if (wsdo->bitmap != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            if (lockflags & SD_LOCK_NEED_PIXELS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                int ret = ::BitBlt(wsdo->bmdc, 0, 0, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                                   hDC, x, y, SRCCOPY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                ::GdiFlush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            wsdo->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            wsdo->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            wsdo->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            wsdo->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            pRasInfo->rasBase = (char *)wsdo->bmBuffer - (x*pixelStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                                y*wsdo->bmScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            pRasInfo->pixelStride = pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            pRasInfo->scanStride = wsdo->bmScanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            if (lockflags & SD_LOCK_WRITE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                // If the user writes to the bitmap then we should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                // copy the bitmap to the screen during Unlock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                wsdo->bmCopyToScreen = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            pRasInfo->rasBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            pRasInfo->pixelStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            pRasInfo->scanStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        /* They didn't lock for anything - we won't give them anything */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        pRasInfo->rasBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        pRasInfo->pixelStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        pRasInfo->scanStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    if (wsdo->lockFlags & SD_LOCK_LUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        pRasInfo->lutBase =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            (long *) wsdo->device->GetSystemPaletteEntries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        pRasInfo->lutSize = 256;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        pRasInfo->lutBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        pRasInfo->lutSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    if (wsdo->lockFlags & SD_LOCK_INVCOLOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        pRasInfo->invColorTable = wsdo->device->GetSystemInverseLUT();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        ColorData *cData = wsdo->device->GetColorData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        pRasInfo->redErrTable = cData->img_oda_red;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        pRasInfo->grnErrTable = cData->img_oda_green;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        pRasInfo->bluErrTable = cData->img_oda_blue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        pRasInfo->invColorTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        pRasInfo->redErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        pRasInfo->grnErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        pRasInfo->bluErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    if (wsdo->lockFlags & SD_LOCK_INVGRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        pRasInfo->invGrayTable =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            wsdo->device->GetColorData()->pGrayInverseLutData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        pRasInfo->invGrayTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   907
static void GDIWinSD_Setup(JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                          SurfaceDataOps *ops)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    // Call SetupTGI to ensure that this thread already has a DC that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    // compatible with this window.  This means that we won't be calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    // ::SendMessage(GETDC) in the middle of a lock procedure, which creates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    // a potential deadlock situation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    // Note that calling SetupTGI here means that anybody needing a DC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    // later in this rendering process need only call GetTGI, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    // assumes that the TGI structure is valid for this thread/window.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   917
    SetupThreadGraphicsInfo(env, (GDIWinSDOps*)ops);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   921
static void GDIWinSD_Unlock(JNIEnv *env,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                           SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                           SurfaceDataRasInfo *pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   925
    GDIWinSDOps *wsdo = (GDIWinSDOps *) ops;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   926
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_Unlock");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    HDC hDC = GetThreadDC(env, wsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    if (wsdo->lockType == WIN32SD_LOCK_UNLOCKED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        if (!safe_ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            JNU_ThrowInternalError(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                                   "Unmatched unlock on Win32 SurfaceData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   937
    if (wsdo->lockType == WIN32SD_LOCK_BY_DIB) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        if (wsdo->lockFlags & SD_LOCK_WRITE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            J2dTraceLn(J2D_TRACE_VERBOSE,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   940
                       "GDIWinSD_Unlock: do Blt of the bitmap");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            if (wsdo->bmCopyToScreen && ::IsWindowVisible(wsdo->window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                // Don't bother copying to screen if our window has gone away
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                // or if the bitmap was not actually written to during this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                // Lock/Unlock procedure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                ::BitBlt(hDC, wsdo->x, wsdo->y, wsdo->w, wsdo->h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                    wsdo->bmdc, 0, 0, SRCCOPY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                ::GdiFlush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            wsdo->bmCopyToScreen = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        wsdo->ReleaseDC(env, wsdo, hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    wsdo->surfaceLock->Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
 * REMIND: This mechanism is just a prototype of a way to manage a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
 * small cache of DC objects.  It is incomplete in the following ways:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
 * - It is not thread-safe!  It needs appropriate locking and release calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
 *   (perhaps the AutoDC mechanisms from Kestrel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
 * - It does hardly any error checking (What if GetDCEx returns NULL?)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
 * - It cannot handle printer DCs and their resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
 * - It should probably "live" in the native SurfaceData object to allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
 *   alternate implementations for printing and embedding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
 * - It doesn't handle XOR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
 * - It caches the client bounds to determine if clipping is really needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
 *   (no way to invalidate the cached bounds and there is probably a better
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
 *    way to manage clip validation in any case)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
#define COLORFOR(c)     (PALETTERGB(((c)>>16)&0xff,((c)>>8)&0xff,((c)&0xff)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   975
COLORREF CheckGrayColor(GDIWinSDOps *wsdo, int c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    if (wsdo->device->GetGrayness() != GS_NOTGRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        int g = (77 *(c & 0xFF) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                 150*((c >> 8) & 0xFF) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                 29 *((c >> 16) & 0xFF) + 128) / 256;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        c = g | (g << 8) | (g << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    return COLORFOR(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   985
static HDC GDIWinSD_GetDC(JNIEnv *env, GDIWinSDOps *wsdo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                         jint type, jint *patrop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                         jobject clip, jobject comp, jint color)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   989
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_GetDC");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    if (wsdo->invalid == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        if (beingShutdown != JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            SurfaceData_ThrowInvalidPipeException(env, "bounds changed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        return (HDC) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    ThreadGraphicsInfo *info = GetThreadGraphicsInfo(env, wsdo);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   999
    GDIWinSD_InitDC(env, wsdo, info, type, patrop, clip, comp, color);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    return info->hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
JNIEXPORT void JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1004
GDIWinSD_InitDC(JNIEnv *env, GDIWinSDOps *wsdo, ThreadGraphicsInfo *info,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
               jint type, jint *patrop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
               jobject clip, jobject comp, jint color)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1008
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_InitDC");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    // init clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    if (clip == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        if (info->type & CLIP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            ::SelectClipRgn(info->hDC, (HRGN) NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            info->type ^= CLIP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        if (info->clip != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            env->DeleteWeakGlobalRef(info->clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            info->clip = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    } else if (!env->IsSameObject(clip, info->clip)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
        SurfaceDataBounds span;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        RegionData clipInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        if (Region_GetInfo(env, clip, &clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            // return; // REMIND: What to do here?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        if (Region_IsEmpty(&clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            HRGN hrgn = ::CreateRectRgn(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            ::SelectClipRgn(info->hDC, hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            ::DeleteObject(hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            info->type |= CLIP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        } else if (Region_IsRectangular(&clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            if (clipInfo.bounds.x1 <= info->bounds.left &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                clipInfo.bounds.y1 <= info->bounds.top &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                clipInfo.bounds.x2 >= info->bounds.right &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                clipInfo.bounds.y2 >= info->bounds.bottom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                if (info->type & CLIP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                    ::SelectClipRgn(info->hDC, (HRGN) NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                    info->type ^= CLIP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                // Make the window-relative rect a client-relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                // one for Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                HRGN hrgn =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                    ::CreateRectRgn(clipInfo.bounds.x1 - wsdo->insets.left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                                    clipInfo.bounds.y1 - wsdo->insets.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                                    clipInfo.bounds.x2 - wsdo->insets.left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                                    clipInfo.bounds.y2 - wsdo->insets.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                ::SelectClipRgn(info->hDC, hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                ::DeleteObject(hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                info->type |= CLIP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            int leftInset = wsdo->insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            int topInset = wsdo->insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            Region_StartIteration(env, &clipInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            jint numrects = Region_CountIterationRects(&clipInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            DWORD nCount = sizeof(RGNDATAHEADER) + numrects * sizeof(RECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            RGNDATA *lpRgnData = (RGNDATA *) safe_Malloc(nCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            lpRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            lpRgnData->rdh.iType = RDH_RECTANGLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            lpRgnData->rdh.nCount = numrects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            lpRgnData->rdh.nRgnSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
            lpRgnData->rdh.rcBound.left = clipInfo.bounds.x1 - leftInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
            lpRgnData->rdh.rcBound.top = clipInfo.bounds.y1 - topInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            lpRgnData->rdh.rcBound.right = clipInfo.bounds.x2 - leftInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
            lpRgnData->rdh.rcBound.bottom = clipInfo.bounds.y2 - topInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
            RECT *pRect = (RECT *) &(((RGNDATA *)lpRgnData)->Buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            while (Region_NextIteration(&clipInfo, &span)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                pRect->left = span.x1 - leftInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                pRect->top = span.y1 - topInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                pRect->right = span.x2 - leftInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                pRect->bottom = span.y2 - topInset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                pRect++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
            Region_EndIteration(env, &clipInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            HRGN hrgn = ::ExtCreateRegion(NULL, nCount, lpRgnData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
            free(lpRgnData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            ::SelectClipRgn(info->hDC, hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            ::DeleteObject(hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            info->type |= CLIP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        if (info->clip != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            env->DeleteWeakGlobalRef(info->clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        info->clip = env->NewWeakGlobalRef(clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    // init composite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    if ((comp == NULL) || !env->IsInstanceOf(comp, xorCompClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        if (info->comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            env->DeleteWeakGlobalRef(info->comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            info->comp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            info->patrop = PATCOPY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            ::SetROP2(info->hDC, R2_COPYPEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        if (!env->IsSameObject(comp, info->comp)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
            info->xorcolor = GrPrim_CompGetXorColor(env, comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            if (info->comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                env->DeleteWeakGlobalRef(info->comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            info->comp = env->NewWeakGlobalRef(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            info->patrop = PATINVERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            ::SetROP2(info->hDC, R2_XORPEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        color ^= info->xorcolor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    if (patrop != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        *patrop = info->patrop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    // init brush and pen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    if (type & BRUSH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        if (info->brushclr != color || (info->brush == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            if (info->type & BRUSH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                ::SelectObject(info->hDC, nullbrush);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                info->type ^= BRUSH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            if (info->brush != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                info->brush->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            info->brush = AwtBrush::Get(CheckGrayColor(wsdo, color));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            info->brushclr = color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        if ((info->type & BRUSH) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            ::SelectObject(info->hDC, info->brush->GetHandle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            info->type ^= BRUSH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    } else if (type & NOBRUSH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
        if (info->type & BRUSH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
            ::SelectObject(info->hDC, nullbrush);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            info->type ^= BRUSH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    if (type & PEN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        if (info->penclr != color || (info->pen == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            if (info->type & PEN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                ::SelectObject(info->hDC, nullpen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                info->type ^= PEN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            if (info->pen != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                info->pen->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            info->pen = AwtPen::Get(CheckGrayColor(wsdo, color));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
            info->penclr = color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        if ((info->type & PEN) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            ::SelectObject(info->hDC, info->pen->GetHandle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            info->type ^= PEN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    } else if (type & NOPEN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        if (info->type & PEN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            ::SelectObject(info->hDC, nullpen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
            info->type ^= PEN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1162
static void GDIWinSD_ReleaseDC(JNIEnv *env, GDIWinSDOps *wsdo, HDC hDC)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1164
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_ReleaseDC");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    // Don't actually do anything here: every thread holds its own
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    // wsdo-specific DC until the thread goes away or the wsdo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    // is disposed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1171
static void GDIWinSD_InvalidateSD(JNIEnv *env, GDIWinSDOps *wsdo)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1173
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_InvalidateSD");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  wsdo=0x%x wsdo->window=0x%x",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                wsdo, wsdo->window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    wsdo->invalid = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
/*
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1183
 * Method:    GDIWinSD_Dispose
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
static void
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1186
GDIWinSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1188
    J2dTraceLn(J2D_TRACE_INFO, "GDIWinSD_Dispose");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    // ops is assumed non-null as it is checked in SurfaceData_DisposeOps
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1190
    GDIWinSDOps *wsdo = (GDIWinSDOps*)ops;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    if (wsdo->bitmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        // delete old objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        J2dTraceLn(J2D_TRACE_VERBOSE, "  disposing the GDI bitmap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        if (wsdo->bmdc) {   // should not be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            ::SelectObject(wsdo->bmdc, wsdo->oldmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
            ::DeleteDC(wsdo->bmdc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
            wsdo->bmdc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        ::DeleteObject(wsdo->bitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        wsdo->bitmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    env->DeleteWeakGlobalRef(wsdo->peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    if (wsdo->device != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        wsdo->device->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        wsdo->device = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    delete wsdo->surfaceLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
/*
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1212
 * Class:     sun_java2d_windows_GDIWindowSurfaceData
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
 * Method:    invalidateSD
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
JNIEXPORT void JNICALL
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1217
Java_sun_java2d_windows_GDIWindowSurfaceData_invalidateSD(JNIEnv *env, jobject wsd)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
{
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1219
    J2dTraceLn(J2D_TRACE_INFO, "GDIWindowSurfaceData_invalidateSD");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1220
    GDIWinSDOps *wsdo = GDIWindowSurfaceData_GetOpsNoSetup(env, wsd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
    if (wsdo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        wsdo->InvalidateSD(env, wsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
}