0N/A/*
2362N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#include "GraphicsPrimitiveMgr.h"
0N/A#include "Region.h"
0N/A
0N/A#include "sun_java2d_loops_BlitBg.h"
0N/A
0N/A/*
0N/A * Class: sun_java2d_loops_BlitBg
0N/A * Method: BlitBg
430N/A * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;IIIIIII)V
0N/A */
0N/AJNIEXPORT void JNICALL Java_sun_java2d_loops_BlitBg_BlitBg
0N/A (JNIEnv *env, jobject self,
0N/A jobject srcData, jobject dstData,
430N/A jobject comp, jobject clip, jint bgColor,
0N/A jint srcx, jint srcy, jint dstx, jint dsty, jint width, jint height)
0N/A{
0N/A SurfaceDataOps *srcOps;
0N/A SurfaceDataOps *dstOps;
0N/A SurfaceDataRasInfo srcInfo;
0N/A SurfaceDataRasInfo dstInfo;
0N/A NativePrimitive *pPrim;
0N/A CompositeInfo compInfo;
0N/A RegionData clipInfo;
0N/A jint dstFlags;
0N/A
0N/A pPrim = GetNativePrim(env, self);
0N/A if (pPrim == NULL) {
0N/A return;
0N/A }
0N/A if (pPrim->pCompType->getCompInfo != NULL) {
0N/A (*pPrim->pCompType->getCompInfo)(env, &compInfo, comp);
0N/A }
0N/A if (Region_GetInfo(env, clip, &clipInfo)) {
0N/A return;
0N/A }
0N/A
0N/A srcOps = SurfaceData_GetOps(env, srcData);
0N/A dstOps = SurfaceData_GetOps(env, dstData);
0N/A if (srcOps == 0 || dstOps == 0) {
0N/A return;
0N/A }
0N/A
0N/A srcInfo.bounds.x1 = srcx;
0N/A srcInfo.bounds.y1 = srcy;
0N/A srcInfo.bounds.x2 = srcx + width;
0N/A srcInfo.bounds.y2 = srcy + height;
0N/A dstInfo.bounds.x1 = dstx;
0N/A dstInfo.bounds.y1 = dsty;
0N/A dstInfo.bounds.x2 = dstx + width;
0N/A dstInfo.bounds.y2 = dsty + height;
0N/A srcx -= dstx;
0N/A srcy -= dsty;
0N/A SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
0N/A if (srcOps->Lock(env, srcOps, &srcInfo, pPrim->srcflags) != SD_SUCCESS) {
0N/A return;
0N/A }
0N/A
0N/A dstFlags = pPrim->dstflags;
0N/A if (!Region_IsRectangular(&clipInfo)) {
0N/A dstFlags |= SD_LOCK_PARTIAL_WRITE;
0N/A }
0N/A if (dstOps->Lock(env, dstOps, &dstInfo, dstFlags) != SD_SUCCESS) {
0N/A SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
0N/A return;
0N/A }
0N/A SurfaceData_IntersectBlitBounds(&dstInfo.bounds, &srcInfo.bounds,
0N/A srcx, srcy);
0N/A Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
0N/A
0N/A if (!Region_IsEmpty(&clipInfo)) {
430N/A jint bgpixel = bgColor;
0N/A srcOps->GetRasInfo(env, srcOps, &srcInfo);
0N/A dstOps->GetRasInfo(env, dstOps, &dstInfo);
0N/A if (pPrim->pDstType->pixelFor) {
0N/A bgpixel = (*pPrim->pDstType->pixelFor)(&dstInfo, bgpixel);
0N/A }
0N/A if (srcInfo.rasBase && dstInfo.rasBase) {
0N/A SurfaceDataBounds span;
0N/A jint savesx = srcInfo.bounds.x1;
0N/A jint savedx = dstInfo.bounds.x1;
0N/A Region_StartIteration(env, &clipInfo);
0N/A while (Region_NextIteration(&clipInfo, &span)) {
0N/A void *pSrc = PtrCoord(srcInfo.rasBase,
0N/A srcx + span.x1, srcInfo.pixelStride,
0N/A srcy + span.y1, srcInfo.scanStride);
0N/A void *pDst = PtrCoord(dstInfo.rasBase,
0N/A span.x1, dstInfo.pixelStride,
0N/A span.y1, dstInfo.scanStride);
0N/A /*
0N/A * Fix for 4804375
0N/A * REMIND: There should probably be a better
0N/A * way to give the span coordinates to the
0N/A * inner loop. This is only really needed
0N/A * for the 1, 2, and 4 bit loops.
0N/A */
0N/A srcInfo.bounds.x1 = srcx + span.x1;
0N/A dstInfo.bounds.x1 = span.x1;
0N/A (*pPrim->funcs.blitbg)(pSrc, pDst,
0N/A span.x2 - span.x1, span.y2 - span.y1,
0N/A bgpixel,
0N/A &srcInfo, &dstInfo, pPrim, &compInfo);
0N/A }
0N/A Region_EndIteration(env, &clipInfo);
0N/A srcInfo.bounds.x1 = savesx;
0N/A dstInfo.bounds.x1 = savedx;
0N/A }
0N/A SurfaceData_InvokeRelease(env, dstOps, &dstInfo);
0N/A SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
0N/A }
0N/A SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
0N/A SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
0N/A}