modules/graphics/src/main/java/com/sun/scenario/effect/BoxBlur.java
Print this page
*** 31,47 ****
import com.sun.javafx.geom.RectBounds;
import com.sun.javafx.geom.Rectangle;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.scenario.effect.impl.Renderer;
import com.sun.scenario.effect.impl.state.BoxBlurState;
/**
* A blur effect using a box-shaped convolution kernel, with a configurable
* size for each dimension of the kernel and a number of passes to control
* the quality of the blur.
*/
! public class BoxBlur extends CoreEffect {
private final BoxBlurState state = new BoxBlurState();
/**
* Constructs a new {@code BoxBlur} effect with
--- 31,48 ----
import com.sun.javafx.geom.RectBounds;
import com.sun.javafx.geom.Rectangle;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.scenario.effect.impl.Renderer;
import com.sun.scenario.effect.impl.state.BoxBlurState;
+ import com.sun.scenario.effect.impl.state.LinearConvolveKernel;
/**
* A blur effect using a box-shaped convolution kernel, with a configurable
* size for each dimension of the kernel and a number of passes to control
* the quality of the blur.
*/
! public class BoxBlur extends LinearConvolveCoreEffect {
private final BoxBlurState state = new BoxBlurState();
/**
* Constructs a new {@code BoxBlur} effect with
*** 52,62 ****
* <pre>
* new BoxBlur(1, 1, 1, DefaultInput)
* </pre>
*/
public BoxBlur() {
! this(1, 1);
}
/**
* Constructs a new {@code BoxBlur} effect with
* the given blur sizes
--- 53,63 ----
* <pre>
* new BoxBlur(1, 1, 1, DefaultInput)
* </pre>
*/
public BoxBlur() {
! this(1.0f, 1.0f);
}
/**
* Constructs a new {@code BoxBlur} effect with
* the given blur sizes
*** 70,80 ****
* @param hsize the horizontal size of the BoxBlur kernel
* @param vsize the vertical size of the BoxBlur kernel
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} is outside the allowable range
*/
! public BoxBlur(int hsize, int vsize) {
this(hsize, vsize, 1, DefaultInput);
}
/**
* Constructs a new {@code BoxBlur} effect with
--- 71,81 ----
* @param hsize the horizontal size of the BoxBlur kernel
* @param vsize the vertical size of the BoxBlur kernel
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} is outside the allowable range
*/
! public BoxBlur(float hsize, float vsize) {
this(hsize, vsize, 1, DefaultInput);
}
/**
* Constructs a new {@code BoxBlur} effect with
*** 91,101 ****
* @param passes the number of blur passes to execute
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} or {@code passes}
* is outside the allowable range
*/
! public BoxBlur(int hsize, int vsize, int passes) {
this(hsize, vsize, passes, DefaultInput);
}
/**
* Constructs a new {@code BoxBlur} effect with
--- 92,102 ----
* @param passes the number of blur passes to execute
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} or {@code passes}
* is outside the allowable range
*/
! public BoxBlur(float hsize, float vsize, int passes) {
this(hsize, vsize, passes, DefaultInput);
}
/**
* Constructs a new {@code BoxBlur} effect with
*** 109,127 ****
* @param input the single input {@code Effect}
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} or {@code passes}
* is outside the allowable range
*/
! public BoxBlur(int hsize, int vsize, int passes, Effect input) {
super(input);
setHorizontalSize(hsize);
setVerticalSize(vsize);
setPasses(passes);
}
@Override
! Object getState() {
return state;
}
/**
* Returns the input for this {@code Effect}.
--- 110,128 ----
* @param input the single input {@code Effect}
* @throws IllegalArgumentException if either {@code hsize}
* or {@code vsize} or {@code passes}
* is outside the allowable range
*/
! public BoxBlur(float hsize, float vsize, int passes, Effect input) {
super(input);
setHorizontalSize(hsize);
setVerticalSize(vsize);
setPasses(passes);
}
@Override
! LinearConvolveKernel getState() {
return state;
}
/**
* Returns the input for this {@code Effect}.
*** 147,157 ****
/**
* Returns the horizontal size of the effect kernel.
*
* @return the horizontal size of the effect kernel
*/
! public int getHorizontalSize() {
return state.getHsize();
}
/**
* Sets the horizontal size of the effect kernel.
--- 148,158 ----
/**
* Returns the horizontal size of the effect kernel.
*
* @return the horizontal size of the effect kernel
*/
! public float getHorizontalSize() {
return state.getHsize();
}
/**
* Sets the horizontal size of the effect kernel.
*** 164,184 ****
*
* @param hsize the horizontal size of the effect kernel
* @throws IllegalArgumentException if {@code hsize}
* is outside the allowable range
*/
! public void setHorizontalSize(int hsize) {
! int old = state.getHsize();
state.setHsize(hsize);
}
/**
* Returns the vertical size of the effect kernel.
*
* @return the vertical size of the effect kernel
*/
! public int getVerticalSize() {
return state.getVsize();
}
/**
* Sets the vertical size of the effect kernel.
--- 165,184 ----
*
* @param hsize the horizontal size of the effect kernel
* @throws IllegalArgumentException if {@code hsize}
* is outside the allowable range
*/
! public final void setHorizontalSize(float hsize) {
state.setHsize(hsize);
}
/**
* Returns the vertical size of the effect kernel.
*
* @return the vertical size of the effect kernel
*/
! public float getVerticalSize() {
return state.getVsize();
}
/**
* Sets the vertical size of the effect kernel.
*** 191,202 ****
*
* @param vsize the vertical size of the effect kernel
* @throws IllegalArgumentException if {@code vsize}
* is outside the allowable range
*/
! public void setVerticalSize(int vsize) {
! int old = state.getVsize();
state.setVsize(vsize);
}
/**
* Returns the number of passes of the effect kernel to control the
--- 191,201 ----
*
* @param vsize the vertical size of the effect kernel
* @throws IllegalArgumentException if {@code vsize}
* is outside the allowable range
*/
! public final void setVerticalSize(float vsize) {
state.setVsize(vsize);
}
/**
* Returns the number of passes of the effect kernel to control the
*** 222,233 ****
*
* @param passes
* @throws IllegalArgumentException if {@code passes} is outside the
* allowable range
*/
! public void setPasses(int passes) {
! int old = state.getBlurPasses();
state.setBlurPasses(passes);
}
@Override
public AccelType getAccelType(FilterContext fctx) {
--- 221,231 ----
*
* @param passes
* @throws IllegalArgumentException if {@code passes} is outside the
* allowable range
*/
! public final void setPasses(int passes) {
state.setBlurPasses(passes);
}
@Override
public AccelType getAccelType(FilterContext fctx) {
*** 255,297 ****
r.intersectWith(outputClip);
return r;
}
@Override
- public ImageData filterImageDatas(FilterContext fctx,
- BaseTransform transform,
- Rectangle outputClip,
- ImageData... inputs)
- {
- return state.filterImageDatas(this, fctx, transform, outputClip, inputs);
- }
-
- @Override
- public boolean operatesInUserSpace() {
- return true;
- }
-
- @Override
- protected Rectangle getInputClip(int inputIndex,
- BaseTransform transform,
- Rectangle outputClip)
- {
- // A blur needs as much "fringe" data from its input as it creates
- // around its output so we use the same expansion as is used in the
- // result bounds.
- if (outputClip != null) {
- int hgrow = state.getKernelSize(0) / 2;
- int vgrow = state.getKernelSize(1) / 2;
- if ((hgrow | vgrow) != 0) {
- outputClip = new Rectangle(outputClip);
- outputClip.grow(hgrow, vgrow);
- }
- }
- return outputClip;
- }
-
- @Override
public boolean reducesOpaquePixels() {
if (!state.isNop()) {
return true;
}
final Effect input = getInput();
--- 253,262 ----