Path: blob/master/src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskFill.java
41159 views
/*1* Copyright (c) 2019, 2021, 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*/24package sun.java2d.metal;2526import sun.java2d.InvalidPipeException;27import sun.java2d.SunGraphics2D;28import sun.java2d.loops.CompositeType;29import sun.java2d.loops.GraphicsPrimitive;30import sun.java2d.loops.GraphicsPrimitiveMgr;31import sun.java2d.loops.SurfaceType;32import sun.java2d.pipe.BufferedMaskFill;3334import java.awt.Composite;3536import static sun.java2d.loops.CompositeType.SrcNoEa;37import static sun.java2d.loops.CompositeType.SrcOver;38import static sun.java2d.loops.SurfaceType.*;3940class MTLMaskFill extends BufferedMaskFill {4142static void register() {43GraphicsPrimitive[] primitives = {44new MTLMaskFill(AnyColor, SrcOver),45new MTLMaskFill(OpaqueColor, SrcNoEa),46new MTLMaskFill(GradientPaint, SrcOver),47new MTLMaskFill(OpaqueGradientPaint, SrcNoEa),48new MTLMaskFill(LinearGradientPaint, SrcOver),49new MTLMaskFill(OpaqueLinearGradientPaint, SrcNoEa),50new MTLMaskFill(RadialGradientPaint, SrcOver),51new MTLMaskFill(OpaqueRadialGradientPaint, SrcNoEa),52new MTLMaskFill(TexturePaint, SrcOver),53new MTLMaskFill(OpaqueTexturePaint, SrcNoEa),54};55GraphicsPrimitiveMgr.register(primitives);56}5758protected MTLMaskFill(SurfaceType srcType, CompositeType compType) {59super(MTLRenderQueue.getInstance(),60srcType, compType, MTLSurfaceData.MTLSurface);61}6263@Override64protected native void maskFill(int x, int y, int w, int h,65int maskoff, int maskscan, int masklen,66byte[] mask);6768@Override69protected void validateContext(SunGraphics2D sg2d,70Composite comp, int ctxflags)71{72MTLSurfaceData dstData;73try {74dstData = (MTLSurfaceData) sg2d.surfaceData;75} catch (ClassCastException e) {76throw new InvalidPipeException("wrong surface data type: " +77sg2d.surfaceData);78}7980MTLContext.validateContext(dstData, dstData,81sg2d.getCompClip(), comp,82null, sg2d.paint, sg2d, ctxflags);83}84}858687