1/*
2 * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#include "GraphicsPrimitiveMgr.h"
27
28#include "sun_java2d_loops_FillRect.h"
29
30/*
31 * Class: sun_java2d_loops_FillRect
32 * Method: FillRect
33 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IIII)V
34 */
35JNIEXPORT void JNICALL
36Java_sun_java2d_loops_FillRect_FillRect
37 (JNIEnv *env, jobject self,
38 jobject sg2d, jobject sData,
39 jint x, jint y, jint w, jint h)
40{
41 SurfaceDataOps *sdOps;
42 SurfaceDataRasInfo rasInfo;
43 NativePrimitive *pPrim;
44 CompositeInfo compInfo;
45 jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);
46
47 if (w <= 0 || h <= 0) {
48 return;
49 }
50
51 pPrim = GetNativePrim(env, self);
52 if (pPrim == NULL) {
53 return;
54 }
55 if (pPrim->pCompType->getCompInfo != NULL) {
56 GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
57 }
58
59 sdOps = SurfaceData_GetOps(env, sData);
60 if (sdOps == 0) {
61 return;
62 }
63
64 GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
65 SurfaceData_IntersectBoundsXYWH(&rasInfo.bounds, x, y, w, h);
66 if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
67 rasInfo.bounds.x2 <= rasInfo.bounds.x1)
68 {
69 return;
70 }
71
72 if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
73 return;
74 }
75
76 if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
77 rasInfo.bounds.y2 > rasInfo.bounds.y1)
78 {
79 sdOps->GetRasInfo(env, sdOps, &rasInfo);
80 if (rasInfo.rasBase) {
81 (*pPrim->funcs.fillrect)(&rasInfo,
82 rasInfo.bounds.x1, rasInfo.bounds.y1,
83 rasInfo.bounds.x2, rasInfo.bounds.y2,
84 pixel, pPrim, &compInfo);
85 }
86 SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
87 }
88 SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
89}
90