Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.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 java.awt.Color;28import java.awt.Transparency;29import sun.java2d.SurfaceData;30import sun.java2d.SurfaceDataProxy;31import sun.java2d.loops.CompositeType;3233/**34* The proxy class contains the logic if to replace a SurfaceData with a35* cached X11 Pixmap and the code to create the accelerated surfaces.36*/37public class XRSurfaceDataProxy extends SurfaceDataProxy implements Transparency {3839public static SurfaceDataProxy createProxy(SurfaceData srcData,40XRGraphicsConfig dstConfig) {4142/*Don't cache already native surfaces*/43if (srcData instanceof XRSurfaceData) {44return UNCACHED;45}4647return new XRSurfaceDataProxy(dstConfig, srcData.getTransparency());48}4950XRGraphicsConfig xrgc;51int transparency;5253public XRSurfaceDataProxy(XRGraphicsConfig x11gc) {54this.xrgc = x11gc;55}5657@Override58public SurfaceData validateSurfaceData(SurfaceData srcData,59SurfaceData cachedData, int w, int h) {60if (cachedData == null) {61try {62cachedData = XRSurfaceData.createData(xrgc, w, h,63xrgc.getColorModel(), null, 0,64getTransparency());65} catch (OutOfMemoryError oome) {66}67}68return cachedData;69}7071public XRSurfaceDataProxy(XRGraphicsConfig x11gc, int transparency) {72this.xrgc = x11gc;73this.transparency = transparency;74}7576//TODO: Is that really ok?77@Override78public boolean isSupportedOperation(SurfaceData srcData, int txtype,79CompositeType comp, Color bgColor) {80return (bgColor == null || transparency == Transparency.TRANSLUCENT);81}8283public int getTransparency() {84return transparency;85}86}878889