Path: blob/master/src/java.desktop/share/classes/sun/java2d/opengl/OGLDrawImage.java
41159 views
/*1* Copyright (c) 2003, 2011, 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*/2425package sun.java2d.opengl;2627import java.awt.Color;28import java.awt.Image;29import java.awt.geom.AffineTransform;30import java.awt.image.AffineTransformOp;31import java.awt.image.BufferedImage;32import java.awt.image.BufferedImageOp;33import sun.java2d.SunGraphics2D;34import sun.java2d.SurfaceData;35import sun.java2d.loops.SurfaceType;36import sun.java2d.loops.TransformBlit;37import sun.java2d.pipe.DrawImage;3839public class OGLDrawImage extends DrawImage {4041@Override42protected void renderImageXform(SunGraphics2D sg, Image img,43AffineTransform tx, int interpType,44int sx1, int sy1, int sx2, int sy2,45Color bgColor)46{47// punt to the MediaLib-based transformImage() in the superclass if:48// - bicubic interpolation is specified49// - a background color is specified and will be used50// - the source surface is neither a texture nor render-to-texture51// surface, and a non-default interpolation hint is specified52// (we can only control the filtering for texture->surface53// copies)54// REMIND: we should tweak the sw->texture->surface55// transform case to handle filtering appropriately56// (see 4841762)...57// - an appropriate TransformBlit primitive could not be found58if (interpType != AffineTransformOp.TYPE_BICUBIC) {59SurfaceData dstData = sg.surfaceData;60SurfaceData srcData =61dstData.getSourceSurfaceData(img,62SunGraphics2D.TRANSFORM_GENERIC,63sg.imageComp,64bgColor);6566if (srcData != null &&67!isBgOperation(srcData, bgColor) &&68(srcData.getSurfaceType() == OGLSurfaceData.OpenGLTexture ||69srcData.getSurfaceType() == OGLSurfaceData.OpenGLSurfaceRTT ||70interpType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR))71{72SurfaceType srcType = srcData.getSurfaceType();73SurfaceType dstType = dstData.getSurfaceType();74TransformBlit blit = TransformBlit.getFromCache(srcType,75sg.imageComp,76dstType);7778if (blit != null) {79blit.Transform(srcData, dstData,80sg.composite, sg.getCompClip(),81tx, interpType,82sx1, sy1, 0, 0, sx2-sx1, sy2-sy1);83return;84}85}86}8788super.renderImageXform(sg, img, tx, interpType,89sx1, sy1, sx2, sy2, bgColor);90}9192@Override93public void transformImage(SunGraphics2D sg, BufferedImage img,94BufferedImageOp op, int x, int y)95{96if (op != null) {97if (op instanceof AffineTransformOp) {98AffineTransformOp atop = (AffineTransformOp) op;99transformImage(sg, img, x, y,100atop.getTransform(),101atop.getInterpolationType());102return;103} else {104if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {105return;106}107}108img = op.filter(img, null);109}110copyImage(sg, img, x, y, null);111}112}113114115