- 浏览: 390458 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
yanmie:
您的文章已被我们收录地址:http://www.airmyth ...
学习一下 Pixel Bender -
chaimzane:
我现在自己都有点看不懂了 实际上很简单, LocaleModu ...
Flex 优化技巧 -- 全局CSS样式模块实现RSLS 方式加载 -
muqingren:
以我现在对flex的了解,没看懂你说的........... ...
Flex 优化技巧 -- 全局CSS样式模块实现RSLS 方式加载 -
cony138:
卤煮碉堡了啊
A*寻路 -- 更加真实 的路径(一) -
jack_ye:
[/flash][/flash][/fl[u][u]ash][ ...
Alternativa3D 8 基础理论 / 概念
from: http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/
By Sean Christmann
Updated ‘Elastic Racetrack’ for Flash 9 and AVM2
In 2005 Ted Patrick posted a great article on the frame execution model inside the Flash Player that he dubbed the ‘elastic racetrack ‘. It’s served as a great reference for me over the years to help understand how code execution and rendering were balanced within the processing of a frame. Since the introduction of Flash Player 9 and the new AVM2, I’ve noticed a few changes to the elastic racetrack model and thought I’d share them. This information is based on research into Flash player internals as well as observations I’ve made playing around with the event and rendering model, but the full model hasn’t been confirmed by Adobe engineers.
The basic premise of the original elastic racetrack is still the same. Given a specific frame rate to operate on, the Flash player will devote the first segment of the frame to execute code, and the second segment to render display objects. Either segment can grow its part of the racetrack to accommodate more processing and effectively extend the duration of the frame
What changes from the previous model is how those segments look under a microscope and how they come together to form a ‘frame’.
AVM2 is controlled by what I’m going to call the Marshal. The Marshal is responsible for carving out time slices for the Flash Player to operate on. Its important to clarify up front that these time slices are not the same thing as the framerate compiled into a swf, but we’ll see below how the player ultimately synthesizes a framerate from these slices. Running a Flex compiled swf within Firefox under Mac OS X, the Marshal appears to be carving out 19-20 millisecond slices, but this can be different between platforms and browsers based on what I’ve observed as well as Adobe employees have hinted at . This can also change depending on how the swf was compiled, see some of the comments below. For the sake of the article lets assume we’re only talking about a 20 millisecond slice to make the math easy. This means the Marshal will attempt to generate and execute no more then 50 slices each second, and it may be less depending on the elasticity of code execution or rendering. Inside each slice, 5 possible steps are processed in the following order.
- Player events are dispatched – This includes events dispatched by the Timer, Mouse, ENTER_FRAMEs, URLLoader, etc…
- User code is executed – Any code listening to events dispatched by step 1 are executed at this stage.
- RENDER event is dispatched – This special event is dispatched when the user calls stage.invalidate() during normal user code operation.
- Final user code is executed – User code listening specifically for step 3 is executed at this point.
- Player renders changes to the display list.
The Marshal executes this 20 millisecond slice over and over and decides on the fly which actions to run. The exact actions processed within a slice will ultimately derive the 2 main racetrack segments (code execution and rendering) that constitute a ‘frame’. User actions and Invalidation actions fill up the code segment track, while Render actions fill up the render segment track. Its important to note that actions will only occur at times predetermined by the Marshal, so a if you have a short running User action, the Marshal will still wait a few milliseconds before moving on to the Invalidate and Render actions.
The best way to illustrate which actions are run and how the elastic racetrack is created, is to look at how those slices are processed on a swf running at 5 fps, 25, fps, and 50 fps.
As you can see, the elastic racetrack performs different actions per frame and requires a different visual illustration depending on the framerate that the player is trying to synthesize. So for a swf running at 5 fps, each frame processed 10 User actions, 1 Invalidation action, and 1 Render action. At 25 fps, each frame processed 2 User actions, 1 Invalidation action, and 1 Render action. At 50 fps, each frame processed 1 User action, 1 Invalidation action, and 1 Render action. Whats important to note in the above chart is that some events are only available in certain slices. For instance, the Event.ENTER_FRAME event will only ever be dispatched in a slice that occurs at the start of a frame.
So what does this all mean? Theres a couple quick ideas to take away from this.
- Long running code execution or render segments can extend a given slice beyond 20 milliseconds. Elasticity will be applied to that particular slice and the duration of the frame may or may not be extended as a result. The Marshal may drop the number of slices that constitute a frame in order to keep the active framerate close to the compiled framerate.
- A swfs real framerate won’t exceed the Marshals rate defined for the player instance. You can set your compiled framerate at 120fps, but Flash will still only process 50 slices max that generate 50 render calls (more or less depending on the system config).
- Code can be executed more often then the compiled framerate. A swf compiled at 1 fps can execute a Timer or Mouse event in every slice, even though it will only render in the last slice. Additionally, if you choose, you can render to the screen sooner then the compiled framerate by calling updateAfterEvent() , but only within a Mouse, Timer, or Keyboard event handler. In this instance though, the Marshal will consider that the end of the frame and start a new frame on the next slice. Lastly, Flash will force an automatic render when mousing over any Sprite that has had its visual properties (x,y,width,height,etc..) changed, naturally this still occurs at the end of the slice and any prerender logic will still run.
- Compiling a framerate that isn’t a multiple of the total number of slices per second for your platform will cause irregular rendering as it tries to divide up the slices. If you were to compile in a framerate of 20 on a platform executing 50 slices per second, then the player has to render 2 frames every 5 slices and would follow a 3-2-3-2-3-2 slice-to-render rate.
These 4 facts are moving targets though, since for this article we’re working on a 20 millisecond slice that’s processed 50 times per second. In reality you’ll see time slices as low as 5 milliseconds or as high at 100 milliseconds and some of the math will change as a result.
If you’d like to test this model for yourself, the easiest route is to create a swf running at 1 fps and another at 100 fps both with a Timer object set on a 1 millisecond interval. Inside the Timer event handler change the x property of a display object and hook a bunch of getTimer() traces up to different player events like Mouse, EnterFrame, and Render and watch the carnage unfold in your console. The rest of the information you can’t derive from the results comes from alot of context about the player I’ve learned over the past 2 years and so isn’t as easily visible. If anyone has any information to help add to or correct the above model, please submit it in the comments.
Thanks to several readers who have clarified some of the differences between Flex and Flash as well as how the Flash API is able to change the default behaviors described above.
发表评论
-
Android 中调用 其他 app 的 url 协议
2014-09-05 00:17 1577// var url:String = "i ... -
blog
2014-01-21 13:37 881http://www.catalinzima.com/ -
在cocos2d-x中实践数据驱动的游戏开发
2014-01-21 09:33 3337from: http://elvisco.de/2013/0 ... -
Packed SWF. How to unpack?
2013-10-29 19:23 1586from:http://blog.codestage.ru/ ... -
Stage3D Upload Speed Tester
2013-08-11 04:23 1784from: http://jacksondunstan.co ... -
Speed Up Alpha Textures With Stage3D By 4x
2013-07-26 13:44 2145from: http://jacksondunstan.c ... -
Stage3D optimisation
2013-07-26 13:07 1274from: http://blog.bwhiting.co ... -
Make an AS3 Flash Component with Custom UI Controls
2013-06-28 22:24 2185from: http://studio.barliesqu ... -
AdobeMax: Deep Dive into Flash Player Rendering
2013-06-21 10:41 1540from http://www.developria.com ... -
Why Starling (or any other 2D framework on top of Stage3D)?
2013-06-18 11:00 1088from: http://blog.kaourantin.n ... -
Updated ‘Elastic Racetrack’ for Flash 9 and AVM2
2013-06-18 10:10 1209from: http://www.craftymind.co ... -
HDR&ToneMapping
2013-06-06 09:43 1148from: http://blog.csdn.net/cca ... -
HDR渲染器的实现(基于OpenGL)
2013-06-06 09:37 1929from: http://dev.gameres.com/P ... -
Alternativa3D 8 基础理论 / 概念
2013-06-05 16:31 4451from: http://blog.csdn.net/lim ... -
3D图形技术概念和渲染管线的处理
2013-05-31 01:32 7041from: http://psv.tgbus.com/ne ... -
深度测试与alpha混合
2013-05-31 01:22 1919from: http://www.opengpu.org/f ... -
Molehill / ND2D – speeding up the engine
2013-05-30 10:15 1659from: http://www.nulldesign.d ... -
Why Starling (or any other 2D framework on top of Stage3D)?
2013-05-28 00:54 842from:http://blog.kaourantin.ne ... -
Adobe Pixel Bender in Flash Player 10 Beta
2013-05-27 23:46 777from: http://www.kaourantin.n ... -
网络游戏的对时以及同步问题
2013-05-15 16:27 1140from: http://blog.codingnow.co ...
相关推荐
标题“Relevant search with applications for Solr and Elasticsearch”以及描述“Relevant search with applications for Solr and Elasticsearch”共同强调了本书的核心内容:**相关搜索(Relevant Search)**在*...
2. **分布式的实时文档存储**:Elasticsearch可以存储、索引和搜索各种类型的数据,如文本、数值、日期和地理位置等。数据以JSON格式存储,便于与其他现代Web服务集成。 3. **自动分片和复制**:Elasticsearch将...
2. 安装:将`elasticsearch-analysis-ik-7.17.9.jar`复制到Elasticsearch的`plugins`目录下。 3. 配置:在Elasticsearch的配置文件`elasticsearch.yml`中添加以下行来启用插件: ``` plugins.load_class: "org....
This course aims to create a smooth learning path that will teach you how to effectively use Elasticsearch with other de facto components and get the most out of Elasticsearch. Through this ...
Elasticsearch is a Lucene-based search engine for distributed search and analytics. This book will be your hands-on guide as you explore and put to use the features of Elasticsearch 5.0. You will ...
Elasticsearch作为Elastic Stack的核心组件,支持日志、指标、追踪和搜索功能。对于Elastic Stack的任何生产部署,都需要以Elasticsearch的容量规划为指导。容量规划涉及估计运行Elasticsearch部署所需资源的类型和...
**Elasticsearch 1.7.0:分布式搜索引擎的精华解析** Elasticsearch,简称ES,是一款基于Lucene的开源、分布式全文搜索引擎。它以其高效、可扩展性、易用性和实时性在IT行业中广受好评。Elasticsearch 1.7.0是其...
「业务安全」Elastic Stack for Security Monitoring in a Nutshell - 基础架构安全 NGFW 数据安全 安全人才 基础架构安全 WEB应用防火墙
The Elastic Stack is a powerful combination of tools for distributed search, analytics, logging, and visualization of data from medium to massive data sets. The newly released Elastic Stack 6.0 brings...
ElasticHD 是一款专为 Elasticsearch 设计的可视化管理工具,主要面向Linux系统,适用于AMD64架构。这个软件提供了一种直观且用户友好的界面,帮助用户管理和监控Elasticsearch集群,包括索引管理、节点状态查看、...
ElasticSearch is a distributed search server similar to Apache Solr with a focus on large datasets, a schema-less setup, and high availability. This schema-free architecture allows ElasticSearch to ...
这个"elasticsearch-7.15.2-windows-x86_64位"压缩包是针对Windows 64位操作系统的一个版本,包含了在Windows平台上运行Elasticsearch 7.15.2所需的所有组件。 首先,让我们深入了解一下Elasticsearch的核心特性: ...
Elastic Waves in Solids I: Free and Guided Propagation (Advanced Texts in Physics), 2000, Daniel Royer (Author), Eugene Dieulesaint (Author), D.P. Morgan (Translator)
This guide will take you on a tour to become a competent developer quickly with a solid knowledge level and understanding of the ElasticSearch core concepts. Starting from the beginning, this book ...