1 /* 2 * Copyright (c) 2012, 2013, 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.glass.ui.lens; 27 28 import com.sun.glass.ui.Pixels; 29 import java.nio.Buffer; 30 import java.nio.ByteBuffer; 31 import java.nio.IntBuffer; 32 33 final class LensPixels extends Pixels { 34 35 protected LensPixels(int width, int height, ByteBuffer data) { 36 super(width, height, data); 37 } 38 39 protected LensPixels(int width, int height, IntBuffer data) { 40 super(width, height, data); 41 } 42 43 protected LensPixels(int width, int height, IntBuffer data, float scalex, float scaley) { 44 super(width, height, data, scalex, scaley); 45 } 46 47 static int getNativeFormat_impl() { 48 LensLogger.getLogger().config("Querying native format"); 49 // All our implementations use ARGB_PRE and convert to the native pixel 50 // format when we push pixels to the screen. 51 return Pixels.Format.BYTE_BGRA_PRE; 52 } 53 54 private native void _copyPixels(Buffer dst, Buffer src, int size); 55 56 @Override protected void _fillDirectByteBuffer(ByteBuffer bb) { 57 if (this.bytes != null) { 58 this.bytes.rewind(); 59 if (this.bytes.isDirect()) { 60 _copyPixels(bb, this.bytes, getWidth() * getHeight()); 61 } else { 62 bb.put(this.bytes); 63 } 64 this.bytes.rewind(); 65 } else { 66 this.ints.rewind(); 67 if (this.ints.isDirect()) { 68 _copyPixels(bb, this.ints, getWidth() * getHeight()); 69 } else { 70 for (int i = 0; i < this.ints.capacity(); i++) { 71 int data = this.ints.get(); 72 bb.put((byte)((data) & 0xff)); 73 bb.put((byte)((data >> 8) & 0xff)); 74 bb.put((byte)((data >> 16) & 0xff)); 75 bb.put((byte)((data >> 24) & 0xff)); 76 } 77 } 78 this.ints.rewind(); 79 } 80 bb.rewind(); 81 } 82 83 @Override protected void _attachInt(long nativeWindowPointer, int w, int h, 84 IntBuffer ints, int[] array, int offset) { 85 LensLogger.getLogger().severe("Not implemented"); 86 throw new UnsupportedOperationException("not implmented"); 87 } 88 89 @Override protected void _attachByte(long ptr, int w, int h, ByteBuffer bytes, 90 byte[] array, int offset) { 91 LensLogger.getLogger().severe("Not implemented"); 92 throw new UnsupportedOperationException("not implmented"); 93 } 94 }