0N/A/*
2362N/A * Copyright (c) 2003, 2007, 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#ifndef HEADLESS
0N/A
0N/A#include <stdlib.h>
0N/A#include <jlong.h>
0N/A
0N/A#include "OGLMaskBlit.h"
0N/A#include "OGLRenderQueue.h"
0N/A#include "OGLSurfaceData.h"
0N/A
0N/A/**
0N/A * REMIND: This method assumes that the dimensions of the incoming pixel
0N/A * array are less than or equal to the cached blit texture tile;
0N/A * these are rather fragile assumptions, and should be cleaned up...
0N/A */
0N/Avoid
0N/AOGLMaskBlit_MaskBlit(JNIEnv *env, OGLContext *oglc,
0N/A jint dstx, jint dsty,
0N/A jint width, jint height,
0N/A void *pPixels)
0N/A{
0N/A GLfloat tx1, ty1, tx2, ty2;
0N/A
0N/A J2dTraceLn(J2D_TRACE_INFO, "OGLMaskBlit_MaskBlit");
0N/A
0N/A if (width <= 0 || height <= 0) {
0N/A J2dTraceLn(J2D_TRACE_WARNING,
0N/A "OGLMaskBlit_MaskBlit: invalid dimensions");
0N/A return;
0N/A }
0N/A
0N/A RETURN_IF_NULL(pPixels);
0N/A RETURN_IF_NULL(oglc);
0N/A CHECK_PREVIOUS_OP(GL_TEXTURE_2D);
0N/A
0N/A if (oglc->blitTextureID == 0) {
0N/A if (!OGLContext_InitBlitTileTexture(oglc)) {
0N/A J2dRlsTraceLn(J2D_TRACE_ERROR,
0N/A "OGLMaskBlit_MaskBlit: could not init blit tile");
0N/A return;
0N/A }
0N/A }
0N/A
0N/A // set up texture parameters
0N/A j2d_glBindTexture(GL_TEXTURE_2D, oglc->blitTextureID);
0N/A OGLC_UPDATE_TEXTURE_FUNCTION(oglc, GL_MODULATE);
0N/A j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
0N/A j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
0N/A
0N/A // copy system memory IntArgbPre surface into cached texture
0N/A j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
0N/A 0, 0, width, height,
0N/A GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pPixels);
0N/A
0N/A tx1 = 0.0f;
0N/A ty1 = 0.0f;
0N/A tx2 = ((GLfloat)width) / OGLC_BLIT_TILE_SIZE;
0N/A ty2 = ((GLfloat)height) / OGLC_BLIT_TILE_SIZE;
0N/A
0N/A // render cached texture to the OpenGL surface
0N/A j2d_glBegin(GL_QUADS);
0N/A j2d_glTexCoord2f(tx1, ty1); j2d_glVertex2i(dstx, dsty);
0N/A j2d_glTexCoord2f(tx2, ty1); j2d_glVertex2i(dstx + width, dsty);
0N/A j2d_glTexCoord2f(tx2, ty2); j2d_glVertex2i(dstx + width, dsty + height);
0N/A j2d_glTexCoord2f(tx1, ty2); j2d_glVertex2i(dstx, dsty + height);
0N/A j2d_glEnd();
0N/A}
0N/A
0N/A#endif /* !HEADLESS */