author | bagiras |
Thu, 25 Oct 2012 09:55:33 +0400 | |
changeset 14304 | 6a1cc5fc1ba0 |
parent 13771 | 77ca6d7c53d2 |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
887 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. |
887 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
887 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
887 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
887 | 24 |
*/ |
25 |
||
26 |
package sun.java2d; |
|
27 |
||
28 |
import java.awt.Color; |
|
29 |
import java.awt.Font; |
|
30 |
import java.awt.Graphics2D; |
|
31 |
import sun.awt.Win32GraphicsConfig; |
|
32 |
import sun.awt.windows.WComponentPeer; |
|
33 |
import sun.java2d.d3d.D3DScreenUpdateManager; |
|
34 |
import sun.java2d.windows.WindowsFlags; |
|
35 |
||
36 |
/** |
|
37 |
* This class handles the creation of on-screen surfaces and |
|
38 |
* corresponding graphics objects. |
|
39 |
* |
|
40 |
* By default it delegates the surface creation to the |
|
41 |
* particular GraphicsConfiguration classes. |
|
42 |
*/ |
|
43 |
public class ScreenUpdateManager { |
|
44 |
private static ScreenUpdateManager theInstance; |
|
45 |
||
46 |
protected ScreenUpdateManager() { |
|
47 |
} |
|
48 |
||
49 |
/** |
|
50 |
* Creates a SunGraphics2D object for the surface, |
|
51 |
* given the parameters. |
|
52 |
* |
|
53 |
* @param sd surface data for which a graphics is to be created |
|
54 |
* @param peer peer which owns the surface |
|
55 |
* @param fgColor fg color to be used in the graphics |
|
56 |
* @param bgColor bg color to be used in the graphics |
|
57 |
* @param font font to be used in the graphics |
|
58 |
* @return a SunGraphics2D object for rendering to the passed surface |
|
59 |
*/ |
|
60 |
public synchronized Graphics2D createGraphics(SurfaceData sd, |
|
61 |
WComponentPeer peer, Color fgColor, Color bgColor, Font font) |
|
62 |
{ |
|
63 |
return new SunGraphics2D(sd, fgColor, bgColor, font); |
|
64 |
} |
|
65 |
||
66 |
/** |
|
67 |
* Creates and returns the surface for the peer. This surface becomes |
|
68 |
* managed by this manager. To remove the surface from the managed list |
|
69 |
* {@code}dropScreenSurface(SurfaceData){@code} will need to be called. |
|
70 |
* |
|
71 |
* The default implementation delegates surface creation |
|
72 |
* to the passed in GraphicsConfiguration object. |
|
73 |
* |
|
74 |
* @param gc graphics configuration for which the surface is to be created |
|
75 |
* @param peer peer for which the onscreen surface is to be created |
|
76 |
* @param bbNum number of back-buffers requested for this peer |
|
77 |
* @param isResize whether this surface is being created in response to |
|
78 |
* a component resize event |
|
79 |
* @return a SurfaceData to be used for on-screen rendering for this peer. |
|
80 |
* @see #dropScreenSurface(SurfaceData) |
|
81 |
*/ |
|
82 |
public SurfaceData createScreenSurface(Win32GraphicsConfig gc, |
|
83 |
WComponentPeer peer, int bbNum, |
|
84 |
boolean isResize) |
|
85 |
{ |
|
86 |
return gc.createSurfaceData(peer, bbNum); |
|
87 |
} |
|
88 |
||
89 |
/** |
|
90 |
* Drops the passed surface from the list of managed surfaces. |
|
91 |
* |
|
92 |
* Nothing happens if the surface wasn't managed by this manager. |
|
93 |
* |
|
94 |
* @param sd SurfaceData to be removed from the list of managed surfaces |
|
95 |
*/ |
|
96 |
public void dropScreenSurface(SurfaceData sd) {} |
|
97 |
||
98 |
/** |
|
99 |
* Returns a replacement SurfaceData for the invalid passed one. |
|
100 |
* |
|
101 |
* This method should be used by SurfaceData's created by |
|
102 |
* the ScreenUpdateManager for providing replacement surfaces. |
|
103 |
* |
|
104 |
* @param peer to which the old surface belongs |
|
105 |
* @param oldsd the old (invalid) surface to get replaced |
|
106 |
* @return a replacement surface |
|
107 |
* @see sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData#getReplacement() |
|
108 |
* @see sun.java2d.windows.GDIWindowSurfaceData#getReplacement() |
|
109 |
*/ |
|
110 |
public SurfaceData getReplacementScreenSurface(WComponentPeer peer, |
|
111 |
SurfaceData oldsd) |
|
112 |
{ |
|
13771
77ca6d7c53d2
7153339: InternalError when drawLine with Xor and Antialiasing
bagiras
parents:
5506
diff
changeset
|
113 |
SurfaceData surfaceData = peer.getSurfaceData(); |
14304
6a1cc5fc1ba0
8000486: REGRESSION: Three java2d tests fail since jdk8b58 on Windows 7 with NullPointerException
bagiras
parents:
13771
diff
changeset
|
114 |
if (surfaceData == null || surfaceData.isValid()) { |
13771
77ca6d7c53d2
7153339: InternalError when drawLine with Xor and Antialiasing
bagiras
parents:
5506
diff
changeset
|
115 |
return surfaceData; |
77ca6d7c53d2
7153339: InternalError when drawLine with Xor and Antialiasing
bagiras
parents:
5506
diff
changeset
|
116 |
} |
77ca6d7c53d2
7153339: InternalError when drawLine with Xor and Antialiasing
bagiras
parents:
5506
diff
changeset
|
117 |
peer.replaceSurfaceData(); |
887 | 118 |
return peer.getSurfaceData(); |
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Returns an (singleton) instance of the screen surfaces |
|
123 |
* manager class. |
|
124 |
* @return instance of onscreen surfaces manager |
|
125 |
*/ |
|
126 |
public static synchronized ScreenUpdateManager getInstance() { |
|
127 |
if (theInstance == null) { |
|
128 |
if (WindowsFlags.isD3DEnabled()) { |
|
129 |
theInstance = new D3DScreenUpdateManager(); |
|
130 |
} else { |
|
131 |
theInstance = new ScreenUpdateManager(); |
|
132 |
} |
|
133 |
} |
|
134 |
return theInstance; |
|
135 |
} |
|
136 |
} |