changeset 10276:95193f897702

8059941: [D3D] The fix for JDK-8029253 should be ported to d3d pipeline Reviewed-by: bae, prr
author serb
date Thu, 23 Oct 2014 19:59:27 +0400
parents 98ed32fc2b55
children ae0633fb37b1
files src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java test/java/awt/image/DrawImage/UnmanagedDrawImagePerformance.java
diffstat 2 files changed, 54 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Wed Oct 22 12:33:28 2014 +0400
+++ b/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Thu Oct 23 19:59:27 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * 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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
 import static sun.java2d.pipe.BufferedOpCodes.*;
 import sun.java2d.windows.GDIWindowSurfaceData;
 
-class D3DBlitLoops {
+final class D3DBlitLoops {
 
     static void register() {
         Blit blitIntArgbPreToSurface =
@@ -57,7 +57,9 @@
         Blit blitIntArgbPreToTexture =
             new D3DSwToTextureBlit(SurfaceType.IntArgbPre,
                                    D3DSurfaceData.ST_INT_ARGB_PRE);
-
+        TransformBlit transformBlitIntArgbPreToSurface =
+            new D3DSwToSurfaceTransform(SurfaceType.IntArgbPre,
+                                        D3DSurfaceData.ST_INT_ARGB_PRE);
         GraphicsPrimitive[] primitives = {
             // prevent D3DSurface -> Screen blits
             new D3DSurfaceToGDIWindowSurfaceBlit(),
@@ -123,8 +125,6 @@
 
             new D3DSwToSurfaceTransform(SurfaceType.IntArgb,
                                         D3DSurfaceData.ST_INT_ARGB),
-            new D3DSwToSurfaceTransform(SurfaceType.IntArgbPre,
-                                        D3DSurfaceData.ST_INT_ARGB_PRE),
             new D3DSwToSurfaceTransform(SurfaceType.IntRgb,
                                         D3DSurfaceData.ST_INT_RGB),
             new D3DSwToSurfaceTransform(SurfaceType.IntBgr,
@@ -140,6 +140,9 @@
             // REMIND: we don't have a native sw loop to back this loop up
 //            new D3DSwToSurfaceTransform(SurfaceType.ByteIndexedBm,
 //                                        D3DSurfaceData.ST_BYTE_INDEXED_BM),
+            transformBlitIntArgbPreToSurface,
+
+            new D3DGeneralTransformedBlit(transformBlitIntArgbPreToSurface),
 
             // texture->surface ops
             new D3DTextureToSurfaceBlit(),
@@ -712,11 +715,11 @@
  * This general Blit 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.
+ * (premultiplied) surface down to D3D using simple blit.
  */
 class D3DGeneralBlit extends Blit {
 
-    private Blit performop;
+    private final Blit performop;
     private WeakReference srcTmp;
 
     D3DGeneralBlit(SurfaceType dstType,
@@ -757,6 +760,49 @@
     }
 }
 
+/**
+ * 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 D3D->sysmem->GDI path is known to be very very slow).
--- a/test/java/awt/image/DrawImage/UnmanagedDrawImagePerformance.java	Wed Oct 22 12:33:28 2014 +0400
+++ b/test/java/awt/image/DrawImage/UnmanagedDrawImagePerformance.java	Thu Oct 23 19:59:27 2014 +0400
@@ -41,7 +41,7 @@
 
 /*
  * @test
- * @bug 8029253
+ * @bug 8029253 8059941
  * @summary Unmanaged images should be drawn fast.
  * @author Sergey Bylokhov
  */