@Override protected void dispatchDraw(Canvas canvas) { // If this is off-screen pass apply blur only if (mBlurRenderer.isOffscreenCanvas(canvas)) { mBlurRenderer.applyBlur(); } // Otherwise draw blurred background image and continue to child views else { mBlurRenderer.drawToCanvas(canvas); super.dispatchDraw(canvas); } }
public MuzeiView(Context context, String mPictureName) { super(context); mRenderer = new BlurRenderer(getContext(), RendererFragment.this); setEGLContextClientVersion(2); setEGLConfigChooser(8, 8, 8, 8, 0, 0); setRenderer(mRenderer); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); mRenderController = new DemoRenderController( getContext(), mRenderer, RendererFragment.this, mDemoFocus, mPictureName); mRenderer.setDemoMode(mDemoMode); mRenderController.setVisible(true); }
/** Default constructor */ public BlurLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); mBlurRenderer = new BlurRenderer(this); // Read blur radius from the layout parameters TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BlurView); for (int i = 0; i < a.getIndexCount(); ++i) { int attr = a.getIndex(i); if (attr == R.styleable.BlurView_radius) { int radius = a.getDimensionPixelSize(attr, 1); mBlurRenderer.setBlurRadius(radius); } } a.recycle(); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mRenderer.hintViewportSize(w, h); mRenderController.reloadCurrentArtwork(true); }
/** Set blur radius in pixels */ public void setBlurRadius(int radius) { mBlurRenderer.setBlurRadius(radius); invalidate(); }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mBlurRenderer.onDetachedFromWindow(); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mBlurRenderer.onAttachedToWindow(); }