Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/FillSpans.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 "jni_util.h"26#include "jlong.h"2728#include "sun_java2d_loops_FillSpans.h"2930#include "GraphicsPrimitiveMgr.h"3132/*33* Class: sun_java2d_loops_FillSpans34* Method: FillSpans35* Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Lsun/java2d/pipe/SpanIterator;)V36*/37JNIEXPORT void JNICALL38Java_sun_java2d_loops_FillSpans_FillSpans39(JNIEnv *env, jobject self,40jobject sg2d, jobject sData, jint pixel, jlong pIterator, jobject si)41{42SpanIteratorFuncs *pSpanFuncs;43SurfaceDataOps *sdOps;44SurfaceDataRasInfo rasInfo;45void *siData;46jint bbox[4];47NativePrimitive *pPrim;48CompositeInfo compInfo;4950pSpanFuncs = (SpanIteratorFuncs *) jlong_to_ptr(pIterator);51if (pSpanFuncs == NULL) {52JNU_ThrowNullPointerException(env, "native iterator not supplied");53return;54}5556pPrim = GetNativePrim(env, self);57if (pPrim == NULL) {58return;59}60if (pPrim->pCompType->getCompInfo != NULL) {61GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);62}6364sdOps = SurfaceData_GetOps(env, sData);65if (sdOps == NULL) {66return;67}6869siData = (*pSpanFuncs->open)(env, si);7071(*pSpanFuncs->getPathBox)(env, siData, bbox);72rasInfo.bounds.x1 = bbox[0];73rasInfo.bounds.y1 = bbox[1];74rasInfo.bounds.x2 = bbox[2];75rasInfo.bounds.y2 = bbox[3];7677if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {78/* Lock threw an exception */79(*pSpanFuncs->close)(env, siData);80return;81}82(*pSpanFuncs->intersectClipBox)(env, siData,83rasInfo.bounds.x1,84rasInfo.bounds.y1,85rasInfo.bounds.x2,86rasInfo.bounds.y2);8788sdOps->GetRasInfo(env, sdOps, &rasInfo);89/* Protect against silent failure of GetRasInfo */90if (rasInfo.rasBase != NULL) {91pPrim->funcs.fillspans(&rasInfo, pSpanFuncs, siData,92pixel, pPrim, &compInfo);93}9495SurfaceData_InvokeRelease(env, sdOps, &rasInfo);96(*pSpanFuncs->close)(env, siData);97SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);98}99100101