提交 d6ace729 编写于 作者: S serb

8059941: [D3D] The fix for JDK-8029253 should be ported to d3d pipeline

Reviewed-by: bae, prr
上级 64bf9ff3
/* /*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,7 +48,7 @@ import sun.java2d.pipe.RenderQueue; ...@@ -48,7 +48,7 @@ import sun.java2d.pipe.RenderQueue;
import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.pipe.BufferedOpCodes.*;
import sun.java2d.windows.GDIWindowSurfaceData; import sun.java2d.windows.GDIWindowSurfaceData;
class D3DBlitLoops { final class D3DBlitLoops {
static void register() { static void register() {
Blit blitIntArgbPreToSurface = Blit blitIntArgbPreToSurface =
...@@ -57,7 +57,9 @@ class D3DBlitLoops { ...@@ -57,7 +57,9 @@ class D3DBlitLoops {
Blit blitIntArgbPreToTexture = Blit blitIntArgbPreToTexture =
new D3DSwToTextureBlit(SurfaceType.IntArgbPre, new D3DSwToTextureBlit(SurfaceType.IntArgbPre,
D3DSurfaceData.ST_INT_ARGB_PRE); D3DSurfaceData.ST_INT_ARGB_PRE);
TransformBlit transformBlitIntArgbPreToSurface =
new D3DSwToSurfaceTransform(SurfaceType.IntArgbPre,
D3DSurfaceData.ST_INT_ARGB_PRE);
GraphicsPrimitive[] primitives = { GraphicsPrimitive[] primitives = {
// prevent D3DSurface -> Screen blits // prevent D3DSurface -> Screen blits
new D3DSurfaceToGDIWindowSurfaceBlit(), new D3DSurfaceToGDIWindowSurfaceBlit(),
...@@ -123,8 +125,6 @@ class D3DBlitLoops { ...@@ -123,8 +125,6 @@ class D3DBlitLoops {
new D3DSwToSurfaceTransform(SurfaceType.IntArgb, new D3DSwToSurfaceTransform(SurfaceType.IntArgb,
D3DSurfaceData.ST_INT_ARGB), D3DSurfaceData.ST_INT_ARGB),
new D3DSwToSurfaceTransform(SurfaceType.IntArgbPre,
D3DSurfaceData.ST_INT_ARGB_PRE),
new D3DSwToSurfaceTransform(SurfaceType.IntRgb, new D3DSwToSurfaceTransform(SurfaceType.IntRgb,
D3DSurfaceData.ST_INT_RGB), D3DSurfaceData.ST_INT_RGB),
new D3DSwToSurfaceTransform(SurfaceType.IntBgr, new D3DSwToSurfaceTransform(SurfaceType.IntBgr,
...@@ -140,6 +140,9 @@ class D3DBlitLoops { ...@@ -140,6 +140,9 @@ class D3DBlitLoops {
// REMIND: we don't have a native sw loop to back this loop up // REMIND: we don't have a native sw loop to back this loop up
// new D3DSwToSurfaceTransform(SurfaceType.ByteIndexedBm, // new D3DSwToSurfaceTransform(SurfaceType.ByteIndexedBm,
// D3DSurfaceData.ST_BYTE_INDEXED_BM), // D3DSurfaceData.ST_BYTE_INDEXED_BM),
transformBlitIntArgbPreToSurface,
new D3DGeneralTransformedBlit(transformBlitIntArgbPreToSurface),
// texture->surface ops // texture->surface ops
new D3DTextureToSurfaceBlit(), new D3DTextureToSurfaceBlit(),
...@@ -712,11 +715,11 @@ class D3DTextureToSurfaceTransform extends TransformBlit { ...@@ -712,11 +715,11 @@ class D3DTextureToSurfaceTransform extends TransformBlit {
* This general Blit implementation converts any source surface to an * This general Blit implementation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific * intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->D3DSurface/Texture loop to get the intermediate * IntArgbPre->D3DSurface/Texture loop to get the intermediate
* (premultiplied) surface down to D3D. * (premultiplied) surface down to D3D using simple blit.
*/ */
class D3DGeneralBlit extends Blit { class D3DGeneralBlit extends Blit {
private Blit performop; private final Blit performop;
private WeakReference srcTmp; private WeakReference srcTmp;
D3DGeneralBlit(SurfaceType dstType, D3DGeneralBlit(SurfaceType dstType,
...@@ -757,6 +760,49 @@ class D3DGeneralBlit extends Blit { ...@@ -757,6 +760,49 @@ class D3DGeneralBlit extends Blit {
} }
} }
/**
* This general TransformedBlit implementation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->D3DSurface/Texture loop to get the intermediate
* (premultiplied) surface down to D3D using simple transformBlit.
*/
final class D3DGeneralTransformedBlit extends TransformBlit {
private final TransformBlit performop;
private WeakReference<SurfaceData> srcTmp;
D3DGeneralTransformedBlit(final TransformBlit performop) {
super(SurfaceType.Any, CompositeType.AnyAlpha,
D3DSurfaceData.D3DSurface);
this.performop = performop;
}
@Override
public synchronized void Transform(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
AffineTransform at, int hint, int srcx,
int srcy, int dstx, int dsty, int width,
int height){
Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),
CompositeType.SrcNoEa,
SurfaceType.IntArgbPre);
// use cached intermediate surface, if available
final SurfaceData cachedSrc = srcTmp != null ? srcTmp.get() : null;
// convert source to IntArgbPre
src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc,
BufferedImage.TYPE_INT_ARGB_PRE);
// transform IntArgbPre intermediate surface to D3D surface
performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty,
width, height);
if (src != cachedSrc) {
// cache the intermediate surface
srcTmp = new WeakReference<>(src);
}
}
}
/* /*
* The following classes prohibit copying D3DSurfaces to the screen * The following classes prohibit copying D3DSurfaces to the screen
* (the D3D->sysmem->GDI path is known to be very very slow). * (the D3D->sysmem->GDI path is known to be very very slow).
......
...@@ -41,7 +41,7 @@ import static java.awt.image.BufferedImage.*; ...@@ -41,7 +41,7 @@ import static java.awt.image.BufferedImage.*;
/* /*
* @test * @test
* @bug 8029253 * @bug 8029253 8059941
* @summary Unmanaged images should be drawn fast. * @summary Unmanaged images should be drawn fast.
* @author Sergey Bylokhov * @author Sergey Bylokhov
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册