PaintProfiler.js 1.9 KB

123456789101112
  1. export class PaintProfilerModel extends SDK.SDKModel{constructor(target){super(target);this._layerTreeAgent=target.layerTreeAgent();}
  2. async loadSnapshotFromFragments(fragments){const snapshotId=await this._layerTreeAgent.loadSnapshot(fragments);return snapshotId&&new PaintProfilerSnapshot(this,snapshotId);}
  3. loadSnapshot(encodedPicture){const fragment={x:0,y:0,picture:encodedPicture};return this.loadSnapshotFromFragments([fragment]);}
  4. async makeSnapshot(layerId){const snapshotId=await this._layerTreeAgent.makeSnapshot(layerId);return snapshotId&&new PaintProfilerSnapshot(this,snapshotId);}}
  5. export class PaintProfilerSnapshot{constructor(paintProfilerModel,snapshotId){this._paintProfilerModel=paintProfilerModel;this._id=snapshotId;this._refCount=1;}
  6. release(){console.assert(this._refCount>0,'release is already called on the object');if(!--this._refCount){this._paintProfilerModel._layerTreeAgent.releaseSnapshot(this._id);}}
  7. addReference(){++this._refCount;console.assert(this._refCount>0,'Referencing a dead object');}
  8. replay(scale,firstStep,lastStep){return this._paintProfilerModel._layerTreeAgent.replaySnapshot(this._id,firstStep,lastStep,scale||1.0);}
  9. profile(clipRect){return this._paintProfilerModel._layerTreeAgent.profileSnapshot(this._id,5,1,clipRect||undefined);}
  10. async commandLog(){const log=await this._paintProfilerModel._layerTreeAgent.snapshotCommandLog(this._id);return log&&log.map((entry,index)=>new PaintProfilerLogItem((entry),index));}}
  11. export class PaintProfilerLogItem{constructor(rawEntry,commandIndex){this.method=rawEntry.method;this.params=rawEntry.params;this.commandIndex=commandIndex;}}
  12. self.SDK=self.SDK||{};SDK=SDK||{};SDK.PaintProfilerModel=PaintProfilerModel;SDK.PaintProfilerSnapshot=PaintProfilerSnapshot;SDK.PaintProfilerLogItem=PaintProfilerLogItem;SDK.PictureFragment;SDK.RawPaintProfilerLogItem;SDK.SDKModel.register(PaintProfilerModel,SDK.Target.Capability.DOM,false);