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/Apackage sun.java2d.opengl;
0N/A
0N/Aimport java.awt.Color;
0N/Aimport java.awt.Image;
0N/Aimport java.awt.geom.AffineTransform;
0N/Aimport java.awt.image.AffineTransformOp;
0N/Aimport java.awt.image.BufferedImage;
0N/Aimport java.awt.image.BufferedImageOp;
0N/Aimport sun.java2d.SunGraphics2D;
0N/Aimport sun.java2d.SurfaceData;
0N/Aimport sun.java2d.loops.SurfaceType;
0N/Aimport sun.java2d.loops.TransformBlit;
0N/Aimport sun.java2d.pipe.DrawImage;
0N/A
0N/Apublic class OGLDrawImage extends DrawImage {
0N/A
0N/A @Override
0N/A protected void renderImageXform(SunGraphics2D sg, Image img,
0N/A AffineTransform tx, int interpType,
0N/A int sx1, int sy1, int sx2, int sy2,
0N/A Color bgColor)
0N/A {
0N/A // punt to the MediaLib-based transformImage() in the superclass if:
0N/A // - bicubic interpolation is specified
0N/A // - a background color is specified and will be used
0N/A // - the source surface is neither a texture nor render-to-texture
0N/A // surface, and a non-default interpolation hint is specified
0N/A // (we can only control the filtering for texture->surface
0N/A // copies)
0N/A // REMIND: we should tweak the sw->texture->surface
0N/A // transform case to handle filtering appropriately
0N/A // (see 4841762)...
0N/A // - an appropriate TransformBlit primitive could not be found
0N/A if (interpType != AffineTransformOp.TYPE_BICUBIC) {
0N/A SurfaceData dstData = sg.surfaceData;
0N/A SurfaceData srcData =
0N/A dstData.getSourceSurfaceData(img,
0N/A sg.TRANSFORM_GENERIC,
0N/A sg.imageComp,
0N/A bgColor);
0N/A
0N/A if (srcData != null &&
0N/A !isBgOperation(srcData, bgColor) &&
0N/A (srcData.getSurfaceType() == OGLSurfaceData.OpenGLTexture ||
0N/A srcData.getSurfaceType() == OGLSurfaceData.OpenGLSurfaceRTT ||
0N/A interpType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR))
0N/A {
0N/A SurfaceType srcType = srcData.getSurfaceType();
0N/A SurfaceType dstType = dstData.getSurfaceType();
0N/A TransformBlit blit = TransformBlit.getFromCache(srcType,
0N/A sg.imageComp,
0N/A dstType);
0N/A
0N/A if (blit != null) {
0N/A blit.Transform(srcData, dstData,
0N/A sg.composite, sg.getCompClip(),
0N/A tx, interpType,
0N/A sx1, sy1, 0, 0, sx2-sx1, sy2-sy1);
0N/A return;
0N/A }
0N/A }
0N/A }
0N/A
0N/A super.renderImageXform(sg, img, tx, interpType,
0N/A sx1, sy1, sx2, sy2, bgColor);
0N/A }
0N/A
0N/A @Override
0N/A public void transformImage(SunGraphics2D sg, BufferedImage img,
0N/A BufferedImageOp op, int x, int y)
0N/A {
0N/A if (op != null) {
0N/A if (op instanceof AffineTransformOp) {
0N/A AffineTransformOp atop = (AffineTransformOp) op;
0N/A transformImage(sg, img, x, y,
0N/A atop.getTransform(),
0N/A atop.getInterpolationType());
0N/A return;
0N/A } else {
0N/A if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
0N/A return;
0N/A }
0N/A }
0N/A img = op.filter(img, null);
0N/A }
0N/A copyImage(sg, img, x, y, null);
0N/A }
0N/A}