1 /*
2 * Copyright (c) 1999, 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 sun.awt.image;
27
28 import java.awt.Color;
29 import java.awt.Rectangle;
30 import java.awt.GraphicsConfiguration;
31 import java.awt.image.ColorModel;
32 import java.awt.image.SampleModel;
33 import java.awt.image.DirectColorModel;
34 import java.awt.image.IndexColorModel;
35 import java.awt.image.Raster;
36 import java.awt.image.BufferedImage;
37 import java.awt.image.DataBuffer;
38
39 import sun.java2d.SurfaceData;
40 import sun.java2d.SunGraphics2D;
41 import sun.java2d.StateTrackable;
42 import sun.java2d.StateTrackable.*;
43 import sun.java2d.StateTracker;
44 import sun.java2d.loops.SurfaceType;
45 import sun.java2d.loops.CompositeType;
46 import sun.java2d.loops.RenderLoops;
47
48
49 public class BufImgSurfaceData extends SurfaceData {
50 BufferedImage bufImg;
51 private BufferedImageGraphicsConfig graphicsConfig;
52 RenderLoops solidloops;
53
54 private static native void initIDs(Class ICM, Class ICMColorData);
55
56 private static final int DCM_RGBX_RED_MASK = 0xff000000;
57 private static final int DCM_RGBX_GREEN_MASK = 0x00ff0000;
58 private static final int DCM_RGBX_BLUE_MASK = 0x0000ff00;
59 private static final int DCM_555X_RED_MASK = 0xF800;
60 private static final int DCM_555X_GREEN_MASK = 0x07C0;
61 private static final int DCM_555X_BLUE_MASK = 0x003E;
62 private static final int DCM_4444_RED_MASK = 0x0f00;
63 private static final int DCM_4444_GREEN_MASK = 0x00f0;
392 // so this method should never be called.
393 return restoreContents(bufImg);
394 }
395
396 public synchronized GraphicsConfiguration getDeviceConfiguration() {
397 if (graphicsConfig == null) {
398 graphicsConfig = BufferedImageGraphicsConfig.getConfig(bufImg);
399 }
400 return graphicsConfig;
401 }
402
403 public java.awt.Rectangle getBounds() {
404 return new Rectangle(bufImg.getWidth(), bufImg.getHeight());
405 }
406
407 protected void checkCustomComposite() {
408 // BufferedImages always allow Custom Composite objects since
409 // their pixels are immediately retrievable anyway.
410 }
411
412 private static native void freeNativeICMData(long pData);
413
414 /**
415 * Returns destination Image associated with this SurfaceData.
416 */
417 public Object getDestination() {
418 return bufImg;
419 }
420
421 public static final class ICMColorData {
422 private long pData = 0L;
423
424 private ICMColorData(long pData) {
425 this.pData = pData;
426 }
427
428 public void finalize() {
429 if (pData != 0L) {
430 BufImgSurfaceData.freeNativeICMData(pData);
431 pData = 0L;
432 }
433 }
434 }
435 }
|
1 /*
2 * Copyright (c) 1999, 2018, 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 sun.awt.image;
27
28 import java.awt.Rectangle;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.image.ColorModel;
31 import java.awt.image.SampleModel;
32 import java.awt.image.DirectColorModel;
33 import java.awt.image.IndexColorModel;
34 import java.awt.image.Raster;
35 import java.awt.image.BufferedImage;
36 import java.awt.image.DataBuffer;
37
38 import sun.java2d.SurfaceData;
39 import sun.java2d.SunGraphics2D;
40 import sun.java2d.loops.SurfaceType;
41 import sun.java2d.loops.CompositeType;
42 import sun.java2d.loops.RenderLoops;
43
44
45 public class BufImgSurfaceData extends SurfaceData {
46 BufferedImage bufImg;
47 private BufferedImageGraphicsConfig graphicsConfig;
48 RenderLoops solidloops;
49
50 private static native void initIDs(Class ICM, Class ICMColorData);
51
52 private static final int DCM_RGBX_RED_MASK = 0xff000000;
53 private static final int DCM_RGBX_GREEN_MASK = 0x00ff0000;
54 private static final int DCM_RGBX_BLUE_MASK = 0x0000ff00;
55 private static final int DCM_555X_RED_MASK = 0xF800;
56 private static final int DCM_555X_GREEN_MASK = 0x07C0;
57 private static final int DCM_555X_BLUE_MASK = 0x003E;
58 private static final int DCM_4444_RED_MASK = 0x0f00;
59 private static final int DCM_4444_GREEN_MASK = 0x00f0;
388 // so this method should never be called.
389 return restoreContents(bufImg);
390 }
391
392 public synchronized GraphicsConfiguration getDeviceConfiguration() {
393 if (graphicsConfig == null) {
394 graphicsConfig = BufferedImageGraphicsConfig.getConfig(bufImg);
395 }
396 return graphicsConfig;
397 }
398
399 public java.awt.Rectangle getBounds() {
400 return new Rectangle(bufImg.getWidth(), bufImg.getHeight());
401 }
402
403 protected void checkCustomComposite() {
404 // BufferedImages always allow Custom Composite objects since
405 // their pixels are immediately retrievable anyway.
406 }
407
408 /**
409 * Returns destination Image associated with this SurfaceData.
410 */
411 public Object getDestination() {
412 return bufImg;
413 }
414
415 public static final class ICMColorData {
416 private long pData = 0L;
417
418 private ICMColorData(long pData) {
419 this.pData = pData;
420 }
421 }
422 }
|