Showing the changes to java/pkg/sun/awt/image/DataBufferNative.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,92 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000, 2001, 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 | |||
| 27 | package sun.awt.image; | ||
| 28 | |||
| 29 | import java.awt.image.DataBuffer; | ||
| 30 | import sun.java2d.SurfaceData; | ||
| 31 | import java.awt.Rectangle; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * This class extends <CODE>DataBuffer</CODE> and allows access to | ||
| 35 | * native data via the DataBuffer methods. Note that, unlike other | ||
| 36 | * DataBuffer classes, the data is not stored in this class but | ||
| 37 | * has been created and stored elsewhere and this class is used | ||
| 38 | * merely to access that data. Note also that this class subclasses | ||
| 39 | * from DataBuffer and not from any of the standard subclasses | ||
| 40 | * (e.g., DataBufferInt); those subclasses allow the user to | ||
| 41 | * get a pointer to the data and manipulate it directly. That | ||
| 42 | * operation may not be possible or wise with native data. | ||
| 43 | * One important use of this DataBuffer class is in accessing the | ||
| 44 | * data stored in an offscreen vram surface, such as that created | ||
| 45 | * by the createVolatileImage() method. | ||
| 46 | */ | ||
| 47 | |||
| 48 | public class DataBufferNative extends DataBuffer | ||
| 49 | { | ||
| 50 | protected SurfaceData surfaceData; | ||
| 51 | protected int width; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Constructor. The constructor of this object requires a | ||
| 55 | * SurfaceData object; that surfaceData object will be used | ||
| 56 | * to access the actual pixel data in native code. | ||
| 57 | */ | ||
| 58 | public DataBufferNative(SurfaceData sData, int type, int width, int height) { | ||
| 59 | super(type, width*height); | ||
| 60 | this.width = width; | ||
| 61 | this.surfaceData = sData; | ||
| 62 | } | ||
| 63 | |||
| 64 | protected native int getElem(int x, int y, SurfaceData sData); | ||
| 65 | |||
| 66 | /** | ||
| 67 | * getElem returns the pixel value for a given index into the | ||
| 68 | * dataBuffer array. The bank value is currently ignored (the | ||
| 69 | * type of data accessed through this class is not stored in | ||
| 70 | * separate banks). The x and y coordinates of a pixel are calculated | ||
| 71 | * from the index value and the native getElem() method is | ||
| 72 | * called with the internal surfaceData object. | ||
| 73 | */ | ||
| 74 | public int getElem(int bank, int i) { | ||
| 75 | return getElem(i % width, i / width, surfaceData); | ||
| 76 | } | ||
| 77 | |||
| 78 | protected native void setElem(int x, int y, int val, SurfaceData sData); | ||
| 79 | |||
| 80 | /** | ||
| 81 | * setElem sets the pixel value of a given index into the | ||
| 82 | * dataBuffer array. The bank value is currently ignored (the | ||
| 83 | * type of data accessed through this class is not stored in | ||
| 84 | * separate banks). The x and y coordinates of a pixel are calculated | ||
| 85 | * from the index value and the native setElem() method is | ||
| 86 | * called with the internal surfaceData object. | ||
| 87 | */ | ||
| 88 | public void setElem(int bank, int i, int val) { | ||
| 89 | setElem(i % width, i / width, val, surfaceData); | ||
| 90 | } | ||
| 91 | |||
| 92 | } | ||