/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* XRender constants and utility methods.
*
* @author Clemens Eisserer
*/
public class XRUtils {
/* Composition Operators */
/* Repeats */
/* Interpolation qualities */
/* PictFormats */
/**
* Maps the specified affineTransformOp to the corresponding XRender image
* filter.
*/
switch (affineTranformOp) {
return FAST;
return GOOD;
return BEST;
}
return -1;
}
/**
* Maps the specified affineTransformOp to the corresponding XRender image
* filter.
*/
switch (affineTranformOp) {
return FAST_NAME;
return GOOD_NAME;
return BEST_NAME;
}
return null;
}
switch (filterType) {
case FAST:
return FAST_NAME;
case GOOD:
return GOOD_NAME;
case BEST:
return BEST_NAME;
}
return null;
}
/**
* Returns the XRender picture Format which is required to fullfill the
* Java2D transparency requirement.
*/
switch (transparency) {
case Transparency.OPAQUE:
return PictStandardRGB24;
case Transparency.BITMASK:
case Transparency.TRANSLUCENT:
return PictStandardARGB32;
}
return -1;
}
return SurfaceType.IntRgb;
}else {
return SurfaceType.IntArgbPre;
}
}
/**
* Maps Java2D CycleMethod to XRender's Repeat property.
*/
return RepeatPad;
return RepeatReflect;
return RepeatNormal;
}
return RepeatNone;
}
/**
* Converts a double into an XFixed.
*/
return (int) (dbl * 65536);
}
return ((double) fixed) / 65536;
}
}
return fixed;
}
if (signed < 0) {
}
return signed;
}
/**
* Maps the specified Java2D composition rule, to the corresponding XRender
* composition rule.
*/
switch (j2dRule) {
case CLEAR:
return PictOpClear;
case SRC:
return PictOpSrc;
case DST:
return PictOpDst;
case SRC_OVER:
return PictOpOver;
case DST_OVER:
return PictOpOverReverse;
case SRC_IN:
return PictOpIn;
case DST_IN:
return PictOpInReverse;
case SRC_OUT:
return PictOpOut;
case DST_OUT:
return PictOpOutReverse;
case SRC_ATOP:
return PictOpAtop;
case DST_ATOP:
return PictOpAtopReverse;
case XOR:
return PictOpXor;
}
throw new InternalError("No XRender equivalent available for requested java2d composition rule: "+j2dRule);
}
public static short clampToShort(int x) {
}
public static short clampToUShort(int x) {
return (short) (x > 65535 ? 65535 : (x < 0) ? 0 : x);
}
}