src/share/classes/sun/java2d/loops/GraphicsPrimitive.java

Print this page
rev 9629 : 8038644: Fix raw and unchecked warnings in sun.java2d.*
Reviewed-by:


 299         }
 300         return true;
 301     }
 302 
 303     //
 304     // A version of satisfies used for regression testing
 305     //
 306     final boolean satisfiesSameAs(GraphicsPrimitive other) {
 307         return (methodSignature == other.methodSignature &&
 308                 sourceType.equals(other.sourceType) &&
 309                 compositeType.equals(other.compositeType) &&
 310                 destType.equals(other.destType));
 311     }
 312 
 313     public abstract GraphicsPrimitive makePrimitive(SurfaceType srctype,
 314                                                     CompositeType comptype,
 315                                                     SurfaceType dsttype);
 316 
 317     public abstract GraphicsPrimitive traceWrap();
 318 
 319     static HashMap traceMap;
 320 
 321     public static int traceflags;
 322     public static String tracefile;
 323     public static PrintStream traceout;
 324 
 325     public static final int TRACELOG = 1;
 326     public static final int TRACETIMESTAMP = 2;
 327     public static final int TRACECOUNTS = 4;
 328 
 329     static {
 330         GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
 331         String trace = AccessController.doPrivileged(gpa);
 332         if (trace != null) {
 333             boolean verbose = false;
 334             int traceflags = 0;
 335             StringTokenizer st = new StringTokenizer(trace, ",");
 336             while (st.hasMoreTokens()) {
 337                 String tok = st.nextToken();
 338                 if (tok.equalsIgnoreCase("count")) {
 339                     traceflags |= GraphicsPrimitive.TRACECOUNTS;


 410                 traceout = System.err;
 411             }
 412         }
 413         return traceout;
 414     }
 415 
 416     public static class TraceReporter extends Thread {
 417         public static void setShutdownHook() {
 418             AccessController.doPrivileged(new PrivilegedAction<Void>() {
 419                 public Void run() {
 420                     TraceReporter t = new TraceReporter();
 421                     t.setContextClassLoader(null);
 422                     Runtime.getRuntime().addShutdownHook(t);
 423                     return null;
 424                 }
 425             });
 426         }
 427 
 428         public void run() {
 429             PrintStream ps = getTraceOutputFile();
 430             Iterator iterator = traceMap.entrySet().iterator();

 431             long total = 0;
 432             int numprims = 0;
 433             while (iterator.hasNext()) {
 434                 Map.Entry me = (Map.Entry) iterator.next();
 435                 Object prim = me.getKey();
 436                 int[] count = (int[]) me.getValue();
 437                 if (count[0] == 1) {
 438                     ps.print("1 call to ");
 439                 } else {
 440                     ps.print(count[0]+" calls to ");
 441                 }
 442                 ps.println(prim);
 443                 numprims++;
 444                 total += count[0];
 445             }
 446             if (numprims == 0) {
 447                 ps.println("No graphics primitives executed");
 448             } else if (numprims > 1) {
 449                 ps.println(total+" total calls to "+
 450                            numprims+" different primitives");
 451             }
 452         }
 453     }
 454 
 455     public synchronized static void tracePrimitive(Object prim) {
 456         if ((traceflags & TRACECOUNTS) != 0) {
 457             if (traceMap == null) {
 458                 traceMap = new HashMap();
 459                 TraceReporter.setShutdownHook();
 460             }
 461             Object o = traceMap.get(prim);
 462             if (o == null) {
 463                 o = new int[1];
 464                 traceMap.put(prim, o);
 465             }
 466             ((int[]) o)[0]++;
 467         }
 468         if ((traceflags & TRACELOG) != 0) {
 469             PrintStream ps = getTraceOutputFile();
 470             if ((traceflags & TRACETIMESTAMP) != 0) {
 471                 ps.print(System.currentTimeMillis()+": ");
 472             }
 473             ps.println(prim);
 474         }
 475     }
 476 
 477     protected void setupGeneralBinaryOp(GeneralBinaryOp gbo) {
 478         int primID = gbo.getPrimTypeID();
 479         String methodSignature = gbo.getSignature();
 480         SurfaceType srctype = gbo.getSourceType();
 481         CompositeType comptype = gbo.getCompositeType();
 482         SurfaceType dsttype = gbo.getDestType();
 483         Blit convertsrc, convertdst, convertres;
 484         GraphicsPrimitive performop;
 485 
 486         convertsrc = createConverter(srctype, SurfaceType.IntArgb);




 299         }
 300         return true;
 301     }
 302 
 303     //
 304     // A version of satisfies used for regression testing
 305     //
 306     final boolean satisfiesSameAs(GraphicsPrimitive other) {
 307         return (methodSignature == other.methodSignature &&
 308                 sourceType.equals(other.sourceType) &&
 309                 compositeType.equals(other.compositeType) &&
 310                 destType.equals(other.destType));
 311     }
 312 
 313     public abstract GraphicsPrimitive makePrimitive(SurfaceType srctype,
 314                                                     CompositeType comptype,
 315                                                     SurfaceType dsttype);
 316 
 317     public abstract GraphicsPrimitive traceWrap();
 318 
 319     static HashMap<Object, int[]> traceMap;
 320 
 321     public static int traceflags;
 322     public static String tracefile;
 323     public static PrintStream traceout;
 324 
 325     public static final int TRACELOG = 1;
 326     public static final int TRACETIMESTAMP = 2;
 327     public static final int TRACECOUNTS = 4;
 328 
 329     static {
 330         GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
 331         String trace = AccessController.doPrivileged(gpa);
 332         if (trace != null) {
 333             boolean verbose = false;
 334             int traceflags = 0;
 335             StringTokenizer st = new StringTokenizer(trace, ",");
 336             while (st.hasMoreTokens()) {
 337                 String tok = st.nextToken();
 338                 if (tok.equalsIgnoreCase("count")) {
 339                     traceflags |= GraphicsPrimitive.TRACECOUNTS;


 410                 traceout = System.err;
 411             }
 412         }
 413         return traceout;
 414     }
 415 
 416     public static class TraceReporter extends Thread {
 417         public static void setShutdownHook() {
 418             AccessController.doPrivileged(new PrivilegedAction<Void>() {
 419                 public Void run() {
 420                     TraceReporter t = new TraceReporter();
 421                     t.setContextClassLoader(null);
 422                     Runtime.getRuntime().addShutdownHook(t);
 423                     return null;
 424                 }
 425             });
 426         }
 427 
 428         public void run() {
 429             PrintStream ps = getTraceOutputFile();
 430             Iterator<Map.Entry<Object, int[]>> iterator =
 431                 traceMap.entrySet().iterator();
 432             long total = 0;
 433             int numprims = 0;
 434             while (iterator.hasNext()) {
 435                 Map.Entry<Object, int[]> me = iterator.next();
 436                 Object prim = me.getKey();
 437                 int[] count = me.getValue();
 438                 if (count[0] == 1) {
 439                     ps.print("1 call to ");
 440                 } else {
 441                     ps.print(count[0]+" calls to ");
 442                 }
 443                 ps.println(prim);
 444                 numprims++;
 445                 total += count[0];
 446             }
 447             if (numprims == 0) {
 448                 ps.println("No graphics primitives executed");
 449             } else if (numprims > 1) {
 450                 ps.println(total+" total calls to "+
 451                            numprims+" different primitives");
 452             }
 453         }
 454     }
 455 
 456     public synchronized static void tracePrimitive(Object prim) {
 457         if ((traceflags & TRACECOUNTS) != 0) {
 458             if (traceMap == null) {
 459                 traceMap = new HashMap<>();
 460                 TraceReporter.setShutdownHook();
 461             }
 462             int[] o = traceMap.get(prim);
 463             if (o == null) {
 464                 o = new int[1];
 465                 traceMap.put(prim, o);
 466             }
 467             o[0]++;
 468         }
 469         if ((traceflags & TRACELOG) != 0) {
 470             PrintStream ps = getTraceOutputFile();
 471             if ((traceflags & TRACETIMESTAMP) != 0) {
 472                 ps.print(System.currentTimeMillis()+": ");
 473             }
 474             ps.println(prim);
 475         }
 476     }
 477 
 478     protected void setupGeneralBinaryOp(GeneralBinaryOp gbo) {
 479         int primID = gbo.getPrimTypeID();
 480         String methodSignature = gbo.getSignature();
 481         SurfaceType srctype = gbo.getSourceType();
 482         CompositeType comptype = gbo.getCompositeType();
 483         SurfaceType dsttype = gbo.getDestType();
 484         Blit convertsrc, convertdst, convertres;
 485         GraphicsPrimitive performop;
 486 
 487         convertsrc = createConverter(srctype, SurfaceType.IntArgb);