Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java
32288 views
/*1* Copyright (c) 2010, 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.xr;2627import static sun.java2d.loops.CompositeType.SrcNoEa;2829import static sun.java2d.loops.CompositeType.SrcOver;30import static sun.java2d.loops.SurfaceType.AnyColor;31import static sun.java2d.loops.SurfaceType.GradientPaint;32import static sun.java2d.loops.SurfaceType.LinearGradientPaint;33import static sun.java2d.loops.SurfaceType.OpaqueColor;34import static sun.java2d.loops.SurfaceType.OpaqueGradientPaint;35import static sun.java2d.loops.SurfaceType.OpaqueLinearGradientPaint;36import static sun.java2d.loops.SurfaceType.OpaqueRadialGradientPaint;37import static sun.java2d.loops.SurfaceType.OpaqueTexturePaint;38import static sun.java2d.loops.SurfaceType.RadialGradientPaint;39import static sun.java2d.loops.SurfaceType.TexturePaint;4041import java.awt.*;42import sun.awt.*;43import sun.java2d.*;44import sun.java2d.loops.*;4546public class XRMaskFill extends MaskFill {47static void register() {48GraphicsPrimitive[] primitives = {49new XRMaskFill(AnyColor, SrcOver, XRSurfaceData.IntRgbX11),50new XRMaskFill(OpaqueColor, SrcNoEa, XRSurfaceData.IntRgbX11),51new XRMaskFill(GradientPaint, SrcOver, XRSurfaceData.IntRgbX11),52new XRMaskFill(OpaqueGradientPaint, SrcNoEa,53XRSurfaceData.IntRgbX11),54new XRMaskFill(LinearGradientPaint, SrcOver,55XRSurfaceData.IntRgbX11),56new XRMaskFill(OpaqueLinearGradientPaint, SrcNoEa,57XRSurfaceData.IntRgbX11),58new XRMaskFill(RadialGradientPaint, SrcOver,59XRSurfaceData.IntRgbX11),60new XRMaskFill(OpaqueRadialGradientPaint, SrcNoEa,61XRSurfaceData.IntRgbX11),62new XRMaskFill(TexturePaint, SrcOver, XRSurfaceData.IntRgbX11),63new XRMaskFill(OpaqueTexturePaint, SrcNoEa,64XRSurfaceData.IntRgbX11),6566new XRMaskFill(AnyColor, SrcOver, XRSurfaceData.IntArgbPreX11),67new XRMaskFill(OpaqueColor, SrcNoEa, XRSurfaceData.IntArgbPreX11),68new XRMaskFill(GradientPaint, SrcOver, XRSurfaceData.IntArgbPreX11),69new XRMaskFill(OpaqueGradientPaint, SrcNoEa,70XRSurfaceData.IntArgbPreX11),71new XRMaskFill(LinearGradientPaint, SrcOver,72XRSurfaceData.IntArgbPreX11),73new XRMaskFill(OpaqueLinearGradientPaint, SrcNoEa,74XRSurfaceData.IntArgbPreX11),75new XRMaskFill(RadialGradientPaint, SrcOver,76XRSurfaceData.IntArgbPreX11),77new XRMaskFill(OpaqueRadialGradientPaint, SrcNoEa,78XRSurfaceData.IntArgbPreX11),79new XRMaskFill(TexturePaint, SrcOver, XRSurfaceData.IntArgbPreX11),80new XRMaskFill(OpaqueTexturePaint, SrcNoEa,81XRSurfaceData.IntArgbPreX11)82};8384GraphicsPrimitiveMgr.register(primitives);85}8687protected XRMaskFill(SurfaceType srcType, CompositeType compType,88SurfaceType surfaceType) {89super(srcType, compType, surfaceType);90}9192protected native void maskFill(long xsdo, int x, int y, int w, int h,93int maskoff, int maskscan, int masklen, byte[] mask);9495public void MaskFill(SunGraphics2D sg2d, SurfaceData sData, Composite comp,96final int x, final int y, final int w, final int h,97final byte[] mask, final int maskoff, final int maskscan) {98try {99SunToolkit.awtLock();100101XRSurfaceData x11sd = (XRSurfaceData) sData;102x11sd.validateAsDestination(null, sg2d.getCompClip());103104XRCompositeManager maskBuffer = x11sd.maskBuffer;105maskBuffer.validateCompositeState(comp, sg2d.transform, sg2d.paint, sg2d);106107int maskPict = maskBuffer.getMaskBuffer().uploadMask(w, h, maskscan, maskoff, mask);108maskBuffer.XRComposite(XRUtils.None, maskPict, x11sd.picture, x, y, 0, 0, x, y, w, h);109maskBuffer.getMaskBuffer().clearUploadMask(maskPict, w, h);110} finally {111SunToolkit.awtUnlock();112}113}114}115116117