libraries/EaselJS_docs/classes/BitmapCache.html (view raw)
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <link rel="stylesheet" href="../assets/css/yui-cssgrids-min.css">
6 <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
7 <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
8 <link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">
9 <script src="../assets/js/yui-source.js"></script>
10 <title>EaselJS v1.0.0 API Documentation : BitmapCache</title>
11</head>
12<body class="yui3-skin-sam">
13
14<div id="doc">
15 <div id="hd" class="yui3-g header">
16 <div class="yui3-u-3-4">
17
18 <h1><a href="http://www.createjs.com/easeljs"><img src="../assets/docs-icon-EaselJS.png" title="EaselJS"></a></h1>
19
20 </div>
21 <div class="version">
22 <em>API Documentation for: 1.0.0</em>
23 </div>
24 </div>
25 <div id="bd" class="yui3-g">
26
27 <div class="yui3-u-1-4">
28 <div id="docs-sidebar" class="sidebar apidocs">
29 <div id="api-list">
30 <h2 class="off-left">APIs</h2>
31 <div id="api-tabview" class="tabview">
32 <ul class="tabs">
33 <li><a href="#api-classes">Classes</a></li>
34 </ul>
35
36 <div id="api-tabview-filter">
37 <input type="search" id="api-filter" placeholder="Type to filter APIs">
38 </div>
39
40 <div id="api-tabview-panel">
41 <ul id="api-classes" class="apis classes">
42
43 <li><a href="../classes/AlphaMapFilter.html">AlphaMapFilter</a></li>
44
45 <li><a href="../classes/AlphaMaskFilter.html">AlphaMaskFilter</a></li>
46
47 <li><a href="../classes/Bitmap.html">Bitmap</a></li>
48
49 <li><a href="../classes/BitmapCache.html">BitmapCache</a></li>
50
51 <li><a href="../classes/BitmapText.html">BitmapText</a></li>
52
53 <li><a href="../classes/BlurFilter.html">BlurFilter</a></li>
54
55 <li><a href="../classes/ButtonHelper.html">ButtonHelper</a></li>
56
57 <li><a href="../classes/ColorFilter.html">ColorFilter</a></li>
58
59 <li><a href="../classes/ColorMatrix.html">ColorMatrix</a></li>
60
61 <li><a href="../classes/ColorMatrixFilter.html">ColorMatrixFilter</a></li>
62
63 <li><a href="../classes/Container.html">Container</a></li>
64
65 <li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
66
67 <li><a href="../classes/DisplayProps.html">DisplayProps</a></li>
68
69 <li><a href="../classes/DOMElement.html">DOMElement</a></li>
70
71 <li><a href="../classes/EaselJS.html">EaselJS</a></li>
72
73 <li><a href="../classes/Event.html">Event</a></li>
74
75 <li><a href="../classes/EventDispatcher.html">EventDispatcher</a></li>
76
77 <li><a href="../classes/Filter.html">Filter</a></li>
78
79 <li><a href="../classes/Graphics.html">Graphics</a></li>
80
81 <li><a href="../classes/Graphics.Arc.html">Graphics.Arc</a></li>
82
83 <li><a href="../classes/Graphics.ArcTo.html">Graphics.ArcTo</a></li>
84
85 <li><a href="../classes/Graphics.BeginPath.html">Graphics.BeginPath</a></li>
86
87 <li><a href="../classes/Graphics.BezierCurveTo.html">Graphics.BezierCurveTo</a></li>
88
89 <li><a href="../classes/Graphics.Circle.html">Graphics.Circle</a></li>
90
91 <li><a href="../classes/Graphics.ClosePath.html">Graphics.ClosePath</a></li>
92
93 <li><a href="../classes/Graphics.Ellipse.html">Graphics.Ellipse</a></li>
94
95 <li><a href="../classes/Graphics.Fill.html">Graphics.Fill</a></li>
96
97 <li><a href="../classes/Graphics.LineTo.html">Graphics.LineTo</a></li>
98
99 <li><a href="../classes/Graphics.MoveTo.html">Graphics.MoveTo</a></li>
100
101 <li><a href="../classes/Graphics.PolyStar.html">Graphics.PolyStar</a></li>
102
103 <li><a href="../classes/Graphics.QuadraticCurveTo.html">Graphics.QuadraticCurveTo</a></li>
104
105 <li><a href="../classes/Graphics.Rect.html">Graphics.Rect</a></li>
106
107 <li><a href="../classes/Graphics.RoundRect.html">Graphics.RoundRect</a></li>
108
109 <li><a href="../classes/Graphics.Stroke.html">Graphics.Stroke</a></li>
110
111 <li><a href="../classes/Graphics.StrokeDash.html">Graphics.StrokeDash</a></li>
112
113 <li><a href="../classes/Graphics.StrokeStyle.html">Graphics.StrokeStyle</a></li>
114
115 <li><a href="../classes/Matrix2D.html">Matrix2D</a></li>
116
117 <li><a href="../classes/MouseEvent.html">MouseEvent</a></li>
118
119 <li><a href="../classes/MovieClip.html">MovieClip</a></li>
120
121 <li><a href="../classes/MovieClipPlugin.html">MovieClipPlugin</a></li>
122
123 <li><a href="../classes/Point.html">Point</a></li>
124
125 <li><a href="../classes/Rectangle.html">Rectangle</a></li>
126
127 <li><a href="../classes/Shadow.html">Shadow</a></li>
128
129 <li><a href="../classes/Shape.html">Shape</a></li>
130
131 <li><a href="../classes/Sprite.html">Sprite</a></li>
132
133 <li><a href="../classes/SpriteSheet.html">SpriteSheet</a></li>
134
135 <li><a href="../classes/SpriteSheetBuilder.html">SpriteSheetBuilder</a></li>
136
137 <li><a href="../classes/SpriteSheetUtils.html">SpriteSheetUtils</a></li>
138
139 <li><a href="../classes/Stage.html">Stage</a></li>
140
141 <li><a href="../classes/StageGL.html">StageGL</a></li>
142
143 <li><a href="../classes/Text.html">Text</a></li>
144
145 <li><a href="../classes/Ticker.html">Ticker</a></li>
146
147 <li><a href="../classes/Touch.html">Touch</a></li>
148
149 <li><a href="../classes/UID.html">UID</a></li>
150
151 <li><a href="../classes/Utility Methods.html">Utility Methods</a></li>
152
153 <li><a href="../classes/VideoBuffer.html">VideoBuffer</a></li>
154
155 <li><a href="../classes/WebGLInspector.html">WebGLInspector</a></li>
156
157 </ul>
158
159 <ul id="api-modules" class="apis modules">
160
161 <li><a href="../modules/CreateJS.html">CreateJS</a></li>
162
163 <li><a href="../modules/EaselJS.html">EaselJS</a></li>
164
165 </ul>
166 </div>
167 </div>
168</div>
169
170 </div>
171 </div>
172 <div class="yui3-u-3-4">
173 <div id="api-options">
174 Show:
175 <label for="api-show-inherited">
176 <input type="checkbox" id="api-show-inherited" checked>
177 Inherited
178 </label>
179
180 <label for="api-show-protected">
181 <input type="checkbox" id="api-show-protected">
182 Protected
183 </label>
184
185 <label for="api-show-private">
186 <input type="checkbox" id="api-show-private">
187 Private
188 </label>
189 <label for="api-show-deprecated">
190 <input type="checkbox" id="api-show-deprecated">
191 Deprecated
192 </label>
193
194 </div>
195 <div class="apidocs">
196 <div id="docs-main">
197 <div class="content">
198 <h1>BitmapCache Class</h1>
199<div class="box meta">
200
201
202
203
204
205 <div class="foundat">
206 Defined in: <a href="../files/easeljs_filters_BitmapCache.js.html#l41"><code>BitmapCache:41</code></a>
207 </div>
208
209
210
211
212 Module: <a href="../modules/EaselJS.html">EaselJS</a>
213
214
215
216
217</div>
218
219
220
221<div class="box intro">
222 <p>The BitmapCache is an internal representation of all the cache properties and logic required in order to "cache"
223an object. This information and functionality used to be located on a <a href="../classes/DisplayObject.html#method_cache" class="crosslink">cache</a>
224method in <a href="../classes/DisplayObject.html" class="crosslink">DisplayObject</a>, but was moved to its own class.</p>
225<p>Caching in this context is purely visual, and will render the DisplayObject out into an image to be used instead
226of the object. The actual cache itself is still stored on the target with the <a href="../classes/DisplayObject.html#property_cacheCanvas" class="crosslink">cacheCanvas</a>.
227Working with a singular image like a <a href="../classes/Bitmap.html" class="crosslink">Bitmap</a> there is little benefit to performing
228a cache as it is already a single image. Caching is best done on containers containing multiple complex parts that
229do not move often, so that rendering the image instead will improve overall rendering speed. A cached object will
230not visually update until explicitly told to do so with a call to update, much like a Stage. If a cache is being
231updated every frame it is likely not improving rendering performance. Cache are best used when updates will be sparse.</p>
232<p>Caching is also a co-requisite for applying filters to prevent expensive filters running constantly without need,
233and to physically enable some effects. The BitmapCache is also responsible for applying filters to objects and
234reads each <a href="../classes/Filter.html" class="crosslink">Filter</a> due to this relationship. Real-time Filters are not recommended
235performance wise when dealing with a Context2D canvas. For best performance and to still allow for some visual
236effects use a compositeOperation when possible.</p>
237
238</div>
239
240
241 <div class="constructor">
242 <h2>Constructor</h2>
243 <div id="method_BitmapCache" class="method item">
244 <h3 class="name"><code>BitmapCache</code></h3>
245
246
247 <span class="paren">()</span>
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264 <div class="meta">
265
266
267
268 <p>
269
270 Defined in
271
272
273
274
275 <a href="../files/easeljs_filters_BitmapCache.js.html#l41"><code>BitmapCache:41</code></a>
276
277 </p>
278
279
280
281
282
283 </div>
284
285 <div class="description">
286
287 </div>
288
289
290
291
292
293
294</div>
295
296 </div>
297
298
299<div id="classdocs" class="tabview">
300 <ul class="api-class-tabs">
301 <li class="api-class-tab index"><a href="#index">Index</a></li>
302
303
304 <li class="api-class-tab methods"><a href="#methods">Methods</a></li>
305
306
307 <li class="api-class-tab properties"><a href="#properties">Properties</a></li>
308
309
310
311 </ul>
312
313 <div>
314 <div id="index" class="api-class-tabpanel index">
315 <h2 class="off-left">Item Index</h2>
316
317
318 <div class="index-section methods">
319 <h3>Methods</h3>
320
321 <ul class="index-list methods">
322
323 <li class="index-item method protected">
324 <a href="#method__applyFilters">_applyFilters</a>
325
326
327
328 </li>
329
330 <li class="index-item method protected">
331 <a href="#method__drawToCache">_drawToCache</a>
332
333
334
335 </li>
336
337 <li class="index-item method protected">
338 <a href="#method__updateSurface">_updateSurface</a>
339
340
341
342 </li>
343
344 <li class="index-item method public">
345 <a href="#method_BitmapCache.cache">BitmapCache.cache</a>
346
347
348
349 </li>
350
351 <li class="index-item method">
352 <a href="#method_draw">draw</a>
353
354
355
356 </li>
357
358 <li class="index-item method">
359 <a href="#method_getCacheDataURL">getCacheDataURL</a>
360
361
362
363 </li>
364
365 <li class="index-item method">
366 <a href="#method_getFilterBounds">getFilterBounds</a>
367
368
369 <span class="flag static">static</span>
370
371
372 </li>
373
374 <li class="index-item method">
375 <a href="#method_release">release</a>
376
377
378
379 </li>
380
381 <li class="index-item method">
382 <a href="#method_toString">toString</a>
383
384
385
386 </li>
387
388 <li class="index-item method">
389 <a href="#method_update">update</a>
390
391
392
393 </li>
394
395 </ul>
396 </div>
397
398
399
400 <div class="index-section properties">
401 <h3>Properties</h3>
402
403 <ul class="index-list properties">
404
405 <li class="index-item property protected">
406 <a href="#property__cacheDataURL">_cacheDataURL</a>
407
408
409
410 </li>
411
412 <li class="index-item property protected">
413 <a href="#property__cacheDataURLID">_cacheDataURLID</a>
414
415
416
417 </li>
418
419 <li class="index-item property protected">
420 <a href="#property__drawHeight">_drawHeight</a>
421
422
423
424 </li>
425
426 <li class="index-item property protected">
427 <a href="#property__drawWidth">_drawWidth</a>
428
429
430
431 </li>
432
433 <li class="index-item property protected">
434 <a href="#property__filterOffY">_filterOffY</a>
435
436
437
438 </li>
439
440 <li class="index-item property protected">
441 <a href="#property__filterOffY">_filterOffY</a>
442
443
444
445 </li>
446
447 <li class="index-item property">
448 <a href="#property_cacheID">cacheID</a>
449
450
451
452 </li>
453
454 <li class="index-item property protected">
455 <a href="#property_height">height</a>
456
457
458
459 </li>
460
461 <li class="index-item property protected">
462 <a href="#property_offX">offX</a>
463
464
465
466 </li>
467
468 <li class="index-item property protected">
469 <a href="#property_offY">offY</a>
470
471
472
473 </li>
474
475 <li class="index-item property protected">
476 <a href="#property_scale">scale</a>
477
478
479
480 </li>
481
482 <li class="index-item property protected">
483 <a href="#property_width">width</a>
484
485
486
487 </li>
488
489 <li class="index-item property protected">
490 <a href="#property_x">x</a>
491
492
493
494 </li>
495
496 <li class="index-item property protected">
497 <a href="#property_y">y</a>
498
499
500
501 </li>
502
503 </ul>
504 </div>
505
506
507
508
509
510 </div>
511
512
513 <div id="methods" class="api-class-tabpanel">
514 <h2 class="off-left">Methods</h2>
515
516
517 <div id="method__applyFilters" class="method item protected">
518 <h3 class="name"><code>_applyFilters</code></h3>
519
520
521 <span class="paren">()</span>
522
523
524
525
526
527
528
529 <span class="flag protected">protected</span>
530
531
532
533
534
535
536
537
538
539
540 <div class="meta">
541
542
543
544 <p>
545
546 Defined in
547
548
549
550
551 <a href="../files/easeljs_filters_BitmapCache.js.html#l516"><code>_applyFilters:516</code></a>
552
553 </p>
554
555
556
557
558
559 </div>
560
561 <div class="description">
562 <p>Work through every filter and apply its individual visual transformation.</p>
563
564 </div>
565
566
567
568
569
570
571</div>
572
573
574 <div id="method__drawToCache" class="method item protected">
575 <h3 class="name"><code>_drawToCache</code></h3>
576
577
578 <span class="paren">()</span>
579
580
581
582
583
584
585
586 <span class="flag protected">protected</span>
587
588
589
590
591
592
593
594
595
596
597 <div class="meta">
598
599
600
601 <p>
602
603 Defined in
604
605
606
607
608 <a href="../files/easeljs_filters_BitmapCache.js.html#l475"><code>_drawToCache:475</code></a>
609
610 </p>
611
612
613
614
615
616 </div>
617
618 <div class="description">
619 <p>Perform the cache draw out for context 2D now that the setup properties have been performed.</p>
620
621 </div>
622
623
624
625
626
627
628</div>
629
630
631 <div id="method__updateSurface" class="method item protected">
632 <h3 class="name"><code>_updateSurface</code></h3>
633
634
635 <span class="paren">()</span>
636
637
638
639
640
641
642
643 <span class="flag protected">protected</span>
644
645
646
647
648
649
650
651
652
653
654 <div class="meta">
655
656
657
658 <p>
659
660 Defined in
661
662
663
664
665 <a href="../files/easeljs_filters_BitmapCache.js.html#l405"><code>_updateSurface:405</code></a>
666
667 </p>
668
669
670
671
672
673 </div>
674
675 <div class="description">
676 <p>Create or resize the invisible canvas/surface that is needed for the display object(s) to draw to,
677and in turn be used in their stead when drawing. The surface is resized to the size defined
678by the width and height, factoring in scaling and filters. Adjust them to adjust the output size.</p>
679
680 </div>
681
682
683
684
685
686
687</div>
688
689
690 <div id="method_BitmapCache.cache" class="method item public">
691 <h3 class="name"><code>BitmapCache.cache</code></h3>
692
693
694 <div class="args">
695 <span class="paren">(</span><ul class="args-list inline commas">
696
697 <li class="arg">
698
699 <code>x</code>
700
701 </li>
702
703 <li class="arg">
704
705 <code>y</code>
706
707 </li>
708
709 <li class="arg">
710
711 <code>width</code>
712
713 </li>
714
715 <li class="arg">
716
717 <code>height</code>
718
719 </li>
720
721 <li class="arg">
722
723 <code class="optional">[scale=1]</code>
724
725 </li>
726
727 <li class="arg">
728
729 <code class="optional">[options=undefined]</code>
730
731 </li>
732
733 </ul><span class="paren">)</span>
734 </div>
735
736
737
738
739
740
741
742 <span class="flag public">public</span>
743
744
745
746
747
748
749
750
751
752
753 <div class="meta">
754
755
756
757 <p>
758
759 Defined in
760
761
762
763
764 <a href="../files/easeljs_filters_BitmapCache.js.html#l238"><code>BitmapCache.cache:238</code></a>
765
766 </p>
767
768
769
770
771
772 </div>
773
774 <div class="description">
775 <p>Actually create the correct cache surface and properties associated with it. Caching and it's benefits are discussed
776by the <a href="../classes/DisplayObject.html#method_cache" class="crosslink">cache</a> function and this class description. Here are the detailed
777specifics of how to use the options object.</p>
778<ul>
779<li>If options.useGL is set to "new" a StageGL is created and contained on this for use when rendering the cache.</li>
780<li>If options.useGL is set to "stage" if the current stage is a StageGL it will be used. If not then it will default to "new".</li>
781<li>If options.useGL is a StageGL instance it will not create one but use the one provided.</li>
782<li>If options.useGL is undefined a Context 2D cache will be performed.</li>
783</ul>
784<p>This means you can use any combination of StageGL and 2D with either, neither, or both the stage and cache being
785WebGL. Using "new" with a StageGL display list is highly unrecommended, but still an option. It should be avoided
786due to negative performance reasons and the Image loading limitation noted in the class complications above.</p>
787<p>When "options.useGL" is set to the parent stage of the target and WebGL, performance is increased by using
788"RenderTextures" instead of canvas elements. These are internal Textures on the graphics card stored in the GPU.
789Because they are no longer canvases you cannot perform operations you could with a regular canvas. The benefit
790is that this avoids the slowdown of copying the texture back and forth from the GPU to a Canvas element.
791This means "stage" is the recommended option when available.</p>
792<p>A StageGL cache does not infer the ability to draw objects a StageGL cannot currently draw, i.e. do not use a
793WebGL context cache when caching a Shape, Text, etc.</p>
794<h4>WebGL cache with a 2D context</h4>
795
796<pre class="code prettyprint"><code>var stage = new createjs.Stage();
797var bmp = new createjs.Bitmap(src);
798bmp.cache(0, 0, bmp.width, bmp.height, 1, {gl: "new"}); // no StageGL to use, so make one
799
800var shape = new createjs.Shape();
801shape.graphics.clear().fill("red").drawRect(0,0,20,20);
802shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache</code></pre>
803<h4>WebGL cache with a WebGL context</h4>
804
805<pre class="code prettyprint"><code>var stageGL = new createjs.StageGL();
806var bmp = new createjs.Bitmap(src);
807bmp.cache(0, 0, bmp.width, bmp.height, 1, {gl: "stage"}); // use our StageGL to cache
808
809var shape = new createjs.Shape();
810shape.graphics.clear().fill("red").drawRect(0,0,20,20);
811shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache</code></pre>
812<p>You may wish to create your own StageGL instance to control factors like clear color, transparency, AA, and
813others. If you do, pass a new instance in instead of "true", the library will automatically set the
814StageGL/isCacheControlled to true on your instance. This will trigger it to behave
815correctly, and not assume your main context is WebGL.</p>
816
817 </div>
818
819
820 <div class="params">
821 <h4>Parameters:</h4>
822
823 <ul class="params-list">
824
825 <li class="param">
826
827 <code class="param-name">x</code>
828 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
829
830
831
832
833 <div class="param-description">
834 <p>The x coordinate origin for the cache region.</p>
835
836 </div>
837
838
839 </li>
840
841 <li class="param">
842
843 <code class="param-name">y</code>
844 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
845
846
847
848
849 <div class="param-description">
850 <p>The y coordinate origin for the cache region.</p>
851
852 </div>
853
854
855 </li>
856
857 <li class="param">
858
859 <code class="param-name">width</code>
860 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
861
862
863
864
865 <div class="param-description">
866 <p>The width of the cache region.</p>
867
868 </div>
869
870
871 </li>
872
873 <li class="param">
874
875 <code class="param-name">height</code>
876 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
877
878
879
880
881 <div class="param-description">
882 <p>The height of the cache region.</p>
883
884 </div>
885
886
887 </li>
888
889 <li class="param">
890
891 <code class="param-name optional">[scale=1]</code>
892 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
893 <span class="flag optional" title="This parameter is optional.">optional</span>
894
895
896
897
898 <div class="param-description">
899 <p>The scale at which the cache will be created. For example, if you cache a vector shape
900using myShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and
901rotate cached elements with greater fidelity. Default is 1.</p>
902
903 </div>
904
905
906 </li>
907
908 <li class="param">
909
910 <code class="param-name optional">[options=undefined]</code>
911 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>
912 <span class="flag optional" title="This parameter is optional.">optional</span>
913
914
915
916
917 <div class="param-description">
918 <p>Specify additional parameters for the cache logic</p>
919
920 </div>
921
922
923 <ul class="params-list">
924
925 <li class="param">
926
927 <code class="param-name optional">[useGL=undefined]</code>
928 <span class="type">Undefined | "new" | "stage" | <a href="../classes/StageGL.html" class="crosslink">StageGL</a></span>
929 <span class="flag optional" title="This parameter is optional.">optional</span>
930
931
932 <div class="param-description">
933 <p>Select whether to use context 2D, or WebGL rendering, and
934whether to make a new stage instance or use an existing one. See above for extensive details on use.</p>
935
936 </div>
937
938
939 </li>
940
941 </ul>
942
943 </li>
944
945 </ul>
946 </div>
947
948
949
950
951
952</div>
953
954
955 <div id="method_draw" class="method item">
956 <h3 class="name"><code>draw</code></h3>
957
958
959 <div class="args">
960 <span class="paren">(</span><ul class="args-list inline commas">
961
962 <li class="arg">
963
964 <code>ctx</code>
965
966 </li>
967
968 </ul><span class="paren">)</span>
969 </div>
970
971
972
973 <span class="returns-inline">
974 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
975 </span>
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990 <div class="meta">
991
992
993
994 <p>
995
996 Defined in
997
998
999
1000
1001 <a href="../files/easeljs_filters_BitmapCache.js.html#l389"><code>draw:389</code></a>
1002
1003 </p>
1004
1005
1006
1007
1008
1009 </div>
1010
1011 <div class="description">
1012 <p>Use context2D drawing commands to display the cache canvas being used.</p>
1013
1014 </div>
1015
1016
1017 <div class="params">
1018 <h4>Parameters:</h4>
1019
1020 <ul class="params-list">
1021
1022 <li class="param">
1023
1024 <code class="param-name">ctx</code>
1025 <span class="type">CanvasRenderingContext2D</span>
1026
1027
1028
1029
1030 <div class="param-description">
1031 <p>The context to draw into.</p>
1032
1033 </div>
1034
1035
1036 </li>
1037
1038 </ul>
1039 </div>
1040
1041
1042
1043 <div class="returns">
1044 <h4>Returns:</h4>
1045
1046 <div class="returns-description">
1047
1048
1049 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>:
1050
1051 <p>Whether the draw was handled successfully.</p>
1052
1053
1054 </div>
1055 </div>
1056
1057
1058
1059</div>
1060
1061
1062 <div id="method_getCacheDataURL" class="method item">
1063 <h3 class="name"><code>getCacheDataURL</code></h3>
1064
1065
1066 <span class="paren">()</span>
1067
1068
1069
1070 <span class="returns-inline">
1071 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
1072 </span>
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087 <div class="meta">
1088
1089
1090
1091 <p>
1092
1093 Defined in
1094
1095
1096
1097
1098 <a href="../files/easeljs_filters_BitmapCache.js.html#l372"><code>getCacheDataURL:372</code></a>
1099
1100 </p>
1101
1102
1103
1104
1105
1106 </div>
1107
1108 <div class="description">
1109 <p>Returns a data URL for the cache, or <code>null</code> if this display object is not cached.
1110Uses <a href="../classes/BitmapCache.html#property_cacheID" class="crosslink">cacheID</a> to ensure a new data URL is not generated if the
1111cache has not changed.</p>
1112
1113 </div>
1114
1115
1116
1117
1118 <div class="returns">
1119 <h4>Returns:</h4>
1120
1121 <div class="returns-description">
1122
1123
1124 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>:
1125
1126 <p>The image data url for the cache.</p>
1127
1128
1129 </div>
1130 </div>
1131
1132
1133
1134</div>
1135
1136
1137 <div id="method_getFilterBounds" class="method item">
1138 <h3 class="name"><code>getFilterBounds</code></h3>
1139
1140
1141 <div class="args">
1142 <span class="paren">(</span><ul class="args-list inline commas">
1143
1144 <li class="arg">
1145
1146 <code>target</code>
1147
1148 </li>
1149
1150 <li class="arg">
1151
1152 <code class="optional">[output=null]</code>
1153
1154 </li>
1155
1156 </ul><span class="paren">)</span>
1157 </div>
1158
1159
1160
1161 <span class="returns-inline">
1162 <span class="type"><a href="../classes/Rectangle.html" class="crosslink">Rectangle</a></span>
1163 </span>
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173 <span class="flag static">static</span>
1174
1175
1176
1177
1178
1179
1180 <div class="meta">
1181
1182
1183
1184 <p>
1185
1186 Defined in
1187
1188
1189
1190
1191 <a href="../files/easeljs_filters_BitmapCache.js.html#l199"><code>getFilterBounds:199</code></a>
1192
1193 </p>
1194
1195
1196
1197
1198
1199 </div>
1200
1201 <div class="description">
1202 <p>Returns the bounds that surround all applied filters, relies on each filter to describe how it changes bounds.</p>
1203
1204 </div>
1205
1206
1207 <div class="params">
1208 <h4>Parameters:</h4>
1209
1210 <ul class="params-list">
1211
1212 <li class="param">
1213
1214 <code class="param-name">target</code>
1215 <span class="type"><a href="../classes/DisplayObject.html" class="crosslink">DisplayObject</a></span>
1216
1217
1218
1219
1220 <div class="param-description">
1221 <p>The object to check the filter bounds for.</p>
1222
1223 </div>
1224
1225
1226 </li>
1227
1228 <li class="param">
1229
1230 <code class="param-name optional">[output=null]</code>
1231 <span class="type"><a href="../classes/Rectangle.html" class="crosslink">Rectangle</a></span>
1232 <span class="flag optional" title="This parameter is optional.">optional</span>
1233
1234
1235
1236
1237 <div class="param-description">
1238 <p>Optional parameter, if provided then calculated bounds will be applied to that object.</p>
1239
1240 </div>
1241
1242
1243 </li>
1244
1245 </ul>
1246 </div>
1247
1248
1249
1250 <div class="returns">
1251 <h4>Returns:</h4>
1252
1253 <div class="returns-description">
1254
1255
1256 <span class="type"><a href="../classes/Rectangle.html" class="crosslink">Rectangle</a></span>:
1257
1258 <p>bounds object representing the bounds with filters.</p>
1259
1260
1261 </div>
1262 </div>
1263
1264
1265
1266</div>
1267
1268
1269 <div id="method_release" class="method item">
1270 <h3 class="name"><code>release</code></h3>
1271
1272
1273 <span class="paren">()</span>
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290 <div class="meta">
1291
1292
1293
1294 <p>
1295
1296 Defined in
1297
1298
1299
1300
1301 <a href="../files/easeljs_filters_BitmapCache.js.html#l344"><code>release:344</code></a>
1302
1303 </p>
1304
1305
1306
1307
1308
1309 </div>
1310
1311 <div class="description">
1312 <p>Reset and release all the properties and memory associated with this cache.</p>
1313
1314 </div>
1315
1316
1317
1318
1319
1320
1321</div>
1322
1323
1324 <div id="method_toString" class="method item">
1325 <h3 class="name"><code>toString</code></h3>
1326
1327
1328 <span class="paren">()</span>
1329
1330
1331
1332 <span class="returns-inline">
1333 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
1334 </span>
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349 <div class="meta">
1350
1351
1352
1353 <p>
1354
1355 Defined in
1356
1357
1358
1359
1360 <a href="../files/easeljs_filters_BitmapCache.js.html#l229"><code>toString:229</code></a>
1361
1362 </p>
1363
1364
1365
1366
1367
1368 </div>
1369
1370 <div class="description">
1371 <p>Returns a string representation of this object.</p>
1372
1373 </div>
1374
1375
1376
1377
1378 <div class="returns">
1379 <h4>Returns:</h4>
1380
1381 <div class="returns-description">
1382
1383
1384 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>:
1385
1386 <p>a string representation of the instance.</p>
1387
1388
1389 </div>
1390 </div>
1391
1392
1393
1394</div>
1395
1396
1397 <div id="method_update" class="method item">
1398 <h3 class="name"><code>update</code></h3>
1399
1400
1401 <div class="args">
1402 <span class="paren">(</span><ul class="args-list inline commas">
1403
1404 <li class="arg">
1405
1406 <code class="optional">[compositeOperation=null]</code>
1407
1408 </li>
1409
1410 </ul><span class="paren">)</span>
1411 </div>
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428 <div class="meta">
1429
1430
1431
1432 <p>
1433
1434 Defined in
1435
1436
1437
1438
1439 <a href="../files/easeljs_filters_BitmapCache.js.html#l313"><code>update:313</code></a>
1440
1441 </p>
1442
1443
1444
1445
1446
1447 </div>
1448
1449 <div class="description">
1450 <p>Directly called via <a href="../classes/DisplayObject.html#method_updateCache" class="crosslink">updateCache</a>, but also internally. This
1451has the dual responsibility of making sure the surface is ready to be drawn to, and performing the draw. For
1452full details of each behaviour, check the protected functions <a href="../classes/BitmapCache.html#method__updateSurface" class="crosslink">_updateSurface</a>
1453and <a href="../classes/BitmapCache.html#method__drawToCache" class="crosslink">_drawToCache</a> respectively.</p>
1454
1455 </div>
1456
1457
1458 <div class="params">
1459 <h4>Parameters:</h4>
1460
1461 <ul class="params-list">
1462
1463 <li class="param">
1464
1465 <code class="param-name optional">[compositeOperation=null]</code>
1466 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
1467 <span class="flag optional" title="This parameter is optional.">optional</span>
1468
1469
1470
1471
1472 <div class="param-description">
1473 <p>The DisplayObject this cache is linked to.</p>
1474
1475 </div>
1476
1477
1478 </li>
1479
1480 </ul>
1481 </div>
1482
1483
1484
1485
1486
1487</div>
1488
1489
1490 </div>
1491
1492
1493
1494 <div id="properties" class="api-class-tabpanel">
1495 <h2 class="off-left">Properties</h2>
1496
1497
1498 <div id="property__cacheDataURL" class="property item protected">
1499 <h3 class="name"><code>_cacheDataURL</code></h3>
1500 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
1501
1502
1503
1504
1505 <span class="flag protected">protected</span>
1506
1507
1508
1509
1510
1511
1512
1513
1514 <div class="meta">
1515
1516
1517
1518 <p>
1519
1520 Defined in
1521
1522
1523
1524
1525 <a href="../files/easeljs_filters_BitmapCache.js.html#l170"><code>_cacheDataURL:170</code></a>
1526
1527 </p>
1528
1529
1530
1531
1532 </div>
1533
1534 <div class="description">
1535 <p>The cache's DataURL, generated on-demand using the getter.</p>
1536
1537 </div>
1538
1539
1540 <p><strong>Default:</strong> null</p>
1541
1542
1543
1544
1545
1546</div>
1547
1548
1549 <div id="property__cacheDataURLID" class="property item protected">
1550 <h3 class="name"><code>_cacheDataURLID</code></h3>
1551 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1552
1553
1554
1555
1556 <span class="flag protected">protected</span>
1557
1558
1559
1560
1561
1562
1563
1564
1565 <div class="meta">
1566
1567
1568
1569 <p>
1570
1571 Defined in
1572
1573
1574
1575
1576 <a href="../files/easeljs_filters_BitmapCache.js.html#l161"><code>_cacheDataURLID:161</code></a>
1577
1578 </p>
1579
1580
1581
1582
1583 </div>
1584
1585 <div class="description">
1586 <p>The cacheID when a DataURL was requested.</p>
1587
1588 </div>
1589
1590
1591 <p><strong>Default:</strong> 0</p>
1592
1593
1594
1595
1596
1597</div>
1598
1599
1600 <div id="property__drawHeight" class="property item protected">
1601 <h3 class="name"><code>_drawHeight</code></h3>
1602 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1603
1604
1605
1606
1607 <span class="flag protected">protected</span>
1608
1609
1610
1611
1612
1613
1614
1615
1616 <div class="meta">
1617
1618
1619
1620 <p>
1621
1622 Defined in
1623
1624
1625
1626
1627 <a href="../files/easeljs_filters_BitmapCache.js.html#l188"><code>_drawHeight:188</code></a>
1628
1629 </p>
1630
1631
1632
1633
1634 </div>
1635
1636 <div class="description">
1637 <p>Internal tracking of final bounding height, approximately height*scale; however, filters can complicate the actual value.</p>
1638
1639 </div>
1640
1641
1642 <p><strong>Default:</strong> 0</p>
1643
1644
1645
1646
1647
1648</div>
1649
1650
1651 <div id="property__drawWidth" class="property item protected">
1652 <h3 class="name"><code>_drawWidth</code></h3>
1653 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1654
1655
1656
1657
1658 <span class="flag protected">protected</span>
1659
1660
1661
1662
1663
1664
1665
1666
1667 <div class="meta">
1668
1669
1670
1671 <p>
1672
1673 Defined in
1674
1675
1676
1677
1678 <a href="../files/easeljs_filters_BitmapCache.js.html#l179"><code>_drawWidth:179</code></a>
1679
1680 </p>
1681
1682
1683
1684
1685 </div>
1686
1687 <div class="description">
1688 <p>Internal tracking of final bounding width, approximately width*scale; however, filters can complicate the actual value.</p>
1689
1690 </div>
1691
1692
1693 <p><strong>Default:</strong> 0</p>
1694
1695
1696
1697
1698
1699</div>
1700
1701
1702 <div id="property__filterOffY" class="property item protected">
1703 <h3 class="name"><code>_filterOffY</code></h3>
1704 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1705
1706
1707
1708
1709 <span class="flag protected">protected</span>
1710
1711
1712
1713
1714
1715
1716
1717
1718 <div class="meta">
1719
1720
1721
1722 <p>
1723
1724 Defined in
1725
1726
1727
1728
1729 <a href="../files/easeljs_filters_BitmapCache.js.html#l151"><code>_filterOffY:151</code></a>
1730
1731 </p>
1732
1733
1734
1735
1736 </div>
1737
1738 <div class="description">
1739 <p>The relative offset of the filter's y position, used for drawing the cache onto its container.
1740Re-calculated every update call before drawing.</p>
1741
1742 </div>
1743
1744
1745 <p><strong>Default:</strong> 0</p>
1746
1747
1748
1749
1750
1751</div>
1752
1753
1754 <div id="property__filterOffY" class="property item protected">
1755 <h3 class="name"><code>_filterOffY</code></h3>
1756 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1757
1758
1759
1760
1761 <span class="flag protected">protected</span>
1762
1763
1764
1765
1766
1767
1768
1769
1770 <div class="meta">
1771
1772
1773
1774 <p>
1775
1776 Defined in
1777
1778
1779
1780
1781 <a href="../files/easeljs_filters_BitmapCache.js.html#l141"><code>_filterOffY:141</code></a>
1782
1783 </p>
1784
1785
1786
1787
1788 </div>
1789
1790 <div class="description">
1791 <p>The relative offset of the filter's x position, used for drawing the cache onto its container.
1792Re-calculated every update call before drawing.</p>
1793
1794 </div>
1795
1796
1797 <p><strong>Default:</strong> 0</p>
1798
1799
1800
1801
1802
1803</div>
1804
1805
1806 <div id="property_cacheID" class="property item">
1807 <h3 class="name"><code>cacheID</code></h3>
1808 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820 <div class="meta">
1821
1822
1823
1824 <p>
1825
1826 Defined in
1827
1828
1829
1830
1831 <a href="../files/easeljs_filters_BitmapCache.js.html#l131"><code>cacheID:131</code></a>
1832
1833 </p>
1834
1835
1836
1837
1838 </div>
1839
1840 <div class="description">
1841 <p>Track how many times the cache has been updated, mostly used for preventing duplicate cacheURLs.
1842This can be useful to see if a cache has been updated.</p>
1843
1844 </div>
1845
1846
1847 <p><strong>Default:</strong> 0</p>
1848
1849
1850
1851
1852
1853</div>
1854
1855
1856 <div id="property_height" class="property item protected">
1857 <h3 class="name"><code>height</code></h3>
1858 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1859
1860
1861
1862
1863 <span class="flag protected">protected</span>
1864
1865
1866
1867
1868
1869
1870
1871
1872 <div class="meta">
1873
1874
1875
1876 <p>
1877
1878 Defined in
1879
1880
1881
1882
1883 <a href="../files/easeljs_filters_BitmapCache.js.html#l74"><code>height:74</code></a>
1884
1885 </p>
1886
1887
1888
1889
1890 </div>
1891
1892 <div class="description">
1893 <p>Height of the cache relative to the target object.</p>
1894
1895 </div>
1896
1897
1898 <p><strong>Default:</strong> undefined</p>
1899
1900
1901
1902
1903
1904</div>
1905
1906
1907 <div id="property_offX" class="property item protected">
1908 <h3 class="name"><code>offX</code></h3>
1909 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1910
1911
1912
1913
1914 <span class="flag protected">protected</span>
1915
1916
1917
1918
1919
1920
1921
1922
1923 <div class="meta">
1924
1925
1926
1927 <p>
1928
1929 Defined in
1930
1931
1932
1933
1934 <a href="../files/easeljs_filters_BitmapCache.js.html#l113"><code>offX:113</code></a>
1935
1936 </p>
1937
1938
1939
1940
1941 </div>
1942
1943 <div class="description">
1944 <p>The x offset used for drawing into the cache itself, accounts for both transforms applied.</p>
1945
1946 </div>
1947
1948
1949 <p><strong>Default:</strong> 0</p>
1950
1951
1952
1953
1954
1955</div>
1956
1957
1958 <div id="property_offY" class="property item protected">
1959 <h3 class="name"><code>offY</code></h3>
1960 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
1961
1962
1963
1964
1965 <span class="flag protected">protected</span>
1966
1967
1968
1969
1970
1971
1972
1973
1974 <div class="meta">
1975
1976
1977
1978 <p>
1979
1980 Defined in
1981
1982
1983
1984
1985 <a href="../files/easeljs_filters_BitmapCache.js.html#l122"><code>offY:122</code></a>
1986
1987 </p>
1988
1989
1990
1991
1992 </div>
1993
1994 <div class="description">
1995 <p>The y offset used for drawing into the cache itself, accounts for both transforms applied.</p>
1996
1997 </div>
1998
1999
2000 <p><strong>Default:</strong> 0</p>
2001
2002
2003
2004
2005
2006</div>
2007
2008
2009 <div id="property_scale" class="property item protected">
2010 <h3 class="name"><code>scale</code></h3>
2011 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
2012
2013
2014
2015
2016 <span class="flag protected">protected</span>
2017
2018
2019
2020
2021
2022
2023
2024
2025 <div class="meta">
2026
2027
2028
2029 <p>
2030
2031 Defined in
2032
2033
2034
2035
2036 <a href="../files/easeljs_filters_BitmapCache.js.html#l102"><code>scale:102</code></a>
2037
2038 </p>
2039
2040
2041
2042
2043 </div>
2044
2045 <div class="description">
2046 <p>The internal scale of the cache image, does not affects display size. This is useful to both increase and
2047decrease render quality. Objects with increased scales are more likely to look good when scaled up or rotated.
2048Objects with decreased scales can save on rendering performance.</p>
2049
2050 </div>
2051
2052
2053 <p><strong>Default:</strong> 1</p>
2054
2055
2056
2057
2058
2059</div>
2060
2061
2062 <div id="property_width" class="property item protected">
2063 <h3 class="name"><code>width</code></h3>
2064 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
2065
2066
2067
2068
2069 <span class="flag protected">protected</span>
2070
2071
2072
2073
2074
2075
2076
2077
2078 <div class="meta">
2079
2080
2081
2082 <p>
2083
2084 Defined in
2085
2086
2087
2088
2089 <a href="../files/easeljs_filters_BitmapCache.js.html#l65"><code>width:65</code></a>
2090
2091 </p>
2092
2093
2094
2095
2096 </div>
2097
2098 <div class="description">
2099 <p>Width of the cache relative to the target object.</p>
2100
2101 </div>
2102
2103
2104 <p><strong>Default:</strong> undefined</p>
2105
2106
2107
2108
2109
2110</div>
2111
2112
2113 <div id="property_x" class="property item protected">
2114 <h3 class="name"><code>x</code></h3>
2115 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
2116
2117
2118
2119
2120 <span class="flag protected">protected</span>
2121
2122
2123
2124
2125
2126
2127
2128
2129 <div class="meta">
2130
2131
2132
2133 <p>
2134
2135 Defined in
2136
2137
2138
2139
2140 <a href="../files/easeljs_filters_BitmapCache.js.html#l84"><code>x:84</code></a>
2141
2142 </p>
2143
2144
2145
2146
2147 </div>
2148
2149 <div class="description">
2150 <p>Horizontal position of the cache relative to the target's origin.</p>
2151
2152 </div>
2153
2154
2155 <p><strong>Default:</strong> undefined</p>
2156
2157
2158
2159
2160
2161</div>
2162
2163
2164 <div id="property_y" class="property item protected">
2165 <h3 class="name"><code>y</code></h3>
2166 <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
2167
2168
2169
2170
2171 <span class="flag protected">protected</span>
2172
2173
2174
2175
2176
2177
2178
2179
2180 <div class="meta">
2181
2182
2183
2184 <p>
2185
2186 Defined in
2187
2188
2189
2190
2191 <a href="../files/easeljs_filters_BitmapCache.js.html#l93"><code>y:93</code></a>
2192
2193 </p>
2194
2195
2196
2197
2198 </div>
2199
2200 <div class="description">
2201 <p>Vertical position of the cache relative to target's origin.</p>
2202
2203 </div>
2204
2205
2206 <p><strong>Default:</strong> undefined</p>
2207
2208
2209
2210
2211
2212</div>
2213
2214
2215 </div>
2216
2217
2218
2219
2220
2221 </div>
2222</div>
2223
2224 </div>
2225 </div>
2226 </div>
2227 </div>
2228 </div>
2229</div>
2230<script src="../assets/vendor/prettify/prettify-min.js"></script>
2231<script>prettyPrint();</script>
2232<script src="../assets/js/yui-prettify.js"></script>
2233<script src="../assets/../api.js"></script>
2234<script src="../assets/js/api-filter.js"></script>
2235<script src="../assets/js/api-list.js"></script>
2236<script src="../assets/js/api-search.js"></script>
2237<script src="../assets/js/apidocs.js"></script>
2238</body>
2239</html>