src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java
changeset 52248 2e330da7cbf4
parent 47977 dcf5dacd0b2b
child 58633 0c518cbf1dcc
equal deleted inserted replaced
52247:f775f83d6b60 52248:2e330da7cbf4
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1856             // of subsequent rendering calls.  In either case, this relaxed
  1856             // of subsequent rendering calls.  In either case, this relaxed
  1857             // test should not be significantly less accurate than the
  1857             // test should not be significantly less accurate than the
  1858             // optimal test for most transforms and so the conservative
  1858             // optimal test for most transforms and so the conservative
  1859             // answer should not cause too much extra work.
  1859             // answer should not cause too much extra work.
  1860 
  1860 
  1861             double d[] = {
  1861             double[] d = {
  1862                 x, y,
  1862                 x, y,
  1863                 x+width, y,
  1863                 x+width, y,
  1864                 x, y+height,
  1864                 x, y+height,
  1865                 x+width, y+height
  1865                 x+width, y+height
  1866             };
  1866             };
  1903         } else if (usrClip instanceof Rectangle2D) {
  1903         } else if (usrClip instanceof Rectangle2D) {
  1904             clipState = CLIP_RECTANGULAR;
  1904             clipState = CLIP_RECTANGULAR;
  1905             clipRegion = devClip.getIntersection((Rectangle2D) usrClip);
  1905             clipRegion = devClip.getIntersection((Rectangle2D) usrClip);
  1906         } else {
  1906         } else {
  1907             PathIterator cpi = usrClip.getPathIterator(null);
  1907             PathIterator cpi = usrClip.getPathIterator(null);
  1908             int box[] = new int[4];
  1908             int[] box = new int[4];
  1909             ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
  1909             ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
  1910             try {
  1910             try {
  1911                 sr.setOutputArea(devClip);
  1911                 sr.setOutputArea(devClip);
  1912                 sr.appendPath(cpi);
  1912                 sr.appendPath(cpi);
  1913                 sr.getPathBox(box);
  1913                 sr.getPathBox(box);
  1990 
  1990 
  1991         if (clip instanceof Rectangle2D &&
  1991         if (clip instanceof Rectangle2D &&
  1992             (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
  1992             (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
  1993         {
  1993         {
  1994             Rectangle2D rect = (Rectangle2D) clip;
  1994             Rectangle2D rect = (Rectangle2D) clip;
  1995             double matrix[] = new double[4];
  1995             double[] matrix = new double[4];
  1996             matrix[0] = rect.getX();
  1996             matrix[0] = rect.getX();
  1997             matrix[1] = rect.getY();
  1997             matrix[1] = rect.getY();
  1998             matrix[2] = matrix[0] + rect.getWidth();
  1998             matrix[2] = matrix[0] + rect.getWidth();
  1999             matrix[3] = matrix[1] + rect.getHeight();
  1999             matrix[3] = matrix[1] + rect.getHeight();
  2000             tx.transform(matrix, 0, matrix, 0, 2);
  2000             tx.transform(matrix, 0, matrix, 0, 2);
  2349         } finally {
  2349         } finally {
  2350             surfaceData.markDirty();
  2350             surfaceData.markDirty();
  2351         }
  2351         }
  2352     }
  2352     }
  2353 
  2353 
  2354     public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
  2354     public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
  2355         try {
  2355         try {
  2356             drawpipe.drawPolyline(this, xPoints, yPoints, nPoints);
  2356             drawpipe.drawPolyline(this, xPoints, yPoints, nPoints);
  2357         } catch (InvalidPipeException e) {
  2357         } catch (InvalidPipeException e) {
  2358             try {
  2358             try {
  2359                 revalidateAll();
  2359                 revalidateAll();
  2366         } finally {
  2366         } finally {
  2367             surfaceData.markDirty();
  2367             surfaceData.markDirty();
  2368         }
  2368         }
  2369     }
  2369     }
  2370 
  2370 
  2371     public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
  2371     public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
  2372         try {
  2372         try {
  2373             drawpipe.drawPolygon(this, xPoints, yPoints, nPoints);
  2373             drawpipe.drawPolygon(this, xPoints, yPoints, nPoints);
  2374         } catch (InvalidPipeException e) {
  2374         } catch (InvalidPipeException e) {
  2375             try {
  2375             try {
  2376                 revalidateAll();
  2376                 revalidateAll();
  2383         } finally {
  2383         } finally {
  2384             surfaceData.markDirty();
  2384             surfaceData.markDirty();
  2385         }
  2385         }
  2386     }
  2386     }
  2387 
  2387 
  2388     public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
  2388     public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
  2389         try {
  2389         try {
  2390             fillpipe.fillPolygon(this, xPoints, yPoints, nPoints);
  2390             fillpipe.fillPolygon(this, xPoints, yPoints, nPoints);
  2391         } catch (InvalidPipeException e) {
  2391         } catch (InvalidPipeException e) {
  2392             try {
  2392             try {
  2393                 revalidateAll();
  2393                 revalidateAll();
  2584             new Rectangle(img.getMinX(), img.getMinY(),
  2584             new Rectangle(img.getMinX(), img.getMinY(),
  2585                           img.getWidth(), img.getHeight());
  2585                           img.getWidth(), img.getHeight());
  2586 
  2586 
  2587         Rectangle result = null;
  2587         Rectangle result = null;
  2588         try {
  2588         try {
  2589             double p[] = new double[8];
  2589             double[] p = new double[8];
  2590             p[0] = p[2] = compClip.getLoX();
  2590             p[0] = p[2] = compClip.getLoX();
  2591             p[4] = p[6] = compClip.getHiX();
  2591             p[4] = p[6] = compClip.getHiX();
  2592             p[1] = p[5] = compClip.getLoY();
  2592             p[1] = p[5] = compClip.getLoY();
  2593             p[3] = p[7] = compClip.getHiY();
  2593             p[3] = p[7] = compClip.getHiY();
  2594 
  2594 
  3014         } finally {
  3014         } finally {
  3015             surfaceData.markDirty();
  3015             surfaceData.markDirty();
  3016         }
  3016         }
  3017     }
  3017     }
  3018 
  3018 
  3019     public void drawChars(char data[], int offset, int length, int x, int y) {
  3019     public void drawChars(char[] data, int offset, int length, int x, int y) {
  3020 
  3020 
  3021         if (data == null) {
  3021         if (data == null) {
  3022             throw new NullPointerException("char data is null");
  3022             throw new NullPointerException("char data is null");
  3023         }
  3023         }
  3024         if (offset < 0 || length < 0 || offset + length > data.length) {
  3024         if (offset < 0 || length < 0 || offset + length > data.length) {
  3047         } finally {
  3047         } finally {
  3048             surfaceData.markDirty();
  3048             surfaceData.markDirty();
  3049         }
  3049         }
  3050     }
  3050     }
  3051 
  3051 
  3052     public void drawBytes(byte data[], int offset, int length, int x, int y) {
  3052     public void drawBytes(byte[] data, int offset, int length, int x, int y) {
  3053         if (data == null) {
  3053         if (data == null) {
  3054             throw new NullPointerException("byte data is null");
  3054             throw new NullPointerException("byte data is null");
  3055         }
  3055         }
  3056         if (offset < 0 || length < 0 || offset + length > data.length) {
  3056         if (offset < 0 || length < 0 || offset + length > data.length) {
  3057             throw new ArrayIndexOutOfBoundsException("bad offset/length");
  3057             throw new ArrayIndexOutOfBoundsException("bad offset/length");
  3058         }
  3058         }
  3059         /* Byte data is interpreted as 8-bit ASCII. Re-use drawChars loops */
  3059         /* Byte data is interpreted as 8-bit ASCII. Re-use drawChars loops */
  3060         char chData[] = new char[length];
  3060         char[] chData = new char[length];
  3061         for (int i = length; i-- > 0; ) {
  3061         for (int i = length; i-- > 0; ) {
  3062             chData[i] = (char)(data[i+offset] & 0xff);
  3062             chData[i] = (char)(data[i+offset] & 0xff);
  3063         }
  3063         }
  3064         if (font.hasLayoutAttributes()) {
  3064         if (font.hasLayoutAttributes()) {
  3065             if (data.length == 0) {
  3065             if (data.length == 0) {