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 *
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.
24 */
25
26 package com.sun.scenario.effect;
27
28 import com.sun.scenario.effect.impl.EffectPeer;
29 import com.sun.scenario.effect.impl.Renderer;
30 import com.sun.javafx.geom.Rectangle;
31 import com.sun.javafx.geom.transform.BaseTransform;
32
33 /**
34 * Package-private base class for built-in effects, i.e., those that are
35 * backed by an EffectPeer implementation.
36 */
37 abstract class CoreEffect extends FilterEffect {
38
39 private String peerKey;
40 private int peerCount = -1;
41
42 CoreEffect() {
43 super();
44 }
45
46 CoreEffect(Effect input) {
47 super(input);
48 }
49
50 CoreEffect(Effect input1, Effect input2) {
51 super(input1, input2);
52 }
53
54 final void updatePeerKey(String key) {
55 updatePeerKey(key, -1);
56 }
57
82 if (inputs.length > 0) {
83 Rectangle approxBounds = inputs[0].getUntransformedBounds();
84 approxW = approxBounds.width;
85 approxH = approxBounds.height;
86 } else {
87 // NOTE: temporary hack until we start using result bounds
88 // (see comment above)...
89 approxW = approxH = 500;
90 }
91 return getPeer(fctx, approxW, approxH);
92 }
93
94 /**
95 * Convenience method that sends the given input data through the
96 * current peer, and then attempts to release the input image data.
97 */
98 @Override
99 public ImageData filterImageDatas(FilterContext fctx,
100 BaseTransform transform,
101 Rectangle outputClip,
102 ImageData... inputs)
103 {
104 return getPeer(fctx, inputs).filter(this, transform, outputClip, inputs);
105 }
106
107 @Override
108 public AccelType getAccelType(FilterContext fctx) {
109 // We choose relatively large (yet arbitrary) values for approxW/H
110 // here so that we get the AccelType for the "ideal" case where
111 // hardware acceleration is used.
112 EffectPeer peer = getPeer(fctx, 1024, 1024);
113 return peer.getAccelType();
114 }
115 }
|
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 *
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.
24 */
25
26 package com.sun.scenario.effect;
27
28 import com.sun.scenario.effect.impl.EffectPeer;
29 import com.sun.scenario.effect.impl.Renderer;
30 import com.sun.javafx.geom.Rectangle;
31 import com.sun.javafx.geom.transform.BaseTransform;
32 import com.sun.scenario.effect.impl.state.RenderState;
33
34 /**
35 * Package-private base class for built-in effects, i.e., those that are
36 * backed by an EffectPeer implementation.
37 */
38 abstract class CoreEffect<T extends RenderState> extends FilterEffect<T> {
39
40 private String peerKey;
41 private int peerCount = -1;
42
43 CoreEffect() {
44 super();
45 }
46
47 CoreEffect(Effect input) {
48 super(input);
49 }
50
51 CoreEffect(Effect input1, Effect input2) {
52 super(input1, input2);
53 }
54
55 final void updatePeerKey(String key) {
56 updatePeerKey(key, -1);
57 }
58
83 if (inputs.length > 0) {
84 Rectangle approxBounds = inputs[0].getUntransformedBounds();
85 approxW = approxBounds.width;
86 approxH = approxBounds.height;
87 } else {
88 // NOTE: temporary hack until we start using result bounds
89 // (see comment above)...
90 approxW = approxH = 500;
91 }
92 return getPeer(fctx, approxW, approxH);
93 }
94
95 /**
96 * Convenience method that sends the given input data through the
97 * current peer, and then attempts to release the input image data.
98 */
99 @Override
100 public ImageData filterImageDatas(FilterContext fctx,
101 BaseTransform transform,
102 Rectangle outputClip,
103 T rstate,
104 ImageData... inputs)
105 {
106 return getPeer(fctx, inputs).filter(this, rstate, transform, outputClip, inputs);
107 }
108
109 @Override
110 public AccelType getAccelType(FilterContext fctx) {
111 // We choose relatively large (yet arbitrary) values for approxW/H
112 // here so that we get the AccelType for the "ideal" case where
113 // hardware acceleration is used.
114 EffectPeer peer = getPeer(fctx, 1024, 1024);
115 return peer.getAccelType();
116 }
117 }
|