UIWebView结构体系(二)UIWebTiledView和WAKWindow
来源:互联网 发布:python sys模块 编辑:程序博客网 时间:2024/05/21 22:56
UIWebTiledView是UIWebBrowserView->UIWebDocumentView->UIWebTiledView继承链中的老爷子,但这三个类的职能却是MVC的关系,UIWebBrowserView是Controller,UIWebDocumentView是Model,UIWebTiledView是View。(这也是我第一次见到这样的设计,很有意思)
它的声明为: (代码好长,点此跳过)
- @interface UIWebTiledView : UIView
- {
- WAKWindow *_wakWindow;
- int _inGestureType;
- int _tilingArea;
- BOOL _didFirstTileLayout;
- BOOL _layoutTilesInMainThread;
- BOOL _tilingModeIsLocked;
- BOOL _allowsPaintingAndScriptsWhilePanning;
- }
- - (id)wakWindow;
- - (void)setLayoutTilesInMainThread:(BOOL)arg1;
- - (BOOL)layoutTilesInMainThread;
- - (void)dumpTiles;
- - (void)removeForegroundTiles;
- - (void)removeAllTiles;
- - (void)removeAllNonVisibleTiles;
- - (BOOL)keepsZoomedOutTiles;
- - (void)setKeepsZoomedOutTiles:(BOOL)arg1;
- - (BOOL)tilesOpaque;
- - (void)setTilesOpaque:(BOOL)arg1;
- - (BOOL)tileDrawingEnabled;
- - (void)setTileDrawingEnabled:(BOOL)arg1;
- - (BOOL)logsTilingChanges;
- - (void)setLogsTilingChanges:(BOOL)arg1;
- - (BOOL)isTilingEnabled;
- - (void)setTilingEnabled:(BOOL)arg1;
- - (unsigned int)adjustedMaxTileCount;
- - (unsigned int)maxTileCount;
- - (void)setMaxTileCount:(unsigned int)arg1;
- - (BOOL)drawsGrid;
- - (void)setDrawsGrid:(BOOL)arg1;
- - (struct CGSize)tileSize;
- - (void)setTileSize:(struct CGSize)arg1;
- - (void)setTransform:(struct CGAffineTransform)arg1;
- - (void)setNeedsDisplay;
- - (void)setNeedsDisplayInRect:(struct CGRect)arg1;
- - (void)_didScroll;
- - (void)setNeedsLayout;
- - (void)setAllowsPaintingAndScriptsWhilePanning:(BOOL)arg1;
- - (BOOL)allowsPaintingAndScriptsWhilePanning;
- - (void)unlockTilingMode;
- - (void)lockTilingMode;
- - (int)tilingArea;
- - (void)setTilingArea:(int)arg1;
- - (void)setInGesture:(int)arg1;
- - (void)updateTilingMode;
- - (void)willMoveToWindow:(id)arg1;
- - (void)_screenChanged:(id)arg1;
- - (void)layoutSubviews;
- - (void)layoutTilesNowForRect:(struct CGRect)arg1;
- - (void)layoutTilesNowOnWebThread;
- - (void)layoutTilesNow;
- - (struct CGRect)visibleRect;
- - (void)setWAKWindow:(id)arg1;
- - (struct WKWindow *)wkWindow;
- - (void)dealloc;
- - (id)initWithFrame:(struct CGRect)arg1;
- - (void)_updateForScreen:(id)arg1;
- @end
可以看到好多名字带Tile这个词,也说明了此类专门负责绘制,而tile是分块渲染的意思,这是为了更好地利用GPU和显存。tile rendering大致意思是把屏幕分成几块区域,按照一定顺序来并行绘制这些区域,而不是一整块屏幕一起绘制,详细的信息可参考wiki:http://en.wikipedia.org/wiki/Tiled_rendering。iDevice都是用PowerVR的显卡,它正是分块渲染技术的先锋之一,也可见iOS的设计有针对硬件做优化,非常用心。
从函数和变量名看,UIWebTiledView有这些作用:
- 确定分块的排版是在主线程还是webThread
- 设置需要重排版、重绘,发起分块排版
- 确定分块模式
- 设置绘图区大小和transform等。
WAKWindow是UIWebTiledView的组合对象之一,其声明如下:(代码好长,点此跳过)
- @interface WAKWindow : WAKResponder
- {
- struct WKWindow *_wkWindow;
- CALayer *_hostLayer;
- struct TileCache *_tileCache;
- struct CGRect _cachedVisibleRect;
- CALayer *_rootLayer;
- struct CGSize _screenSize;
- struct CGSize _availableScreenSize;
- float _screenScale;
- struct CGRect _frame;
- BOOL _useOrientationDependentFontAntialiasing;
- }
- + (id)currentEvent;
- + (BOOL)hasLandscapeOrientation;
- + (void)setOrientationProvider:(id)arg1;
- + (id)_wrapperForWindowRef:(struct WKWindow *)arg1;
- @property(nonatomic) BOOL useOrientationDependentFontAntialiasing; // @synthesize useOrientationDependentFontAntialiasing=_useOrientationDependentFontAntialiasing;
- - (id).cxx_construct;
- - (id)recursiveDescription;
- - (id)description;
- - (void)dumpTiles;
- - (void)setAcceleratedDrawingEnabled:(BOOL)arg1;
- - (void)setTilePaintCountsVisible:(BOOL)arg1;
- - (void)setTileBordersVisible:(BOOL)arg1;
- - (id)hostLayer;
- - (void)didRotate;
- - (void)willRotate;
- - (void)displayRect:(struct CGRect)arg1;
- - (BOOL)hasPendingDraw;
- - (BOOL)keepsZoomedOutTiles;
- - (void)setKeepsZoomedOutTiles:(BOOL)arg1;
- - (float)currentTileScale;
- - (void)setCurrentTileScale:(float)arg1;
- - (float)zoomedOutTileScale;
- - (void)setZoomedOutTileScale:(float)arg1;
- - (int)tilingDirection;
- - (void)setTilingDirection:(int)arg1;
- - (int)tilingMode;
- - (void)setTilingMode:(int)arg1;
- - (void)removeForegroundTiles;
- - (void)removeAllTiles;
- - (void)removeAllNonVisibleTiles;
- - (struct CGRect)visibleRect;
- - (void)setTilesOpaque:(BOOL)arg1;
- - (BOOL)tilesOpaque;
- - (void)setNeedsDisplayInRect:(struct CGRect)arg1;
- - (void)setNeedsDisplay;
- - (void)layoutTilesNowForRect:(struct CGRect)arg1;
- - (void)layoutTilesNow;
- - (void)layoutTiles;
- - (void)sendMouseMoveEvent:(id)arg1 contentChange:(int *)arg2;
- - (void)sendEventSynchronously:(id)arg1;
- - (void)sendEvent:(id)arg1;
- - (struct WKWindow *)_windowRef;
- - (id)rootLayer;
- - (void)setRootLayer:(id)arg1;
- - (float)screenScale;
- - (void)setScreenScale:(float)arg1;
- - (struct CGSize)availableScreenSize;
- - (void)setAvailableScreenSize:(struct CGSize)arg1;
- - (struct CGSize)screenSize;
- - (void)setScreenSize:(struct CGSize)arg1;
- - (void)setContentRect:(struct CGRect)arg1;
- - (struct CGRect)frame;
- - (void)setFrame:(struct CGRect)arg1 display:(BOOL)arg2;
- - (BOOL)makeFirstResponder:(id)arg1;
- - (int)keyViewSelectionDirection;
- - (void)makeKeyWindow;
- - (BOOL)isKeyWindow;
- - (struct CGPoint)convertScreenToBase:(struct CGPoint)arg1;
- - (struct CGPoint)convertBaseToScreen:(struct CGPoint)arg1;
- - (id)_newFirstResponderAfterResigning;
- - (BOOL)makeViewFirstResponder:(id)arg1;
- - (id)firstResponder;
- - (void)close;
- - (id)contentView;
- - (void)setContentView:(id)arg1;
- - (void)dealloc;
- - (id)initWithFrame:(struct CGRect)arg1;
- - (id)initWithLayer:(id)arg1;
- @end
根据之前《WebCore::Widget浅探》的研究,WAKWindow是模仿NSWindow的,不过也有iOS的特性。它的成员变量TileCache是对分块做缓存,可重复利用。每块Tile都会对应一个CALayer对象,所以也有成员变量叫rootLayer。 hostLayer则是放置用作硬件加速的layer的(这个不深入讲了)。
总结之:UIWebTiledView和WAKWindow共同负责页面的绘制,包括分块、排版、提供CALayer的context(绘图上下文)、缓存Layer、交互(缩放、滚动等)。WAKWindow还兼做分派用户操作信息的工作(sendEvent)。
- UIWebView结构体系(二)UIWebTiledView和WAKWindow
- UIWebView结构体系(二)UIWebTiledView和WAKWindow
- UIWebView结构体系(二)UIWebTiledView和WAKWindow
- UIWebView结构体系(二)UIWebTiledView和WAKWindow
- 新一代应用结构体系(二)面向服务架构
- 软件结构体系和风格
- 017_计算机结构体系二
- DBA_Oracle基本体系内存和进程结构(概念)
- oracle和mysql结构体系的区别
- tomcat体系架构和目录结构
- PostgreSQL 逻辑结构 和 权限体系 介绍
- J2EE安全体系(二)
- Oracle物理体系(二)
- View事件体系(二)
- Oracle体系结构:内存结构和进程结构-体系架构
- Oracle体系结构:内存结构和进程结构-体系架构
- Oracle体系结构:内存结构和进程结构-体系架构
- UIWebView页面的控制(二)
- xcode反汇编调试iOS模拟器程序(八)反汇编自己的代码来掌握规则
- ubuntu13.10 归档管理器解压zip文件中文乱码问题的解决(亲测成功)
- Mac10.9和iOS7新公开的框架JavaScriptCore.framework
- SOAP Webservice和RESTful Webservice
- UIWebView体系结构(一)概貌
- UIWebView结构体系(二)UIWebTiledView和WAKWindow
- ubuntu下安装配置 JDK7
- UIWebView体系结构(三)UIWebDocumentView和WebView
- UIWebView体系结构(四)UIWebBrowserView
- UIWebView体系结构(五)_UIWebViewScrollView和UIWebScrollView
- UIWebView体系结构(六)UIWebView
- Makefile
- UIWebView体系结构(七)WebView
- UIWebView体系结构(八)各个Client综述