Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/FillRect.c
41159 views
/*1* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "GraphicsPrimitiveMgr.h"2627#include "sun_java2d_loops_FillRect.h"2829/*30* Class: sun_java2d_loops_FillRect31* Method: FillRect32* Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IIII)V33*/34JNIEXPORT void JNICALL35Java_sun_java2d_loops_FillRect_FillRect36(JNIEnv *env, jobject self,37jobject sg2d, jobject sData,38jint x, jint y, jint w, jint h)39{40SurfaceDataOps *sdOps;41SurfaceDataRasInfo rasInfo;42NativePrimitive *pPrim;43CompositeInfo compInfo;44jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);4546if (w <= 0 || h <= 0) {47return;48}4950pPrim = GetNativePrim(env, self);51if (pPrim == NULL) {52return;53}54if (pPrim->pCompType->getCompInfo != NULL) {55GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);56}5758sdOps = SurfaceData_GetOps(env, sData);59if (sdOps == 0) {60return;61}6263GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);64SurfaceData_IntersectBoundsXYWH(&rasInfo.bounds, x, y, w, h);65if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||66rasInfo.bounds.x2 <= rasInfo.bounds.x1)67{68return;69}7071if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {72return;73}7475if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&76rasInfo.bounds.y2 > rasInfo.bounds.y1)77{78sdOps->GetRasInfo(env, sdOps, &rasInfo);79if (rasInfo.rasBase) {80(*pPrim->funcs.fillrect)(&rasInfo,81rasInfo.bounds.x1, rasInfo.bounds.y1,82rasInfo.bounds.x2, rasInfo.bounds.y2,83pixel, pPrim, &compInfo);84}85SurfaceData_InvokeRelease(env, sdOps, &rasInfo);86}87SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);88}899091