apache-flex - AS3/Flex : Improving slow performance of drawing Application using BitmapData. 绘制()

标签 apache-flex actionscript-3 performance drawing bitmapdata

我正在使用自定义 Flex 皮肤在 float 面板、TitleWindows 和其他容器的背景上创建主动模糊/磨砂玻璃效果(类似于 http://www.pixelfumes.com/blog/apr07/activeBlurClass.html )。应用程序皮肤中有一个背景图像,并且在事件模糊组件的上方和下方可能有任意数量的其他组件。以下是皮肤中的一些相关代码:

public static const BLUR_FILTER :BlurFilter = new BlurFilter(16, 16, BitmapFilterQuality.HIGH);

private var _bitmapFill :BitmapFill = new BitmapFill;

private var _matrix :Matrix = new Matrix;

protected function handleEnterFrameEvent (event :Event) :void {

    var bitmapData :BitmapData,
        matrix :Matrix;

    // only run if component has width and height
    if (unscaledWidth && unscaledHeight) {
        bitmapData = new BitmapData(unscaledWidth, unscaledHeight, false);
        // use the component's transform matrix to source the area to draw
        matrix = transform.concatenatedMatrix;
        _matrix.tx = -matrix.tx;
        _matrix.ty = -matrix.ty;
        // hide component to draw what's behind it
        visible = false;
        // this is the performance hit: draw the application to a bitmap
        bitmapData.draw(IBitmapDrawable(parentApplication), _matrix);
        visible = true;
        bitmapData.applyFilter(bitmapData, bitmapData.rect, new Point, BLUR_FILTER);
        _bitmapFill.source = bitmapData
        backgroundRect.fill = _bitmapFill;
    }

}

不幸的是,当组件调整大小时,尤其是移动时,其性能很差。存在明显的拖动延迟和整体速度减慢,这是测试应用程序中仅弹出一个标题窗口的情况。当 TitleWindow 内的组件发生更改(按钮悬停状态等)时,性能特别差

我尝试通过避免重新实例化模糊滤镜、位图填充和矩阵来进行一些优化,但这几乎没有效果。我一度删除了模糊,只是将应用程序绘制到位图上,但性能仍然很差,因此很明显,这主要是 BitmapData.draw() 调用。

我已经阅读过有关使用scrollRect和cacheAsBitmap的信息,但我不确定在应用程序或其组件中的何处应用这些属性(或我不知道的其他优化)。

我已经被这个问题困扰了一段时间,并决定是时候伸出援手了。提前致谢!

最佳答案

这个真的很有趣.. 您是否测试过添加事件监听器,例如用于触发重绘的布局管理器和 用相同的像素混合器着色器替换模糊过滤器?

关于apache-flex - AS3/Flex : Improving slow performance of drawing Application using BitmapData. 绘制(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6156278/

相关文章:

mysql - 在 Flex 移动应用程序中显示可滚动图片网格的最佳方法

actionscript-3 - Adobe Air - 分析

apache-flex - Flexunit 与 Flex Builder 3 中的纯 ActionScript 项目

actionscript-3 - 了解dispatchEvent(evt.clone())

actionscript-3 - AS3 : Loop in enterframe/s

performance - Adobe AIR 与 iOS 8 相关的问题和性能不佳

c++ - 假栈比真栈快吗

java - 如何提高RestTemplate的性能

mysql - 优化 select 中的派生表

xml - 柔性 : How to tell if XML is well formatted?