Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java
32288 views
/*1* Copyright (c) 2008, 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.d3d;2627import java.awt.Color;28import java.awt.Transparency;2930import sun.java2d.InvalidPipeException;31import sun.java2d.SurfaceData;32import sun.java2d.SurfaceDataProxy;33import sun.java2d.loops.CompositeType;3435/**36* The proxy class contains the logic for when to replace a37* SurfaceData with a cached D3D Texture and the code to create38* the accelerated surfaces.39*/40public class D3DSurfaceDataProxy extends SurfaceDataProxy {4142public static SurfaceDataProxy createProxy(SurfaceData srcData,43D3DGraphicsConfig dstConfig)44{45if (srcData instanceof D3DSurfaceData) {46// srcData must be a VolatileImage which either matches47// our pixel format or not - either way we do not cache it...48return UNCACHED;49}5051return new D3DSurfaceDataProxy(dstConfig, srcData.getTransparency());52}5354D3DGraphicsConfig d3dgc;55int transparency;5657public D3DSurfaceDataProxy(D3DGraphicsConfig d3dgc, int transparency) {58this.d3dgc = d3dgc;59this.transparency = transparency;60// REMIND: we may want to change this for the d3d pipeline, it's not61// necessary to invalidate them all at once on display change62activateDisplayListener();63}6465@Override66public SurfaceData validateSurfaceData(SurfaceData srcData,67SurfaceData cachedData,68int w, int h)69{70if (cachedData == null || cachedData.isSurfaceLost()) {71try {72cachedData = d3dgc.createManagedSurface(w, h, transparency);73} catch (InvalidPipeException e) {74if (!d3dgc.getD3DDevice().isD3DAvailable()) {75invalidate();76flush();77return null;78}79}80}81return cachedData;82}8384@Override85public boolean isSupportedOperation(SurfaceData srcData,86int txtype,87CompositeType comp,88Color bgColor)89{90return (bgColor == null || transparency == Transparency.OPAQUE);91}92}939495