Path: blob/master/src/java.desktop/share/native/common/java2d/opengl/OGLMaskBlit.c
41159 views
/*1* Copyright (c) 2003, 2007, 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#ifndef HEADLESS2627#include <stdlib.h>28#include <jlong.h>2930#include "OGLMaskBlit.h"31#include "OGLRenderQueue.h"32#include "OGLSurfaceData.h"3334/**35* REMIND: This method assumes that the dimensions of the incoming pixel36* array are less than or equal to the cached blit texture tile;37* these are rather fragile assumptions, and should be cleaned up...38*/39void40OGLMaskBlit_MaskBlit(JNIEnv *env, OGLContext *oglc,41jint dstx, jint dsty,42jint width, jint height,43void *pPixels)44{45GLfloat tx1, ty1, tx2, ty2;4647J2dTraceLn(J2D_TRACE_INFO, "OGLMaskBlit_MaskBlit");4849if (width <= 0 || height <= 0) {50J2dTraceLn(J2D_TRACE_WARNING,51"OGLMaskBlit_MaskBlit: invalid dimensions");52return;53}5455RETURN_IF_NULL(pPixels);56RETURN_IF_NULL(oglc);57CHECK_PREVIOUS_OP(GL_TEXTURE_2D);5859if (oglc->blitTextureID == 0) {60if (!OGLContext_InitBlitTileTexture(oglc)) {61J2dRlsTraceLn(J2D_TRACE_ERROR,62"OGLMaskBlit_MaskBlit: could not init blit tile");63return;64}65}6667// set up texture parameters68j2d_glBindTexture(GL_TEXTURE_2D, oglc->blitTextureID);69OGLC_UPDATE_TEXTURE_FUNCTION(oglc, GL_MODULATE);70j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);71j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);7273// copy system memory IntArgbPre surface into cached texture74j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,750, 0, width, height,76GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pPixels);7778tx1 = 0.0f;79ty1 = 0.0f;80tx2 = ((GLfloat)width) / OGLC_BLIT_TILE_SIZE;81ty2 = ((GLfloat)height) / OGLC_BLIT_TILE_SIZE;8283// render cached texture to the OpenGL surface84j2d_glBegin(GL_QUADS);85j2d_glTexCoord2f(tx1, ty1); j2d_glVertex2i(dstx, dsty);86j2d_glTexCoord2f(tx2, ty1); j2d_glVertex2i(dstx + width, dsty);87j2d_glTexCoord2f(tx2, ty2); j2d_glVertex2i(dstx + width, dsty + height);88j2d_glTexCoord2f(tx1, ty2); j2d_glVertex2i(dstx, dsty + height);89j2d_glEnd();90}9192#endif /* !HEADLESS */939495