1 /* 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.prism.es2; 27 28 import java.security.AccessController; 29 import java.security.PrivilegedAction; 30 31 import com.sun.glass.utils.NativeLibLoader; 32 import com.sun.javafx.PlatformUtil; 33 import com.sun.prism.impl.PrismSettings; 34 35 class GLPixelFormat { 36 final private Attributes attributes; 37 final private long nativeScreen; 38 private long nativePFInfo; 39 private static int defaultDepthSize; 40 private static int defaultBufferSize; 41 42 static { 43 AccessController.doPrivileged((PrivilegedAction<Void>) () -> { 44 defaultDepthSize = Integer.getInteger("prism.glDepthSize", 24); 45 defaultBufferSize = Integer.getInteger("prism.glBufferSize", 32); 46 return null; 47 }); 48 } 49 50 GLPixelFormat(long nativeScreen, Attributes attributes) { 51 this.nativeScreen = nativeScreen; 52 this.attributes = attributes; 53 } 54 55 Attributes getAttributes() { 56 return attributes; 57 } 58 59 long getNativeScreen() { 60 return nativeScreen; 61 } 62 63 void setNativePFInfo(long nativePFInfo) { 64 this.nativePFInfo = nativePFInfo; 65 } 66 67 long getNativePFInfo() { 68 return nativePFInfo; 69 } 70 71 static class Attributes { 72 // These definitions are used by both the Mac, Win and X11 subclasses 73 final static int RED_SIZE = 0; 74 final static int GREEN_SIZE = 1; 75 final static int BLUE_SIZE = 2; 76 final static int ALPHA_SIZE = 3; 77 final static int DEPTH_SIZE = 4; 78 final static int DOUBLEBUFFER = 5; 79 final static int ONSCREEN = 6; 80 81 final static int NUM_ITEMS = 7; 82 83 private boolean onScreen; 84 private boolean doubleBuffer; 85 private int alphaSize; 86 private int blueSize; 87 private int greenSize; 88 private int redSize; 89 private int depthSize; 90 91 Attributes() { 92 onScreen = true; 93 doubleBuffer = true; 94 depthSize = defaultDepthSize; 95 switch (defaultBufferSize) { 96 case 32: 97 redSize = greenSize = blueSize = alphaSize = 8; 98 break; 99 case 24: 100 redSize = greenSize = blueSize = 8; 101 alphaSize = 0; 102 break; 103 case 16: 104 redSize = blueSize = 5; 105 greenSize = 6; 106 alphaSize = 0; 107 break; 108 default: 109 throw new IllegalArgumentException("color buffer size " 110 + defaultBufferSize + " not supported"); 111 } 112 } 113 114 boolean isOnScreen() { 115 return onScreen; 116 } 117 118 boolean isDoubleBuffer() { 119 return doubleBuffer; 120 } 121 122 int getDepthSize() { 123 return depthSize; 124 } 125 126 int getAlphaSize() { 127 return alphaSize; 128 } 129 130 int getBlueSize() { 131 return blueSize; 132 } 133 134 int getGreenSize() { 135 return greenSize; 136 } 137 138 int getRedSize() { 139 return redSize; 140 } 141 142 void setOnScreen(boolean os) { 143 onScreen = os; 144 } 145 146 void setDoubleBuffer(boolean db) { 147 doubleBuffer = db; 148 } 149 150 void setDepthSize(int ds) { 151 depthSize = ds; 152 } 153 154 void setAlphaSize(int as) { 155 alphaSize = as; 156 } 157 158 void setBlueSize(int bs) { 159 blueSize = bs; 160 } 161 162 void setGreenSize(int gs) { 163 greenSize = gs; 164 } 165 166 void setRedSize(int rs) { 167 redSize = rs; 168 } 169 170 public String toString() { 171 return "onScreen: " + onScreen 172 + "redSize : " + redSize + ", " 173 + "greenSize : " + greenSize + ", " 174 + "blueSize : " + blueSize + ", " 175 + "alphaSize : " + alphaSize + ", " 176 + "depthSize : " + depthSize + ", " 177 + "doubleBuffer : " + doubleBuffer; 178 } 179 } 180 }