aboutsummaryrefslogtreecommitdiff
path: root/src/windows/native/sun/java2d/windows/DDRenderer.cpp
blob: 258a7beedeb614eb5e626bc7632cda5e5ff3223c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */

#include "sun_java2d_windows_DDRenderer.h"
#include "Win32SurfaceData.h"

#include <ddraw.h>
#include "ddrawUtils.h"
#include "Trace.h"

/*
 * Class:     sun_java2d_windows_DDRenderer
 * Method:    doDrawLineDD
 * Signature: (Lsun/java2d/SurfaceData;IIIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_DDRenderer_doDrawLineDD
    (JNIEnv *env, jobject wr,
     jobject sData,
     jint color,
     jint x1, jint y1, jint x2, jint y2)
{
    Win32SDOps      *wsdo = Win32SurfaceData_GetOpsNoSetup(env, sData);
    RECT            fillRect;

    J2dTraceLn(J2D_TRACE_INFO, "DDRenderer_doDrawLineDD");

    // Assume x1 <= x2 and y1 <= y2 (that's the way the
    // Java code is written)
    fillRect.left = x1;
    fillRect.top = y1;
    fillRect.right = x2+1;
    fillRect.bottom = y2+1;
    DDColorFill(env, sData, wsdo, &fillRect, color);
}


/*
 * Class:     sun_java2d_windows_DDRenderer
 * Method:    doFillRect
 * Signature: (Lsun/java2d/SurfaceData;IIIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_DDRenderer_doFillRectDD
    (JNIEnv *env, jobject wr,
     jobject sData,
     jint color,
     jint left, jint top, jint right, jint bottom)
{
    Win32SDOps      *wsdo = Win32SurfaceData_GetOpsNoSetup(env, sData);
    RECT            fillRect;

    J2dTraceLn(J2D_TRACE_INFO, "DDRenderer_doFillRectDD");

    fillRect.left = left;
    fillRect.top = top;
    fillRect.right = right;
    fillRect.bottom = bottom;
    DDColorFill(env, sData, wsdo, &fillRect, color);
}


/*
 * Class:     sun_java2d_windows_DDRenderer
 * Method:    doDrawRectDD
 * Signature: (Lsun/java2d/SurfaceData;IIIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_DDRenderer_doDrawRectDD
    (JNIEnv *env, jobject wr,
     jobject sData,
     jint color,
     jint x, jint y, jint w, jint h)
{
    Win32SDOps      *wsdo = Win32SurfaceData_GetOpsNoSetup(env, sData);
    RECT            fillRect;

    J2dTraceLn(J2D_TRACE_INFO, "DDRenderer_doDrawRectDD");

    if (w == 0 || h == 0) {
        fillRect.left = x;
        fillRect.top = y;
        fillRect.right = w + 1;
        fillRect.bottom = h + 1;
        DDColorFill(env, sData, wsdo, &fillRect, color);
    }
    else {
        fillRect.left = x;
        fillRect.top = y;
        fillRect.right = x + w + 1;
        fillRect.bottom = y + 1;
        if (!DDColorFill(env, sData, wsdo, &fillRect, color))
            return;
        fillRect.top = y + 1;
        fillRect.right = x + 1;
        fillRect.bottom = y + h + 1;
        if (!DDColorFill(env, sData, wsdo, &fillRect, color))
            return;
        fillRect.left = x + 1;
        fillRect.top = y + h;
        fillRect.right = x + w + 1;
        fillRect.bottom = y + h + 1;
        if (!DDColorFill(env, sData, wsdo, &fillRect, color))
            return;
        fillRect.left = x + w;
        fillRect.top = y + 1;
        fillRect.bottom = y + h;
        if (!DDColorFill(env, sData, wsdo, &fillRect, color))
            return;
    }
}

/*
 * Class:     sun_java2d_windows_DDRenderer
 * Method:    devCopyArea
 * Signature: (Lsun/awt/windows/SurfaceData;IIIIII)V
 */
JNIEXPORT void JNICALL
Java_sun_java2d_windows_DDRenderer_devCopyArea
    (JNIEnv *env, jobject wr,
     jobject sData,
     jint srcx, jint srcy,
     jint dx, jint dy,
     jint width, jint height)
{
    Win32SDOps *wsdo = Win32SurfaceData_GetOpsNoSetup(env, sData);
    J2dTraceLn(J2D_TRACE_INFO, "DDRenderer_devCopyArea");
    J2dTrace4(J2D_TRACE_VERBOSE, "  sx=%-4d sy=%-4d dx=%-4d dy=%-4d",
                srcx, srcy, dx, dy);
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  w=%-4d h=%-4d", width, height);
    if (wsdo == NULL) {
        return;
    }

    RECT rSrc = {srcx, srcy, srcx + width, srcy + height};
    if (DDCanBlt(wsdo)) {
        RECT rDst = rSrc;
        ::OffsetRect(&rDst, dx, dy);

        DDBlt(env,wsdo, wsdo, &rDst, &rSrc);
        return;
    }
    HDC hDC = wsdo->GetDC(env, wsdo, 0, NULL, NULL, NULL, 0);
    if (hDC == NULL) {
        return;
    }

    VERIFY(::ScrollDC(hDC, dx, dy, &rSrc, NULL, NULL, NULL));
    wsdo->ReleaseDC(env, wsdo, hDC);
}