提交 1709d153 编写于 作者: T tdv

6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop

Reviewed-by: campbell, flar
上级 c3b76538
...@@ -25,17 +25,13 @@ ...@@ -25,17 +25,13 @@
package sun.java2d.opengl; package sun.java2d.opengl;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite; import java.awt.Composite;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp; import java.awt.image.BufferedImageOp;
import java.awt.image.ColorModel;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import sun.awt.image.BufImgSurfaceData;
import sun.java2d.SurfaceData; import sun.java2d.SurfaceData;
import sun.java2d.loops.Blit; import sun.java2d.loops.Blit;
import sun.java2d.loops.CompositeType; import sun.java2d.loops.CompositeType;
...@@ -84,6 +80,8 @@ class OGLBlitLoops { ...@@ -84,6 +80,8 @@ class OGLBlitLoops {
OGLSurfaceData.PF_INT_BGR), OGLSurfaceData.PF_INT_BGR),
new OGLSwToSurfaceBlit(SurfaceType.IntBgrx, new OGLSwToSurfaceBlit(SurfaceType.IntBgrx,
OGLSurfaceData.PF_INT_BGRX), OGLSurfaceData.PF_INT_BGRX),
new OGLSwToSurfaceBlit(SurfaceType.ThreeByteBgr,
OGLSurfaceData.PF_3BYTE_BGR),
new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb, new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb,
OGLSurfaceData.PF_USHORT_565_RGB), OGLSurfaceData.PF_USHORT_565_RGB),
new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb, new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb,
...@@ -106,6 +104,8 @@ class OGLBlitLoops { ...@@ -106,6 +104,8 @@ class OGLBlitLoops {
OGLSurfaceData.PF_INT_BGR), OGLSurfaceData.PF_INT_BGR),
new OGLSwToSurfaceScale(SurfaceType.IntBgrx, new OGLSwToSurfaceScale(SurfaceType.IntBgrx,
OGLSurfaceData.PF_INT_BGRX), OGLSurfaceData.PF_INT_BGRX),
new OGLSwToSurfaceScale(SurfaceType.ThreeByteBgr,
OGLSurfaceData.PF_3BYTE_BGR),
new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb, new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb,
OGLSurfaceData.PF_USHORT_565_RGB), OGLSurfaceData.PF_USHORT_565_RGB),
new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb, new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb,
...@@ -127,6 +127,8 @@ class OGLBlitLoops { ...@@ -127,6 +127,8 @@ class OGLBlitLoops {
OGLSurfaceData.PF_INT_BGR), OGLSurfaceData.PF_INT_BGR),
new OGLSwToSurfaceTransform(SurfaceType.IntBgrx, new OGLSwToSurfaceTransform(SurfaceType.IntBgrx,
OGLSurfaceData.PF_INT_BGRX), OGLSurfaceData.PF_INT_BGRX),
new OGLSwToSurfaceTransform(SurfaceType.ThreeByteBgr,
OGLSurfaceData.PF_3BYTE_BGR),
new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb, new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb,
OGLSurfaceData.PF_USHORT_565_RGB), OGLSurfaceData.PF_USHORT_565_RGB),
new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb, new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb,
...@@ -155,6 +157,8 @@ class OGLBlitLoops { ...@@ -155,6 +157,8 @@ class OGLBlitLoops {
OGLSurfaceData.PF_INT_BGR), OGLSurfaceData.PF_INT_BGR),
new OGLSwToTextureBlit(SurfaceType.IntBgrx, new OGLSwToTextureBlit(SurfaceType.IntBgrx,
OGLSurfaceData.PF_INT_BGRX), OGLSurfaceData.PF_INT_BGRX),
new OGLSwToTextureBlit(SurfaceType.ThreeByteBgr,
OGLSurfaceData.PF_3BYTE_BGR),
new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb, new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb,
OGLSurfaceData.PF_USHORT_565_RGB), OGLSurfaceData.PF_USHORT_565_RGB),
new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb, new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb,
......
...@@ -120,6 +120,7 @@ public abstract class OGLSurfaceData extends SurfaceData ...@@ -120,6 +120,7 @@ public abstract class OGLSurfaceData extends SurfaceData
public static final int PF_USHORT_555_RGBX = 8; public static final int PF_USHORT_555_RGBX = 8;
public static final int PF_BYTE_GRAY = 9; public static final int PF_BYTE_GRAY = 9;
public static final int PF_USHORT_GRAY = 10; public static final int PF_USHORT_GRAY = 10;
public static final int PF_3BYTE_BGR = 11;
/** /**
* SurfaceTypes * SurfaceTypes
......
...@@ -60,6 +60,9 @@ import java.awt.image.VolatileImage; ...@@ -60,6 +60,9 @@ import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
import java.awt.image.DataBufferShort;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JComponent; import javax.swing.JComponent;
...@@ -84,6 +87,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -84,6 +87,7 @@ public abstract class ImageTests extends GraphicsTests {
static Group.EnableSet bufimgsrcroot; static Group.EnableSet bufimgsrcroot;
static Group imgtestroot; static Group imgtestroot;
static Group imgoptionsroot;
static Group imageOpRoot; static Group imageOpRoot;
static Group imageOpOptRoot; static Group imageOpOptRoot;
...@@ -92,6 +96,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -92,6 +96,7 @@ public abstract class ImageTests extends GraphicsTests {
static Group bufImgOpTestRoot; static Group bufImgOpTestRoot;
static Group rasterOpTestRoot; static Group rasterOpTestRoot;
static Option opList; static Option opList;
static Option doTouchSrc;
static String transNodeNames[] = { static String transNodeNames[] = {
null, "opaque", "bitmask", "translucent", null, "opaque", "bitmask", "translucent",
...@@ -105,9 +110,19 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -105,9 +110,19 @@ public abstract class ImageTests extends GraphicsTests {
imageroot = new Group(graphicsroot, "imaging", imageroot = new Group(graphicsroot, "imaging",
"Imaging Benchmarks"); "Imaging Benchmarks");
imageroot.setTabbed(); imageroot.setTabbed();
imgsrcroot = new Group.EnableSet(imageroot, "src", imgsrcroot = new Group.EnableSet(imageroot, "src",
"Image Rendering Sources"); "Image Rendering Sources");
imgsrcroot.setBordered(true); imgsrcroot.setBordered(true);
imgoptionsroot = new Group(imgsrcroot, "options",
"Image Source Options");
imgoptionsroot.setBordered(true);
doTouchSrc =
new Option.Toggle(imgoptionsroot, "touchsrc",
"Touch src image before every operation",
Option.Toggle.Off);
imgtestroot = new Group(imageroot, "tests", imgtestroot = new Group(imageroot, "tests",
"Image Rendering Tests"); "Image Rendering Tests");
imgtestroot.setBordered(true); imgtestroot.setBordered(true);
...@@ -131,7 +146,11 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -131,7 +146,11 @@ public abstract class ImageTests extends GraphicsTests {
new BufImg(BufferedImage.TYPE_INT_RGB); new BufImg(BufferedImage.TYPE_INT_RGB);
new BufImg(BufferedImage.TYPE_INT_ARGB); new BufImg(BufferedImage.TYPE_INT_ARGB);
new BufImg(BufferedImage.TYPE_BYTE_GRAY); new BufImg(BufferedImage.TYPE_BYTE_GRAY);
new BufImg(BufferedImage.TYPE_3BYTE_BGR);
new BmByteIndexBufImg(); new BmByteIndexBufImg();
new BufImg(BufferedImage.TYPE_INT_RGB, true);
new BufImg(BufferedImage.TYPE_INT_ARGB, true);
new BufImg(BufferedImage.TYPE_3BYTE_BGR, true);
imageOpRoot = new Group(imageroot, "imageops", imageOpRoot = new Group(imageroot, "imageops",
"Image Op Benchmarks"); "Image Op Benchmarks");
...@@ -193,6 +212,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -193,6 +212,7 @@ public abstract class ImageTests extends GraphicsTests {
} }
public static class Context extends GraphicsTests.Context { public static class Context extends GraphicsTests.Context {
boolean touchSrc;
Image src; Image src;
AffineTransform tx; AffineTransform tx;
} }
...@@ -206,6 +226,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -206,6 +226,7 @@ public abstract class ImageTests extends GraphicsTests {
{ {
super(parent, nodeName, description); super(parent, nodeName, description);
addDependency(imgsrcroot, srcFilter); addDependency(imgsrcroot, srcFilter);
addDependency(doTouchSrc);
} }
public GraphicsTests.Context createContext() { public GraphicsTests.Context createContext() {
...@@ -217,6 +238,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -217,6 +238,7 @@ public abstract class ImageTests extends GraphicsTests {
ImageTests.Context ictx = (ImageTests.Context) ctx; ImageTests.Context ictx = (ImageTests.Context) ctx;
ictx.src = env.getSrcImage(); ictx.src = env.getSrcImage();
ictx.touchSrc = env.isEnabled(doTouchSrc);
} }
public abstract static class TriStateImageType extends Group { public abstract static class TriStateImageType extends Group {
...@@ -272,13 +294,6 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -272,13 +294,6 @@ public abstract class ImageTests extends GraphicsTests {
public static class CompatImg extends TriStateImageType { public static class CompatImg extends TriStateImageType {
int transparency; int transparency;
public static String Descriptions[] = {
"Default Compatible Image",
"Opaque Compatible Image",
"Bitmask Compatible Image",
"Translucent Compatible Image",
};
public CompatImg(int transparency) { public CompatImg(int transparency) {
super(imgsrcroot, super(imgsrcroot,
Destinations.CompatImg.ShortNames[transparency], Destinations.CompatImg.ShortNames[transparency],
...@@ -296,6 +311,7 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -296,6 +311,7 @@ public abstract class ImageTests extends GraphicsTests {
public static class BufImg extends TriStateImageType { public static class BufImg extends TriStateImageType {
int type; int type;
boolean unmanaged;
static int Transparencies[] = { static int Transparencies[] = {
Transparency.TRANSLUCENT, // "custom", Transparency.TRANSLUCENT, // "custom",
...@@ -315,15 +331,37 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -315,15 +331,37 @@ public abstract class ImageTests extends GraphicsTests {
}; };
public BufImg(int type) { public BufImg(int type) {
this(type, false);
}
public BufImg(int type, boolean unmanaged) {
super(bufimgsrcroot, super(bufimgsrcroot,
(unmanaged ? "unmanaged" : "") +
Destinations.BufImg.ShortNames[type], Destinations.BufImg.ShortNames[type],
(unmanaged ? "Unmanaged " : "") +
Destinations.BufImg.Descriptions[type], Destinations.BufImg.Descriptions[type],
Transparencies[type]); Transparencies[type]);
this.type = type; this.type = type;
this.unmanaged = unmanaged;
} }
public Image makeImage(TestEnvironment env, int w, int h) { public Image makeImage(TestEnvironment env, int w, int h) {
return new BufferedImage(w, h, type); BufferedImage img = new BufferedImage(w, h, type);
if (unmanaged) {
DataBuffer db = img.getRaster().getDataBuffer();
if (db instanceof DataBufferInt) {
((DataBufferInt)db).getData();
} else if (db instanceof DataBufferShort) {
((DataBufferShort)db).getData();
} else if (db instanceof DataBufferByte) {
((DataBufferByte)db).getData();
} else {
try {
img.setAccelerationPriority(0.0f);
} catch (Throwable e) {}
}
}
return img;
} }
} }
...@@ -471,7 +509,10 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -471,7 +509,10 @@ public abstract class ImageTests extends GraphicsTests {
g.translate(ictx.orgX, ictx.orgY); g.translate(ictx.orgX, ictx.orgY);
Image src = ictx.src; Image src = ictx.src;
if (ictx.animate) { if (ictx.animate) {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do { do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, null); g.drawImage(src, x, y, null);
if ((x -= 3) < 0) x += ictx.maxX; if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY; if ((y -= 1) < 0) y += ictx.maxY;
...@@ -479,8 +520,23 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -479,8 +520,23 @@ public abstract class ImageTests extends GraphicsTests {
} else { } else {
do { do {
g.drawImage(src, x, y, null); g.drawImage(src, x, y, null);
if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0); } while (--numReps > 0);
} }
} else {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, null);
} while (--numReps > 0);
} else {
do {
g.drawImage(src, x, y, null);
} while (--numReps > 0);
}
}
g.translate(-ictx.orgX, -ictx.orgY); g.translate(-ictx.orgX, -ictx.orgY);
} }
} }
...@@ -505,16 +561,34 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -505,16 +561,34 @@ public abstract class ImageTests extends GraphicsTests {
Image src = ictx.src; Image src = ictx.src;
Color bg = Color.orange; Color bg = Color.orange;
if (ictx.animate) { if (ictx.animate) {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, bg, null);
if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0);
} else {
do { do {
g.drawImage(src, x, y, bg, null); g.drawImage(src, x, y, bg, null);
if ((x -= 3) < 0) x += ictx.maxX; if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY; if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0); } while (--numReps > 0);
}
} else {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, bg, null);
} while (--numReps > 0);
} else { } else {
do { do {
g.drawImage(src, x, y, bg, null); g.drawImage(src, x, y, bg, null);
} while (--numReps > 0); } while (--numReps > 0);
} }
}
g.translate(-ictx.orgX, -ictx.orgY); g.translate(-ictx.orgX, -ictx.orgY);
} }
} }
...@@ -546,16 +620,34 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -546,16 +620,34 @@ public abstract class ImageTests extends GraphicsTests {
g.translate(ictx.orgX, ictx.orgY); g.translate(ictx.orgX, ictx.orgY);
Image src = ictx.src; Image src = ictx.src;
if (ictx.animate) { if (ictx.animate) {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, w, h, null);
if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0);
} else {
do { do {
g.drawImage(src, x, y, w, h, null); g.drawImage(src, x, y, w, h, null);
if ((x -= 3) < 0) x += ictx.maxX; if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY; if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0); } while (--numReps > 0);
}
} else {
Graphics srcG = src.getGraphics();
if (ictx.touchSrc) {
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, x, y, w, h, null);
} while (--numReps > 0);
} else { } else {
do { do {
g.drawImage(src, x, y, w, h, null); g.drawImage(src, x, y, w, h, null);
} while (--numReps > 0); } while (--numReps > 0);
} }
}
g.translate(-ictx.orgX, -ictx.orgY); g.translate(-ictx.orgX, -ictx.orgY);
} }
} }
...@@ -588,18 +680,37 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -588,18 +680,37 @@ public abstract class ImageTests extends GraphicsTests {
Image src = ictx.src; Image src = ictx.src;
AffineTransform tx = ictx.tx; AffineTransform tx = ictx.tx;
if (ictx.animate) { if (ictx.animate) {
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do { do {
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y); tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, tx, null); g.drawImage(src, tx, null);
if ((x -= 3) < 0) x += ictx.maxX; if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY; if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0); } while (--numReps > 0);
} else { } else {
do {
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y); tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
g.drawImage(src, tx, null);
if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0);
}
} else {
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
if (ictx.touchSrc) {
Graphics srcG = src.getGraphics();
do {
srcG.fillRect(0, 0, 1, 1);
g.drawImage(src, tx, null);
} while (--numReps > 0);
} else {
do { do {
g.drawImage(src, tx, null); g.drawImage(src, tx, null);
} while (--numReps > 0); } while (--numReps > 0);
} }
}
g.translate(-ictx.orgX, -ictx.orgY); g.translate(-ictx.orgX, -ictx.orgY);
} }
} }
...@@ -736,7 +847,10 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -736,7 +847,10 @@ public abstract class ImageTests extends GraphicsTests {
Graphics2D g2 = (Graphics2D)ictx.graphics; Graphics2D g2 = (Graphics2D)ictx.graphics;
g2.translate(ictx.orgX, ictx.orgY); g2.translate(ictx.orgX, ictx.orgY);
if (ictx.animate) { if (ictx.animate) {
if (ictx.touchSrc) {
Graphics gSrc = src.getGraphics();
do { do {
gSrc.fillRect(0, 0, 1, 1);
g2.drawImage(src, op, x, y); g2.drawImage(src, op, x, y);
if ((x -= 3) < 0) x += ictx.maxX; if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY; if ((y -= 1) < 0) y += ictx.maxY;
...@@ -744,8 +858,23 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -744,8 +858,23 @@ public abstract class ImageTests extends GraphicsTests {
} else { } else {
do { do {
g2.drawImage(src, op, x, y); g2.drawImage(src, op, x, y);
if ((x -= 3) < 0) x += ictx.maxX;
if ((y -= 1) < 0) y += ictx.maxY;
} while (--numReps > 0); } while (--numReps > 0);
} }
} else {
if (ictx.touchSrc) {
Graphics gSrc = src.getGraphics();
do {
gSrc.fillRect(0, 0, 1, 1);
g2.drawImage(src, op, x, y);
} while (--numReps > 0);
} else {
do {
g2.drawImage(src, op, x, y);
} while (--numReps > 0);
}
}
g2.translate(-ictx.orgX, -ictx.orgY); g2.translate(-ictx.orgX, -ictx.orgY);
} }
} }
...@@ -778,9 +907,17 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -778,9 +907,17 @@ public abstract class ImageTests extends GraphicsTests {
BufferedImageOp op = ictx.bufImgOp; BufferedImageOp op = ictx.bufImgOp;
BufferedImage src = ictx.bufSrc; BufferedImage src = ictx.bufSrc;
BufferedImage dst = ictx.bufDst; BufferedImage dst = ictx.bufDst;
if (ictx.touchSrc) {
Graphics gSrc = src.getGraphics();
do { do {
gSrc.fillRect(0, 0, 1, 1);
op.filter(src, dst); op.filter(src, dst);
} while (--numReps > 0); } while (--numReps > 0);
} else {
do {
op.filter(src, dst);
} while (--numReps > 0);
}
} }
} }
...@@ -814,9 +951,17 @@ public abstract class ImageTests extends GraphicsTests { ...@@ -814,9 +951,17 @@ public abstract class ImageTests extends GraphicsTests {
RasterOp op = ictx.rasterOp; RasterOp op = ictx.rasterOp;
Raster src = ictx.rasSrc; Raster src = ictx.rasSrc;
WritableRaster dst = ictx.rasDst; WritableRaster dst = ictx.rasDst;
if (ictx.touchSrc) {
Graphics gSrc = ictx.bufSrc.getGraphics();
do { do {
gSrc.fillRect(0, 0, 1, 1);
op.filter(src, dst); op.filter(src, dst);
} while (--numReps > 0); } while (--numReps > 0);
} else {
do {
op.filter(src, dst);
} while (--numReps > 0);
}
} }
} }
} }
...@@ -203,7 +203,24 @@ OGLBlitSwToSurface(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ...@@ -203,7 +203,24 @@ OGLBlitSwToSurface(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
j2d_glBitmap(0, 0, 0, 0, (GLfloat)dx1, (GLfloat)-dy1, NULL); j2d_glBitmap(0, 0, 0, 0, (GLfloat)dx1, (GLfloat)-dy1, NULL);
j2d_glPixelZoom(scalex, -scaley); j2d_glPixelZoom(scalex, -scaley);
// in case pixel stride is not a multiple of scanline stride the copy
// has to be done line by line (see 6207877)
if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
jint width = sx2-sx1;
jint height = sy2-sy1;
GLvoid *pSrc = srcInfo->rasBase;
while (height > 0) {
j2d_glDrawPixels(width, 1, pf->format, pf->type, pSrc);
j2d_glBitmap(0, 0, 0, 0, (GLfloat)0, (GLfloat)-1, NULL);
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
height--;
}
} else {
j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase); j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase);
}
j2d_glPixelZoom(1.0, 1.0); j2d_glPixelZoom(1.0, 1.0);
if (oglc->extraAlpha != 1.0f) { if (oglc->extraAlpha != 1.0f) {
...@@ -250,6 +267,7 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ...@@ -250,6 +267,7 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
jint sx, sy, sw, sh; jint sx, sy, sw, sh;
GLint glhint = (hint == OGLSD_XFORM_BILINEAR) ? GL_LINEAR : GL_NEAREST; GLint glhint = (hint == OGLSD_XFORM_BILINEAR) ? GL_LINEAR : GL_NEAREST;
jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha); jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha);
jboolean slowPath;
if (oglc->blitTextureID == 0) { if (oglc->blitTextureID == 0) {
if (!OGLContext_InitBlitTileTexture(oglc)) { if (!OGLContext_InitBlitTileTexture(oglc)) {
...@@ -279,6 +297,10 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ...@@ -279,6 +297,10 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f); j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f);
} }
// in case pixel stride is not a multiple of scanline stride the copy
// has to be done line by line (see 6207877)
slowPath = srcInfo->scanStride % srcInfo->pixelStride != 0;
for (sy = sy1, dy = dy1; sy < sy2; sy += th, dy += cdh) { for (sy = sy1, dy = dy1; sy < sy2; sy += th, dy += cdh) {
sh = ((sy + th) > sy2) ? (sy2 - sy) : th; sh = ((sy + th) > sy2) ? (sy2 - sy) : th;
dh = ((dy + cdh) > dy2) ? (dy2 - dy) : cdh; dh = ((dy + cdh) > dy2) ? (dy2 - dy) : cdh;
...@@ -291,6 +313,21 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ...@@ -291,6 +313,21 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
ty2 = ((GLdouble)sh) / th; ty2 = ((GLdouble)sh) / th;
if (swsurface) { if (swsurface) {
if (slowPath) {
jint tmph = sh;
GLvoid *pSrc = PtrCoord(srcInfo->rasBase,
sx, srcInfo->pixelStride,
sy, srcInfo->scanStride);
while (tmph > 0) {
j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
0, sh - tmph, sw, 1,
pf->format, pf->type,
pSrc);
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
tmph--;
}
} else {
j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx); j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy); j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy);
...@@ -298,6 +335,7 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ...@@ -298,6 +335,7 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
0, 0, sw, sh, 0, 0, sw, sh,
pf->format, pf->type, pf->format, pf->type,
srcInfo->rasBase); srcInfo->rasBase);
}
// the texture image is "right side up", so we align the // the texture image is "right side up", so we align the
// upper-left texture corner with the upper-left quad corner // upper-left texture corner with the upper-left quad corner
...@@ -356,9 +394,25 @@ OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf, ...@@ -356,9 +394,25 @@ OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf,
jint dx1, jint dy1, jint dx2, jint dy2) jint dx1, jint dy1, jint dx2, jint dy2)
{ {
j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID); j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID);
// in case pixel stride is not a multiple of scanline stride the copy
// has to be done line by line (see 6207877)
if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
jint width = dx2 - dx1;
jint height = dy2 - dy1;
GLvoid *pSrc = srcInfo->rasBase;
while (height > 0) {
j2d_glTexSubImage2D(dstOps->textureTarget, 0,
dx1, dy2 - height, width, 1,
pf->format, pf->type, pSrc);
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
height--;
}
} else {
j2d_glTexSubImage2D(dstOps->textureTarget, 0, j2d_glTexSubImage2D(dstOps->textureTarget, 0,
dx1, dy1, dx2-dx1, dy2-dy1, dx1, dy1, dx2-dx1, dy2-dy1,
pf->format, pf->type, srcInfo->rasBase); pf->format, pf->type, srcInfo->rasBase);
}
} }
/** /**
......
...@@ -73,7 +73,8 @@ OGLPixelFormat PixelFormats[] = { ...@@ -73,7 +73,8 @@ OGLPixelFormat PixelFormats[] = {
1, 0, 1, }, /* 9 - ByteGray */ 1, 0, 1, }, /* 9 - ByteGray */
{ GL_LUMINANCE, GL_UNSIGNED_SHORT, { GL_LUMINANCE, GL_UNSIGNED_SHORT,
2, 0, 1, }, /*10 - UshortGray */ 2, 0, 1, }, /*10 - UshortGray */
}; { GL_BGR, GL_UNSIGNED_BYTE,
1, 0, 1, }, /*11 - ThreeByteBgr */};
/** /**
* Given a starting value and a maximum limit, returns the first power-of-two * Given a starting value and a maximum limit, returns the first power-of-two
......
...@@ -85,6 +85,8 @@ class D3DBlitLoops { ...@@ -85,6 +85,8 @@ class D3DBlitLoops {
D3DSurfaceData.ST_INT_RGB), D3DSurfaceData.ST_INT_RGB),
new D3DSwToSurfaceBlit(SurfaceType.IntBgr, new D3DSwToSurfaceBlit(SurfaceType.IntBgr,
D3DSurfaceData.ST_INT_BGR), D3DSurfaceData.ST_INT_BGR),
new D3DSwToSurfaceBlit(SurfaceType.ThreeByteBgr,
D3DSurfaceData.ST_3BYTE_BGR),
new D3DSwToSurfaceBlit(SurfaceType.Ushort565Rgb, new D3DSwToSurfaceBlit(SurfaceType.Ushort565Rgb,
D3DSurfaceData.ST_USHORT_565_RGB), D3DSurfaceData.ST_USHORT_565_RGB),
new D3DSwToSurfaceBlit(SurfaceType.Ushort555Rgb, new D3DSwToSurfaceBlit(SurfaceType.Ushort555Rgb,
...@@ -106,6 +108,8 @@ class D3DBlitLoops { ...@@ -106,6 +108,8 @@ class D3DBlitLoops {
D3DSurfaceData.ST_INT_RGB), D3DSurfaceData.ST_INT_RGB),
new D3DSwToSurfaceScale(SurfaceType.IntBgr, new D3DSwToSurfaceScale(SurfaceType.IntBgr,
D3DSurfaceData.ST_INT_BGR), D3DSurfaceData.ST_INT_BGR),
new D3DSwToSurfaceScale(SurfaceType.ThreeByteBgr,
D3DSurfaceData.ST_3BYTE_BGR),
new D3DSwToSurfaceScale(SurfaceType.Ushort565Rgb, new D3DSwToSurfaceScale(SurfaceType.Ushort565Rgb,
D3DSurfaceData.ST_USHORT_565_RGB), D3DSurfaceData.ST_USHORT_565_RGB),
new D3DSwToSurfaceScale(SurfaceType.Ushort555Rgb, new D3DSwToSurfaceScale(SurfaceType.Ushort555Rgb,
...@@ -124,6 +128,8 @@ class D3DBlitLoops { ...@@ -124,6 +128,8 @@ class D3DBlitLoops {
D3DSurfaceData.ST_INT_RGB), D3DSurfaceData.ST_INT_RGB),
new D3DSwToSurfaceTransform(SurfaceType.IntBgr, new D3DSwToSurfaceTransform(SurfaceType.IntBgr,
D3DSurfaceData.ST_INT_BGR), D3DSurfaceData.ST_INT_BGR),
new D3DSwToSurfaceTransform(SurfaceType.ThreeByteBgr,
D3DSurfaceData.ST_3BYTE_BGR),
new D3DSwToSurfaceTransform(SurfaceType.Ushort565Rgb, new D3DSwToSurfaceTransform(SurfaceType.Ushort565Rgb,
D3DSurfaceData.ST_USHORT_565_RGB), D3DSurfaceData.ST_USHORT_565_RGB),
new D3DSwToSurfaceTransform(SurfaceType.Ushort555Rgb, new D3DSwToSurfaceTransform(SurfaceType.Ushort555Rgb,
...@@ -147,6 +153,8 @@ class D3DBlitLoops { ...@@ -147,6 +153,8 @@ class D3DBlitLoops {
D3DSurfaceData.ST_INT_ARGB), D3DSurfaceData.ST_INT_ARGB),
new D3DSwToTextureBlit(SurfaceType.IntBgr, new D3DSwToTextureBlit(SurfaceType.IntBgr,
D3DSurfaceData.ST_INT_BGR), D3DSurfaceData.ST_INT_BGR),
new D3DSwToTextureBlit(SurfaceType.ThreeByteBgr,
D3DSurfaceData.ST_3BYTE_BGR),
new D3DSwToTextureBlit(SurfaceType.Ushort565Rgb, new D3DSwToTextureBlit(SurfaceType.Ushort565Rgb,
D3DSurfaceData.ST_USHORT_565_RGB), D3DSurfaceData.ST_USHORT_565_RGB),
new D3DSwToTextureBlit(SurfaceType.Ushort555Rgb, new D3DSwToTextureBlit(SurfaceType.Ushort555Rgb,
......
...@@ -135,6 +135,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { ...@@ -135,6 +135,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
public static final int ST_USHORT_555_RGB = 6; public static final int ST_USHORT_555_RGB = 6;
public static final int ST_BYTE_INDEXED = 7; public static final int ST_BYTE_INDEXED = 7;
public static final int ST_BYTE_INDEXED_BM = 8; public static final int ST_BYTE_INDEXED_BM = 8;
public static final int ST_3BYTE_BGR = 9;
/** Equals to D3DSWAPEFFECT_DISCARD */ /** Equals to D3DSWAPEFFECT_DISCARD */
public static final int SWAP_DISCARD = 1; public static final int SWAP_DISCARD = 1;
......
...@@ -47,6 +47,7 @@ extern "C" BlitFunc IntArgbToIntArgbPreConvert; ...@@ -47,6 +47,7 @@ extern "C" BlitFunc IntArgbToIntArgbPreConvert;
extern "C" BlitFunc IntArgbPreToIntArgbConvert; extern "C" BlitFunc IntArgbPreToIntArgbConvert;
extern "C" BlitFunc IntArgbBmToIntArgbConvert; extern "C" BlitFunc IntArgbBmToIntArgbConvert;
extern "C" BlitFunc IntRgbToIntArgbConvert; extern "C" BlitFunc IntRgbToIntArgbConvert;
extern "C" BlitFunc ThreeByteBgrToIntArgbConvert;
extern "C" BlitFunc Ushort565RgbToIntArgbConvert; extern "C" BlitFunc Ushort565RgbToIntArgbConvert;
extern "C" BlitFunc Ushort555RgbToIntArgbConvert; extern "C" BlitFunc Ushort555RgbToIntArgbConvert;
extern "C" BlitFunc IntBgrToIntArgbConvert; extern "C" BlitFunc IntBgrToIntArgbConvert;
...@@ -268,6 +269,11 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo, ...@@ -268,6 +269,11 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo,
srcWidth, srcHeight, srcWidth, srcHeight,
pSrcInfo, &dstInfo, NULL, NULL); pSrcInfo, &dstInfo, NULL, NULL);
break; break;
case ST_3BYTE_BGR:
ThreeByteBgrToIntArgbConvert(pSrcBase, pDstBase,
srcWidth, srcHeight,
pSrcInfo, &dstInfo, NULL, NULL);
break;
case ST_USHORT_555_RGB: case ST_USHORT_555_RGB:
Ushort555RgbToIntArgbConvert(pSrcBase, pDstBase, Ushort555RgbToIntArgbConvert(pSrcBase, pDstBase,
srcWidth, srcHeight, srcWidth, srcHeight,
......
...@@ -68,6 +68,7 @@ struct _D3DSDOps { ...@@ -68,6 +68,7 @@ struct _D3DSDOps {
#define ST_USHORT_555_RGB sun_java2d_d3d_D3DSurfaceData_ST_USHORT_555_RGB #define ST_USHORT_555_RGB sun_java2d_d3d_D3DSurfaceData_ST_USHORT_555_RGB
#define ST_BYTE_INDEXED sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED #define ST_BYTE_INDEXED sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED
#define ST_BYTE_INDEXED_BM sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED_BM #define ST_BYTE_INDEXED_BM sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED_BM
#define ST_3BYTE_BGR sun_java2d_d3d_D3DSurfaceData_ST_3BYTE_BGR
/** /**
* These are defined to be the same as ExtendedBufferCapabilities.VSyncType * These are defined to be the same as ExtendedBufferCapabilities.VSyncType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册