Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_a_layer_8j_source.html

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_a_layer_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:28 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: AppKit/CoreAnimation/CALayer.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>AppKit/CoreAnimation/CALayer.j</h1><a href="_c_a_layer_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * CALayer.j</span>
<a name="l00003"></a>00003 <span class="comment"> * AppKit</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created by Francisco Tolmasky.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2008, 280 North, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00016"></a>00016 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 @<span class="keyword">import</span> &lt;Foundation/<a class="code" href="class_c_p_object.html" title="The root class from which most classes are subclassed.">CPObject</a>.j&gt;
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 @<span class="keyword">import</span> &lt;AppKit/CABackingStore.j&gt;
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 @<span class="keyword">import</span> &lt;AppKit/CGContext.j&gt;
<a name="l00028"></a>00028 @<span class="keyword">import</span> &lt;AppKit/CGGeometry.j&gt;
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;../CoreGraphics/CGGeometry.h&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;../CoreGraphics/CGAffineTransform.j&quot;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">00034</a> <span class="preprocessor">#define DOM(aLayer) aLayer._DOMElement</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a><a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">00036</a> var <a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">CALayerGeometryBoundsMask</a>                   = 1,
<a name="l00037"></a><a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">00037</a>     <a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">CALayerGeometryPositionMask</a>                 = 2,
<a name="l00038"></a><a class="code" href="_c_a_layer_8j.html#a4481f9da252746e5b81eb67af6f9d0f8">00038</a>     <a class="code" href="_c_a_layer_8j.html#a4481f9da252746e5b81eb67af6f9d0f8">CALayerGeometryAnchorPointMask</a>              = 4,
<a name="l00039"></a><a class="code" href="_c_a_layer_8j.html#af551f56d2ec1637a4dd3b8e6672d284e">00039</a>     <a class="code" href="_c_a_layer_8j.html#af551f56d2ec1637a4dd3b8e6672d284e">CALayerGeometryAffineTransformMask</a>          = 8,
<a name="l00040"></a><a class="code" href="_c_a_layer_8j.html#afafdb56b39f5840584dabc52cac0a9a7">00040</a>     <a class="code" href="_c_a_layer_8j.html#afafdb56b39f5840584dabc52cac0a9a7">CALayerGeometryParentSublayerTransformMask</a>  = 16;
<a name="l00041"></a><a class="code" href="_c_a_layer_8j.html#af1278afeafe5ca978f308332072f9efd">00041</a> var <a class="code" href="_c_a_layer_8j.html#af1278afeafe5ca978f308332072f9efd">USE_BUFFER</a> = NO;
<a name="l00042"></a>00042 
<a name="l00043"></a><a class="code" href="_c_a_layer_8j.html#aaf1285d3b64e902c2c83bb85b7937e31">00043</a> var <a class="code" href="_c_a_layer_8j.html#aaf1285d3b64e902c2c83bb85b7937e31">CALayerFrameOriginUpdateMask</a>                = 1,
<a name="l00044"></a><a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">00044</a>     <a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">CALayerFrameSizeUpdateMask</a>                  = 2,
<a name="l00045"></a><a class="code" href="_c_a_layer_8j.html#acd4260da148e61285fdf91c10bf2e661">00045</a>     <a class="code" href="_c_a_layer_8j.html#acd4260da148e61285fdf91c10bf2e661">CALayerZPositionUpdateMask</a>                  = 4,
<a name="l00046"></a><a class="code" href="_c_a_layer_8j.html#aea3fa0c520450b903260bc7d7d91e873">00046</a>     <a class="code" href="_c_a_layer_8j.html#aea3fa0c520450b903260bc7d7d91e873">CALayerDisplayUpdateMask</a>                    = 8,
<a name="l00047"></a><a class="code" href="_c_a_layer_8j.html#a0d8d5fbf9708caaee8b1b1147e7ed988">00047</a>     <a class="code" href="_c_a_layer_8j.html#a0d8d5fbf9708caaee8b1b1147e7ed988">CALayerCompositeUpdateMask</a>                  = 16,
<a name="l00048"></a><a class="code" href="_c_a_layer_8j.html#a13368e69c48203d60d0e8eba3a151791">00048</a>     <a class="code" href="_c_a_layer_8j.html#a13368e69c48203d60d0e8eba3a151791">CALayerDOMUpdateMask</a>                        = <a class="code" href="_c_a_layer_8j.html#acd4260da148e61285fdf91c10bf2e661">CALayerZPositionUpdateMask</a> | <a class="code" href="_c_a_layer_8j.html#aaf1285d3b64e902c2c83bb85b7937e31">CALayerFrameOriginUpdateMask</a> | <a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">CALayerFrameSizeUpdateMask</a>;
<a name="l00049"></a>00049 
<a name="l00050"></a><a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">00050</a> var <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a>             = nil;
<a name="l00051"></a>00051 
<a name="l00067"></a><a class="code" href="class_c_a_layer.html">00067</a> <span class="keyword">@implementation </span><a class="code" href="class_c_a_layer.html">CALayer</a> : <a class="code" href="class_c_p_object.html" title="The root class from which most classes are subclassed.">CPObject</a>
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069     <span class="comment">// Modifying the Layer Geometry</span>
<a name="l00070"></a>00070     
<a name="l00071"></a>00071     CGRect              _frame;
<a name="l00072"></a>00072     CGRect              _bounds;
<a name="l00073"></a>00073     CGPoint             _position;
<a name="l00074"></a>00074     <span class="keywordtype">unsigned</span>            _zPosition;
<a name="l00075"></a>00075     CGPoint             _anchorPoint;
<a name="l00076"></a>00076     
<a name="l00077"></a>00077     CGAffineTransform   _affineTransform;
<a name="l00078"></a>00078     CGAffineTransform   _sublayerTransform;
<a name="l00079"></a>00079     CGAffineTransform   _sublayerTransformForSublayers;
<a name="l00080"></a>00080     
<a name="l00081"></a>00081     CGRect              _backingStoreFrame;
<a name="l00082"></a>00082     CGRect              _standardBackingStoreFrame;
<a name="l00083"></a>00083     
<a name="l00084"></a>00084     BOOL                _hasSublayerTransform;
<a name="l00085"></a>00085     BOOL                _hasCustomBackingStoreFrame;
<a name="l00086"></a>00086     
<a name="l00087"></a>00087     <span class="comment">// Style Attributes</span>
<a name="l00088"></a>00088     
<a name="l00089"></a>00089     <span class="keywordtype">float</span>               _opacity;
<a name="l00090"></a>00090     BOOL                _isHidden;
<a name="l00091"></a>00091     <a class="code" href="class_c_p_color.html">CPColor</a>             _backgroundColor;
<a name="l00092"></a>00092     
<a name="l00093"></a>00093     <span class="comment">// Managing Layer Hierarchy</span>
<a name="l00094"></a>00094     
<a name="l00095"></a>00095     <a class="code" href="class_c_a_layer.html">CALayer</a>             _superlayer;
<a name="l00096"></a>00096     <a class="code" href="class_c_p_mutable_array.html">CPMutableArray</a>      _sublayers;
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <span class="comment">// Updating Layer Display</span>
<a name="l00099"></a>00099     
<a name="l00100"></a>00100     <span class="keywordtype">unsigned</span>            _runLoopUpdateMask;
<a name="l00101"></a>00101     BOOL                _needsDisplayOnBoundsChange;
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="comment">// Modifying the Delegate</span>
<a name="l00104"></a>00104     
<a name="l00105"></a>00105     <span class="keywordtype">id</span>                  _delegate;
<a name="l00106"></a>00106     
<a name="l00107"></a>00107     BOOL                _delegateRespondsToDisplayLayerSelector;
<a name="l00108"></a>00108     BOOL                _delegateRespondsToDrawLayerInContextSelector;
<a name="l00109"></a>00109     
<a name="l00110"></a>00110     <span class="comment">// DOM Implementation</span>
<a name="l00111"></a>00111     
<a name="l00112"></a>00112     DOMElement          _DOMElement;
<a name="l00113"></a>00113     DOMElement          _DOMContentsElement;
<a name="l00114"></a>00114     <span class="keywordtype">id</span>                  _contents;
<a name="l00115"></a>00115     CGContext           _context;
<a name="l00116"></a>00116     <a class="code" href="class_c_p_view.html">CPView</a>              _owningView;
<a name="l00117"></a>00117     
<a name="l00118"></a>00118     CGAffineTransform   _transformToLayer;
<a name="l00119"></a>00119     CGAffineTransform   _transformFromLayer;
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121 
<a name="l00125"></a><a class="code" href="class_c_a_layer.html#a8831e6df7ac688e76e448afada8eafe6">00125</a> + (<a class="code" href="class_c_a_layer.html">CALayer</a>)layer
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127     <span class="keywordflow">return</span> [[[<span class="keyword">self</span> class] alloc] init];
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 
<a name="l00133"></a><a class="code" href="class_c_a_layer.html#ad279427de9cac2b101431f9d638b130f">00133</a> - (id)init
<a name="l00134"></a>00134 {
<a name="l00135"></a>00135     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00136"></a>00136     
<a name="l00137"></a>00137     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00138"></a>00138     {
<a name="l00139"></a>00139         _frame = <a class="code" href="_c_g_geometry_8j.html#aaab3ca5ef295a8517c18bfce6e95c1f6">CGRectMakeZero</a>();
<a name="l00140"></a>00140         
<a name="l00141"></a>00141         _backingStoreFrame = <a class="code" href="_c_g_geometry_8j.html#aaab3ca5ef295a8517c18bfce6e95c1f6">CGRectMakeZero</a>();
<a name="l00142"></a>00142         _standardBackingStoreFrame = <a class="code" href="_c_g_geometry_8j.html#aaab3ca5ef295a8517c18bfce6e95c1f6">CGRectMakeZero</a>();
<a name="l00143"></a>00143         
<a name="l00144"></a>00144         _bounds = <a class="code" href="_c_g_geometry_8j.html#aaab3ca5ef295a8517c18bfce6e95c1f6">CGRectMakeZero</a>();
<a name="l00145"></a>00145         _position = <a class="code" href="_c_g_geometry_8j.html#a708f763d0feefd3056965f041c3c2cb2">CGPointMakeZero</a>();
<a name="l00146"></a>00146         _zPosition = 0.0;
<a name="l00147"></a>00147         _anchorPoint = <a class="code" href="_c_g_geometry_8j.html#a06c96cb5931220da52ff44b8ce9b603e">CGPointMake</a>(0.5, 0.5);
<a name="l00148"></a>00148         _affineTransform = <a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>();
<a name="l00149"></a>00149         _sublayerTransform = <a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>();
<a name="l00150"></a>00150 
<a name="l00151"></a>00151         _transformToLayer = <a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>(); <span class="comment">// FIXME? does it matter?</span>
<a name="l00152"></a>00152         _transformFromLayer = <a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>();
<a name="l00153"></a>00153         
<a name="l00154"></a>00154         _opacity = 1.0;
<a name="l00155"></a>00155         _isHidden = NO;
<a name="l00156"></a>00156         _masksToBounds = NO;
<a name="l00157"></a>00157         
<a name="l00158"></a>00158         _sublayers = [];
<a name="l00159"></a>00159         
<a name="l00160"></a>00160         _DOMElement = document.createElement(<span class="stringliteral">&quot;div&quot;</span>);
<a name="l00161"></a>00161         
<a name="l00162"></a>00162         _DOMElement.style.overflow = <span class="stringliteral">&quot;visible&quot;</span>;
<a name="l00163"></a>00163         _DOMElement.style.position = <span class="stringliteral">&quot;absolute&quot;</span>;
<a name="l00164"></a>00164         _DOMElement.style.visibility = <span class="stringliteral">&quot;visible&quot;</span>;
<a name="l00165"></a>00165         _DOMElement.style.top = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00166"></a>00166         _DOMElement.style.left = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00167"></a>00167         _DOMElement.style.zIndex = 0;
<a name="l00168"></a>00168         _DOMElement.style.width = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00169"></a>00169         _DOMElement.style.height = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00170"></a>00170     }
<a name="l00171"></a>00171     
<a name="l00172"></a>00172     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="comment">// Modifying the Layer Geometry</span>
<a name="l00180"></a><a class="code" href="class_c_a_layer.html#ab83346bff051219122826ae87b77da63">00180</a> <span class="comment"></span>- (void)setBounds:(CGRect)aBounds
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182     <span class="keywordflow">if</span> (<a class="code" href="_c_g_geometry_8j.html#ab2c7317de643eac257976b886fc932e8">CGRectEqualToRect</a>(_bounds, aBounds))
<a name="l00183"></a>00183         <span class="keywordflow">return</span>;
<a name="l00184"></a>00184 
<a name="l00185"></a>00185     var oldOrigin = _bounds.origin;
<a name="l00186"></a>00186 
<a name="l00187"></a>00187     _bounds = _CGRectMakeCopy(aBounds);
<a name="l00188"></a>00188     
<a name="l00189"></a>00189     <span class="keywordflow">if</span> (_hasSublayerTransform)
<a name="l00190"></a>00190         _CALayerUpdateSublayerTransformForSublayers(<span class="keyword">self</span>);
<a name="l00191"></a>00191         
<a name="l00192"></a>00192     <span class="comment">// _hasSublayerTransform == true will handle this for us.</span>
<a name="l00193"></a>00193     <span class="comment">/*else if (!CGPointEqualToPoint(_bounds.origin, oldOrigin))</span>
<a name="l00194"></a>00194 <span class="comment">    {</span>
<a name="l00195"></a>00195 <span class="comment">        var index = _sublayers.length;</span>
<a name="l00196"></a>00196 <span class="comment">        </span>
<a name="l00197"></a>00197 <span class="comment">        // FIXME: This should climb the layer tree down.</span>
<a name="l00198"></a>00198 <span class="comment">        while (index--)</span>
<a name="l00199"></a>00199 <span class="comment">            _CALayerRecalculateGeometry(_sublayers[index], CALayerGeometryPositionMask);</span>
<a name="l00200"></a>00200 <span class="comment">    }*/</span>
<a name="l00201"></a>00201     
<a name="l00202"></a>00202     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">CALayerGeometryBoundsMask</a>);
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204 
<a name="l00208"></a><a class="code" href="class_c_a_layer.html#a3b4a675ebb6097d357586a278472483c">00208</a> - (CGRect)bounds
<a name="l00209"></a>00209 {
<a name="l00210"></a>00210     <span class="keywordflow">return</span> _bounds;
<a name="l00211"></a>00211 }
<a name="l00212"></a>00212 
<a name="l00217"></a><a class="code" href="class_c_a_layer.html#a780ade74d12340c78544a200283d0e73">00217</a> - (void)setPosition:(CGPoint)aPosition
<a name="l00218"></a>00218 {
<a name="l00219"></a>00219     <span class="keywordflow">if</span> (<a class="code" href="_c_g_geometry_8j.html#a92e2504d7631188e8c340f9462dd80d9">CGPointEqualToPoint</a>(_position, aPosition))
<a name="l00220"></a>00220         <span class="keywordflow">return</span>;
<a name="l00221"></a>00221     
<a name="l00222"></a>00222     _position = _CGPointMakeCopy(aPosition);
<a name="l00223"></a>00223     
<a name="l00224"></a>00224     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">CALayerGeometryPositionMask</a>);
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 
<a name="l00230"></a><a class="code" href="class_c_a_layer.html#ad23d67f19332161b662251f45914fcd8">00230</a> - (CGPoint)position
<a name="l00231"></a>00231 {
<a name="l00232"></a>00232     <span class="keywordflow">return</span> _position;
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234 
<a name="l00239"></a><a class="code" href="class_c_a_layer.html#a83df7dcca0a2a28c39fdc727049fc378">00239</a> - (void)setZPosition:(<span class="keywordtype">int</span>)aZPosition
<a name="l00240"></a>00240 {
<a name="l00241"></a>00241     <span class="keywordflow">if</span> (_zPosition == aZPosition)
<a name="l00242"></a>00242         <span class="keywordflow">return</span>;
<a name="l00243"></a>00243     
<a name="l00244"></a>00244     _zPosition = aZPosition;
<a name="l00245"></a>00245     
<a name="l00246"></a>00246     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerZPositionUpdateMask];
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248 
<a name="l00253"></a><a class="code" href="class_c_a_layer.html#a3278f0312f7ab10c42f1f5b0f7d00ed8">00253</a> - (void)setAnchorPoint:(CGPoint)anAnchorPoint
<a name="l00254"></a>00254 {
<a name="l00255"></a>00255     anAnchorPoint = _CGPointMakeCopy(anAnchorPoint);
<a name="l00256"></a>00256     anAnchorPoint.x = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(1.0, <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(0.0, anAnchorPoint.x));
<a name="l00257"></a>00257     anAnchorPoint.y = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(1.0, <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(0.0, anAnchorPoint.y));
<a name="l00258"></a>00258     
<a name="l00259"></a>00259     <span class="keywordflow">if</span> (<a class="code" href="_c_g_geometry_8j.html#a92e2504d7631188e8c340f9462dd80d9">CGPointEqualToPoint</a>(_anchorPoint, anAnchorPoint))
<a name="l00260"></a>00260         <span class="keywordflow">return</span>;
<a name="l00261"></a>00261     
<a name="l00262"></a>00262     _anchorPoint = anAnchorPoint;
<a name="l00263"></a>00263     
<a name="l00264"></a>00264     <span class="keywordflow">if</span> (_hasSublayerTransform)
<a name="l00265"></a>00265         _CALayerUpdateSublayerTransformForSublayers(<span class="keyword">self</span>);
<a name="l00266"></a>00266 
<a name="l00267"></a>00267     <span class="keywordflow">if</span> (_owningView)
<a name="l00268"></a>00268         _position = <a class="code" href="_c_g_geometry_8j.html#a06c96cb5931220da52ff44b8ce9b603e">CGPointMake</a>(_CGRectGetWidth(_bounds) * _anchorPoint.x, _CGRectGetHeight(_bounds) * _anchorPoint.y);
<a name="l00269"></a>00269     
<a name="l00270"></a>00270     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#a4481f9da252746e5b81eb67af6f9d0f8">CALayerGeometryAnchorPointMask</a>);
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272 
<a name="l00276"></a><a class="code" href="class_c_a_layer.html#a16eb5134e6f939626f8db2fc6859a8ee">00276</a> - (CGPoint)anchorPoint
<a name="l00277"></a>00277 {
<a name="l00278"></a>00278     <span class="keywordflow">return</span> _anchorPoint;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 
<a name="l00285"></a><a class="code" href="class_c_a_layer.html#a7f2e0ac759e3ec76d70b108761c968b8">00285</a> - (void)setAffineTransform:(CGAffineTransform)anAffineTransform
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287     <span class="keywordflow">if</span> (<a class="code" href="_c_g_affine_transform_8j.html#a13fc4eb44a96f08f758b22b47be24224">CGAffineTransformEqualToTransform</a>(_affineTransform, anAffineTransform))
<a name="l00288"></a>00288         <span class="keywordflow">return</span>;
<a name="l00289"></a>00289     
<a name="l00290"></a>00290     _affineTransform = _CGAffineTransformMakeCopy(anAffineTransform);
<a name="l00291"></a>00291     
<a name="l00292"></a>00292     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#af551f56d2ec1637a4dd3b8e6672d284e">CALayerGeometryAffineTransformMask</a>);
<a name="l00293"></a>00293 }
<a name="l00294"></a>00294 
<a name="l00298"></a><a class="code" href="class_c_a_layer.html#a2b79a8b8f2ff2f5ffc98cb662366ebe1">00298</a> - (CGAffineTransform)affineTransform
<a name="l00299"></a>00299 {
<a name="l00300"></a>00300     <span class="keywordflow">return</span> _affineTransform;
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302 
<a name="l00307"></a><a class="code" href="class_c_a_layer.html#a29ba21b392a078fd1c0a2d1d968c4fa9">00307</a> - (void)setSublayerTransform:(CGAffineTransform)anAffineTransform
<a name="l00308"></a>00308 {
<a name="l00309"></a>00309     <span class="keywordflow">if</span> (<a class="code" href="_c_g_affine_transform_8j.html#a13fc4eb44a96f08f758b22b47be24224">CGAffineTransformEqualToTransform</a>(_sublayerTransform, anAffineTransform))
<a name="l00310"></a>00310         <span class="keywordflow">return</span>;
<a name="l00311"></a>00311 
<a name="l00312"></a>00312     var hadSublayerTransform = _hasSublayerTransform;
<a name="l00313"></a>00313     
<a name="l00314"></a>00314     _sublayerTransform = _CGAffineTransformMakeCopy(anAffineTransform);
<a name="l00315"></a>00315     _hasSublayerTransform = !_CGAffineTransformIsIdentity(_sublayerTransform);
<a name="l00316"></a>00316     
<a name="l00317"></a>00317     <span class="keywordflow">if</span> (_hasSublayerTransform)
<a name="l00318"></a>00318     {
<a name="l00319"></a>00319         _CALayerUpdateSublayerTransformForSublayers(<span class="keyword">self</span>);
<a name="l00320"></a>00320 
<a name="l00321"></a>00321         var index = _sublayers.length;
<a name="l00322"></a>00322         
<a name="l00323"></a>00323         <span class="comment">// FIXME: This should climb the layer tree down.</span>
<a name="l00324"></a>00324         <span class="keywordflow">while</span> (index--)
<a name="l00325"></a>00325             _CALayerRecalculateGeometry(_sublayers[index], <a class="code" href="_c_a_layer_8j.html#afafdb56b39f5840584dabc52cac0a9a7">CALayerGeometryParentSublayerTransformMask</a>);
<a name="l00326"></a>00326     }
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328 
<a name="l00332"></a><a class="code" href="class_c_a_layer.html#a21dce1e6a753bb1a042d457052a8a765">00332</a> - (CGAffineTransform)sublayerTransform
<a name="l00333"></a>00333 {
<a name="l00334"></a>00334     <span class="keywordflow">return</span> _sublayerTransform;
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336 
<a name="l00337"></a>00337 <span class="comment">/*</span>
<a name="l00338"></a>00338 <span class="comment">    Private</span>
<a name="l00339"></a>00339 <span class="comment">    @ignore</span>
<a name="l00340"></a>00340 <span class="comment">*/</span>
<a name="l00341"></a><a class="code" href="class_c_a_layer.html#a3143b9efe061d28239232dd4bcdf0a36">00341</a> - (CGAffineTransform)transformToLayer
<a name="l00342"></a>00342 {
<a name="l00343"></a>00343     <span class="keywordflow">return</span> _transformToLayer;
<a name="l00344"></a>00344 }
<a name="l00345"></a>00345 
<a name="l00351"></a><a class="code" href="class_c_a_layer.html#af2e344de4f27180679fcddce494daaef">00351</a> - (void)setFrame:(CGRect)aFrame
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353     alert(<span class="stringliteral">&quot;FIXME IMPLEMENT&quot;</span>);
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 
<a name="l00363"></a><a class="code" href="class_c_a_layer.html#aec1346c32960eec23d6d37df877a196c">00363</a> - (CGRect)<a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a>
<a name="l00364"></a>00364 {
<a name="l00365"></a>00365     <span class="keywordflow">if</span> (!_frame)
<a name="l00366"></a>00366         _frame = [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#ab3ef6728f2afc9408da351267ef975b2">convertRect</a>:_bounds <a class="code" href="class_c_a_layer.html#ab3ef6728f2afc9408da351267ef975b2">toLayer</a>:_superlayer];
<a name="l00367"></a>00367     
<a name="l00368"></a>00368     <span class="keywordflow">return</span> _frame;
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370 
<a name="l00379"></a><a class="code" href="class_c_a_layer.html#aa4e6bccff52897b5ea719f97f661d402">00379</a> - (CGRect)backingStoreFrame
<a name="l00380"></a>00380 {
<a name="l00381"></a>00381     <span class="keywordflow">return</span> _backingStoreFrame;
<a name="l00382"></a>00382 }
<a name="l00383"></a>00383 
<a name="l00388"></a><a class="code" href="class_c_a_layer.html#a0487576422eaa56f1b070df34f357a55">00388</a> - (void)setBackingStoreFrame:(CGRect)aFrame
<a name="l00389"></a>00389 {
<a name="l00390"></a>00390     _hasCustomBackingStoreFrame = (aFrame != nil);
<a name="l00391"></a>00391     
<a name="l00392"></a>00392     <span class="keywordflow">if</span> (aFrame == nil)
<a name="l00393"></a>00393         aFrame = <a class="code" href="_c_g_geometry_8j.html#a7521362038d81fa55cafbd6da5130335">CGRectMakeCopy</a>(_standardBackingStoreFrame);
<a name="l00394"></a>00394     <span class="keywordflow">else</span>
<a name="l00395"></a>00395     {
<a name="l00396"></a>00396         <span class="keywordflow">if</span> (_superlayer)
<a name="l00397"></a>00397         {
<a name="l00398"></a>00398             aFrame = [_superlayer convertRect:aFrame toLayer:nil];
<a name="l00399"></a>00399             
<a name="l00400"></a>00400             var bounds = [_superlayer bounds],
<a name="l00401"></a>00401                 <a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a> = [_superlayer convertRect:bounds toLayer:nil];
<a name="l00402"></a>00402             
<a name="l00403"></a>00403             aFrame.origin.x -= _CGRectGetMinX(<a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a>);
<a name="l00404"></a>00404             aFrame.origin.y -= _CGRectGetMinY(<a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a>);
<a name="l00405"></a>00405         }
<a name="l00406"></a>00406         <span class="keywordflow">else</span>
<a name="l00407"></a>00407             aFrame = <a class="code" href="_c_g_geometry_8j.html#a7521362038d81fa55cafbd6da5130335">CGRectMakeCopy</a>(aFrame);
<a name="l00408"></a>00408     }
<a name="l00409"></a>00409     
<a name="l00410"></a>00410     <span class="keywordflow">if</span> (!<a class="code" href="_c_g_geometry_8j.html#a92e2504d7631188e8c340f9462dd80d9">CGPointEqualToPoint</a>(_backingStoreFrame.origin, aFrame.origin))
<a name="l00411"></a>00411         [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerFrameOriginUpdateMask];
<a name="l00412"></a>00412         
<a name="l00413"></a>00413     <span class="keywordflow">if</span> (!<a class="code" href="_c_g_geometry_8j.html#a1eefbb30f35d5c4f4473bec9a2ebff9f">CGSizeEqualToSize</a>(_backingStoreFrame.size, aFrame.size))
<a name="l00414"></a>00414         [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerFrameSizeUpdateMask];
<a name="l00415"></a>00415         
<a name="l00416"></a>00416     _backingStoreFrame = aFrame;
<a name="l00417"></a>00417 }
<a name="l00418"></a>00418 
<a name="l00419"></a>00419 <span class="comment">// Providing Layer Content</span>
<a name="l00424"></a><a class="code" href="class_c_a_layer.html#a9b79362a38e353ac64c338c979645e1b">00424</a> <span class="comment"></span>- (CGImage)contents
<a name="l00425"></a>00425 {
<a name="l00426"></a>00426     <span class="keywordflow">return</span> _contents;
<a name="l00427"></a>00427 }
<a name="l00428"></a>00428 
<a name="l00433"></a><a class="code" href="class_c_a_layer.html#a70e448233f13f081e5d4848556dda17d">00433</a> - (void)setContents:(CGImage)contents
<a name="l00434"></a>00434 {
<a name="l00435"></a>00435     <span class="keywordflow">if</span> (_contents == contents)
<a name="l00436"></a>00436         <span class="keywordflow">return</span>;
<a name="l00437"></a>00437         
<a name="l00438"></a>00438     _contents = contents;
<a name="l00439"></a>00439        
<a name="l00440"></a>00440     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a0ca648303d1edf497cb522400afff95c">composite</a>];
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 
<a name="l00443"></a>00443 <span class="comment">/*</span>
<a name="l00444"></a>00444 <span class="comment">    Composites this layer onto the super layer, and draws its contents as well.</span>
<a name="l00445"></a>00445 <span class="comment">    @ignore</span>
<a name="l00446"></a>00446 <span class="comment">*/</span>
<a name="l00447"></a><a class="code" href="class_c_a_layer.html#a0ca648303d1edf497cb522400afff95c">00447</a> - (void)composite
<a name="l00448"></a>00448 {
<a name="l00449"></a>00449     <span class="keywordflow">if</span> (<a class="code" href="_c_a_layer_8j.html#af1278afeafe5ca978f308332072f9efd">USE_BUFFER</a> &amp;&amp; !_contents || !_context)
<a name="l00450"></a>00450         <span class="keywordflow">return</span>;
<a name="l00451"></a>00451     
<a name="l00452"></a>00452     <a class="code" href="_c_g_context_canvas_8j.html#ad26b22aa810370acebe12a0656b26f8d">CGContextClearRect</a>(_context, _CGRectMake(0.0, 0.0, _CGRectGetWidth(_backingStoreFrame), _CGRectGetHeight(_backingStoreFrame)));
<a name="l00453"></a>00453     
<a name="l00454"></a>00454     <span class="comment">// Recomposite</span>
<a name="l00455"></a>00455     var transform = _transformFromLayer;
<a name="l00456"></a>00456     
<a name="l00457"></a>00457     <span class="keywordflow">if</span> (_superlayer)
<a name="l00458"></a>00458     {
<a name="l00459"></a>00459         var superlayerTransform = _CALayerGetTransform(_superlayer, nil),
<a name="l00460"></a>00460             superlayerOrigin = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(_superlayer._bounds.origin, superlayerTransform);
<a name="l00461"></a>00461         
<a name="l00462"></a>00462         transform = <a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(transform, superlayerTransform);
<a name="l00463"></a>00463         
<a name="l00464"></a>00464         transform.tx -= superlayerOrigin.x;
<a name="l00465"></a>00465         transform.ty -= superlayerOrigin.y;
<a name="l00466"></a>00466     }
<a name="l00467"></a>00467 
<a name="l00468"></a>00468     transform.tx -= _CGRectGetMinX(_backingStoreFrame);
<a name="l00469"></a>00469     transform.ty -= _CGRectGetMinY(_backingStoreFrame);
<a name="l00470"></a>00470     
<a name="l00471"></a>00471     <a class="code" href="group__coregraphics.html#ga3044141e2efee5c87c2d2cf7a034442d">CGContextSaveGState</a>(_context);
<a name="l00472"></a>00472     <a class="code" href="group__coregraphics.html#ga0f2dc89da432a179558067fd023a9315">CGContextConcatCTM</a>(_context, transform);<span class="comment">//_transformFromView);</span>
<a name="l00473"></a>00473     <span class="keywordflow">if</span> (<a class="code" href="_c_a_layer_8j.html#af1278afeafe5ca978f308332072f9efd">USE_BUFFER</a>)
<a name="l00474"></a>00474     {
<a name="l00475"></a>00475 <span class="comment">//        CGContextDrawImage(_context, _bounds, _contents.context);</span>
<a name="l00476"></a>00476         _context.drawImage(_contents.buffer, _CGRectGetMinX(_bounds), _CGRectGetMinY(_bounds));<span class="comment">//, _CGRectGetWidth(_standardBackingStoreFrame), _CGRectGetHeight(_standardBackingStoreFrame));</span>
<a name="l00477"></a>00477     }
<a name="l00478"></a>00478     <span class="keywordflow">else</span>
<a name="l00479"></a>00479         [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aae7b9db1917a37a0fbd35692276ada5a">drawInContext</a>:_context];
<a name="l00480"></a>00480     <a class="code" href="group__coregraphics.html#ga017455e56ea37b37ba671c0443764576">CGContextRestoreGState</a>(_context);
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 
<a name="l00486"></a><a class="code" href="class_c_a_layer.html#a7557b5b724e9fb8d705d9978cd31e760">00486</a> - (void)display
<a name="l00487"></a>00487 {
<a name="l00488"></a>00488     <span class="keywordflow">if</span> (!_context)
<a name="l00489"></a>00489     {
<a name="l00490"></a>00490         _context = <a class="code" href="group__coregraphics.html#ga792b63f505ae560e354bdd49de62307c">CGBitmapGraphicsContextCreate</a>();
<a name="l00491"></a>00491         
<a name="l00492"></a>00492         _DOMContentsElement = _context.DOMElement;
<a name="l00493"></a>00493         
<a name="l00494"></a>00494         _DOMContentsElement.style.zIndex = -100;
<a name="l00495"></a>00495 
<a name="l00496"></a>00496         _DOMContentsElement.style.overflow = <span class="stringliteral">&quot;hidden&quot;</span>;
<a name="l00497"></a>00497         _DOMContentsElement.style.position = <span class="stringliteral">&quot;absolute&quot;</span>;
<a name="l00498"></a>00498         _DOMContentsElement.style.visibility = <span class="stringliteral">&quot;visible&quot;</span>;
<a name="l00499"></a>00499         
<a name="l00500"></a>00500         _DOMContentsElement.width = ROUND(_CGRectGetWidth(_backingStoreFrame));
<a name="l00501"></a>00501         _DOMContentsElement.height = ROUND(_CGRectGetHeight(_backingStoreFrame));
<a name="l00502"></a>00502         
<a name="l00503"></a>00503         _DOMContentsElement.style.top = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00504"></a>00504         _DOMContentsElement.style.left = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00505"></a>00505         _DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_backingStoreFrame)) + <span class="stringliteral">&quot;px&quot;</span>;
<a name="l00506"></a>00506         _DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_backingStoreFrame)) + <span class="stringliteral">&quot;px&quot;</span>;
<a name="l00507"></a>00507 
<a name="l00508"></a>00508         _DOMElement.appendChild(_DOMContentsElement);
<a name="l00509"></a>00509     }
<a name="l00510"></a>00510     
<a name="l00511"></a>00511     <span class="keywordflow">if</span> (<a class="code" href="_c_a_layer_8j.html#af1278afeafe5ca978f308332072f9efd">USE_BUFFER</a>)
<a name="l00512"></a>00512     {
<a name="l00513"></a>00513         <span class="keywordflow">if</span> (_delegateRespondsToDisplayLayerSelector)
<a name="l00514"></a>00514             <span class="keywordflow">return</span> [_delegate displayInLayer:self];
<a name="l00515"></a>00515     
<a name="l00516"></a>00516         <span class="keywordflow">if</span> (_CGRectGetWidth(_backingStoreFrame) == 0.0 || _CGRectGetHeight(_backingStoreFrame) == 0.0)
<a name="l00517"></a>00517             <span class="keywordflow">return</span>;
<a name="l00518"></a>00518     
<a name="l00519"></a>00519         <span class="keywordflow">if</span> (!_contents)
<a name="l00520"></a>00520             _contents = CABackingStoreCreate();
<a name="l00521"></a>00521     
<a name="l00522"></a>00522         CABackingStoreSetSize(_contents, _bounds.size);
<a name="l00523"></a>00523             
<a name="l00524"></a>00524         [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aae7b9db1917a37a0fbd35692276ada5a">drawInContext</a>:CABackingStoreGetContext(_contents)];
<a name="l00525"></a>00525     }
<a name="l00526"></a>00526         
<a name="l00527"></a>00527     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a0ca648303d1edf497cb522400afff95c">composite</a>];
<a name="l00528"></a>00528 }
<a name="l00529"></a>00529 
<a name="l00534"></a><a class="code" href="class_c_a_layer.html#aae7b9db1917a37a0fbd35692276ada5a">00534</a> - (void)drawInContext:(CGContext)aContext
<a name="l00535"></a>00535 {   <span class="comment">//if (!window.loop || window.nodisplay) CPLog.error(&quot;htiasd&quot;);</span>
<a name="l00536"></a>00536     <span class="keywordflow">if</span> (_backgroundColor)
<a name="l00537"></a>00537     {
<a name="l00538"></a>00538         <a class="code" href="group__coregraphics.html#ga800a3e5b0c46359d28b091376630bb0e">CGContextSetFillColor</a>(aContext, _backgroundColor);
<a name="l00539"></a>00539         <a class="code" href="group__coregraphics.html#ga74c13e165c00cc434a54bb8c2148e1ba">CGContextFillRect</a>(aContext, _bounds);
<a name="l00540"></a>00540     }
<a name="l00541"></a>00541     
<a name="l00542"></a>00542     <span class="keywordflow">if</span> (_delegateRespondsToDrawLayerInContextSelector)
<a name="l00543"></a>00543         [_delegate drawLayer:self inContext:aContext];
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 
<a name="l00546"></a>00546 
<a name="l00547"></a>00547 <span class="comment">// Style Attributes</span>
<a name="l00552"></a><a class="code" href="class_c_a_layer.html#a94162c4e99563bbdc4dc1ca776bd2ab9">00552</a> <span class="comment"></span>- (float)opacity
<a name="l00553"></a>00553 {
<a name="l00554"></a>00554     <span class="keywordflow">return</span> _opacity;
<a name="l00555"></a>00555 }
<a name="l00556"></a>00556 
<a name="l00561"></a><a class="code" href="class_c_a_layer.html#a4166632f6706a9028a3a43eed9b646d1">00561</a> - (void)setOpacity:(<span class="keywordtype">float</span>)anOpacity
<a name="l00562"></a>00562 {
<a name="l00563"></a>00563     <span class="keywordflow">if</span> (_opacity == anOpacity)
<a name="l00564"></a>00564         <span class="keywordflow">return</span>;
<a name="l00565"></a>00565     
<a name="l00566"></a>00566     _opacity = anOpacity;
<a name="l00567"></a>00567     
<a name="l00568"></a>00568     _DOMElement.style.opacity = anOpacity;
<a name="l00569"></a>00569     _DOMElement.style.filter = <span class="stringliteral">&quot;alpha(opacity=&quot;</span> + anOpacity * 100 + <span class="stringliteral">&quot;)&quot;</span>;
<a name="l00570"></a>00570 }
<a name="l00571"></a>00571 
<a name="l00576"></a><a class="code" href="class_c_a_layer.html#af4d75e6699c3bc53248bc96f422de327">00576</a> - (void)setHidden:(BOOL)isHidden
<a name="l00577"></a>00577 {
<a name="l00578"></a>00578     _isHidden = isHidden;
<a name="l00579"></a>00579     _DOMElement.style.display = isHidden ? <span class="stringliteral">&quot;none&quot;</span> : <span class="stringliteral">&quot;block&quot;</span>;
<a name="l00580"></a>00580 }
<a name="l00581"></a>00581 
<a name="l00585"></a><a class="code" href="class_c_a_layer.html#aeeda6cac50848a84b2cdbf84eaa69400">00585</a> - (BOOL)hidden
<a name="l00586"></a>00586 {
<a name="l00587"></a>00587     <span class="keywordflow">return</span> _isHidden;
<a name="l00588"></a>00588 }
<a name="l00589"></a>00589 
<a name="l00593"></a><a class="code" href="class_c_a_layer.html#a66a927d05868179a9c993abe50b35f96">00593</a> - (BOOL)isHidden
<a name="l00594"></a>00594 {
<a name="l00595"></a>00595     <span class="keywordflow">return</span> _isHidden;
<a name="l00596"></a>00596 }
<a name="l00597"></a>00597 
<a name="l00602"></a><a class="code" href="class_c_a_layer.html#a3bd6c0754ecad30e49098491baa82d41">00602</a> - (void)setMasksToBounds:(BOOL)masksToBounds
<a name="l00603"></a>00603 {
<a name="l00604"></a>00604     <span class="keywordflow">if</span> (_masksToBounds == masksToBounds)
<a name="l00605"></a>00605         <span class="keywordflow">return</span>;
<a name="l00606"></a>00606     
<a name="l00607"></a>00607     _masksToBounds = masksToBounds;
<a name="l00608"></a>00608     _DOMElement.style.overflow = _masksToBounds ? <span class="stringliteral">&quot;hidden&quot;</span> : <span class="stringliteral">&quot;visible&quot;</span>;
<a name="l00609"></a>00609 }
<a name="l00610"></a>00610 
<a name="l00615"></a><a class="code" href="class_c_a_layer.html#a48f508ebdf9fb5ecb21042d691734a62">00615</a> - (void)setBackgroundColor:(<a class="code" href="class_c_p_color.html">CPColor</a>)aColor
<a name="l00616"></a>00616 {
<a name="l00617"></a>00617     _backgroundColor = aColor;
<a name="l00618"></a>00618     
<a name="l00619"></a>00619     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a3e6e077d5d09abe55d41c4a83ba958a2">setNeedsDisplay</a>];
<a name="l00620"></a>00620 }
<a name="l00621"></a>00621 
<a name="l00625"></a><a class="code" href="class_c_a_layer.html#ad1ae877c80904a4a727516d74755fbb2">00625</a> - (<a class="code" href="class_c_p_color.html">CPColor</a>)backgroundColor
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627     <span class="keywordflow">return</span> _backgroundColor;
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629 
<a name="l00630"></a>00630 <span class="comment">// Managing Layer Hierarchy</span>
<a name="l00634"></a><a class="code" href="class_c_a_layer.html#a6be4902ae5344bb33854c8b2d4bea365">00634</a> <span class="comment"></span>- (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sublayers
<a name="l00635"></a>00635 {
<a name="l00636"></a>00636     <span class="keywordflow">return</span> _sublayers;
<a name="l00637"></a>00637 }
<a name="l00638"></a>00638 
<a name="l00642"></a><a class="code" href="class_c_a_layer.html#a878e05181085d8860efd761330581032">00642</a> - (<a class="code" href="class_c_a_layer.html">CALayer</a>)superlayer
<a name="l00643"></a>00643 {
<a name="l00644"></a>00644     <span class="keywordflow">return</span> _superlayer;
<a name="l00645"></a>00645 }
<a name="l00646"></a>00646 
<a name="l00647"></a><a class="code" href="_c_a_layer_8j.html#a15cb1b6757121dfb227d46b0ce0f963f">00647</a> <span class="preprocessor">#define ADJUST_CONTENTS_ZINDEX(aLayer)\</span>
<a name="l00648"></a>00648 <span class="preprocessor">if (_DOMContentsElement &amp;&amp; aLayer._zPosition &gt; _DOMContentsElement.style.zIndex)\</span>
<a name="l00649"></a>00649 <span class="preprocessor">    _DOMContentsElement.style.zIndex -= 100.0;\</span>
<a name="l00650"></a>00650 <span class="preprocessor"></span>
<a name="l00651"></a>00651 <span class="preprocessor"></span>
<a name="l00654"></a><a class="code" href="class_c_a_layer.html#a95257f5a715860bcd54873ba587aa313">00654</a> - (void)addSublayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00655"></a>00655 {
<a name="l00656"></a>00656     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a3c7393fe4e971c94c8a3fa34de834a52">insertSublayer</a>:aLayer <a class="code" href="class_c_a_layer.html#a3c7393fe4e971c94c8a3fa34de834a52">atIndex</a>:_sublayers.length];
<a name="l00657"></a>00657     <span class="keywordflow">return</span>;
<a name="l00658"></a>00658     <a class="code" href="_c_a_layer_8j.html#a15cb1b6757121dfb227d46b0ce0f963f">ADJUST_CONTENTS_ZINDEX</a>(aLayer);
<a name="l00659"></a>00659 
<a name="l00660"></a>00660     [_sublayers addObject:aLayer];
<a name="l00661"></a>00661     _DOMElement.appendChild(<a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">DOM</a>(aLayer));
<a name="l00662"></a>00662 }
<a name="l00663"></a>00663 
<a name="l00667"></a><a class="code" href="class_c_a_layer.html#a6f2751f0279b5cb2584f76afeaefffc2">00667</a> - (void)removeFromSuperlayer
<a name="l00668"></a>00668 {
<a name="l00669"></a>00669     <span class="keywordflow">if</span> (_owningView)
<a name="l00670"></a>00670         [_owningView setLayer:nil];
<a name="l00671"></a>00671     
<a name="l00672"></a>00672     <span class="keywordflow">if</span> (!_superlayer)
<a name="l00673"></a>00673         <span class="keywordflow">return</span>;
<a name="l00674"></a>00674         
<a name="l00675"></a>00675     _superlayer._DOMElement.removeChild(_DOMElement);
<a name="l00676"></a>00676     [_superlayer._sublayers removeObject:self];
<a name="l00677"></a>00677 
<a name="l00678"></a>00678     _superlayer = nil;
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00686"></a><a class="code" href="class_c_a_layer.html#a3c7393fe4e971c94c8a3fa34de834a52">00686</a> - (void)insertSublayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer atIndex:(<span class="keywordtype">unsigned</span>)anIndex
<a name="l00687"></a>00687 {
<a name="l00688"></a>00688     <span class="keywordflow">if</span> (!aLayer)
<a name="l00689"></a>00689         <span class="keywordflow">return</span>;
<a name="l00690"></a>00690     
<a name="l00691"></a>00691     var superlayer = [aLayer <a class="code" href="class_c_a_layer.html#a878e05181085d8860efd761330581032">superlayer</a>];
<a name="l00692"></a>00692     
<a name="l00693"></a>00693     <span class="keywordflow">if</span> (superlayer == <span class="keyword">self</span>)
<a name="l00694"></a>00694     {
<a name="l00695"></a>00695         var index = [_sublayers indexOfObjectIdenticalTo:aLayer];
<a name="l00696"></a>00696 
<a name="l00697"></a>00697         <span class="keywordflow">if</span> (index == anIndex)
<a name="l00698"></a>00698             <span class="keywordflow">return</span>;
<a name="l00699"></a>00699     
<a name="l00700"></a>00700         [_sublayers removeObjectAtIndex:index];
<a name="l00701"></a>00701         
<a name="l00702"></a>00702         <span class="keywordflow">if</span> (index &lt; anIndex)
<a name="l00703"></a>00703             --anIndex;
<a name="l00704"></a>00704     }
<a name="l00705"></a>00705     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (superlayer != nil)
<a name="l00706"></a>00706         [aLayer <a class="code" href="class_c_a_layer.html#a6f2751f0279b5cb2584f76afeaefffc2">removeFromSuperlayer</a>];
<a name="l00707"></a>00707     
<a name="l00708"></a>00708     <a class="code" href="_c_a_layer_8j.html#a15cb1b6757121dfb227d46b0ce0f963f">ADJUST_CONTENTS_ZINDEX</a>(aLayer);
<a name="l00709"></a>00709 
<a name="l00710"></a>00710     [_sublayers insertObject:aLayer atIndex:anIndex];
<a name="l00711"></a>00711 
<a name="l00712"></a>00712     <span class="keywordflow">if</span> (anIndex &gt;= _sublayers.length - 1)
<a name="l00713"></a>00713         _DOMElement.appendChild(<a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">DOM</a>(aLayer));
<a name="l00714"></a>00714     <span class="keywordflow">else</span>
<a name="l00715"></a>00715         _DOMElement.insertBefore(<a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">DOM</a>(aLayer), _sublayers[anIndex + 1]._DOMElement);
<a name="l00716"></a>00716         
<a name="l00717"></a>00717     aLayer._superlayer = <span class="keyword">self</span>;
<a name="l00718"></a>00718     
<a name="l00719"></a>00719     <span class="keywordflow">if</span> (<span class="keyword">self</span> != superlayer)
<a name="l00720"></a>00720         _CALayerRecalculateGeometry(aLayer, 0xFFFFFFF);
<a name="l00721"></a>00721 }
<a name="l00722"></a>00722 
<a name="l00729"></a><a class="code" href="class_c_a_layer.html#aba70f97c973ed09c1a4d4f34093536d5">00729</a> - (void)insertSublayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer below:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aSublayer
<a name="l00730"></a>00730 {
<a name="l00731"></a>00731     var index = aSublayer ? [_sublayers indexOfObjectIdenticalTo:aSublayer] : 0;
<a name="l00732"></a>00732     
<a name="l00733"></a>00733     [<span class="keyword">self</span> insertSublayer:aLayer atIndex:index == CPNotFound ? _sublayers.length : index];
<a name="l00734"></a>00734 }
<a name="l00735"></a>00735 
<a name="l00742"></a><a class="code" href="class_c_a_layer.html#afe54d7bab3347c2c4c66b634aac5c0fd">00742</a> - (void)insertSublayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer above:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aSublayer
<a name="l00743"></a>00743 {
<a name="l00744"></a>00744     var index = aSublayer ? [_sublayers indexOfObjectIdenticalTo:aSublayer] : _sublayers.length;
<a name="l00745"></a>00745     <span class="keywordflow">if</span> (index == <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l00746"></a>00746         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:&quot;CALayerNotFoundException&quot; <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;aSublayer is not a sublayer of this layer&quot;];
<a name="l00747"></a>00747 
<a name="l00748"></a>00748     [_sublayers insertObject:aLayer atIndex:index == CPNotFound ? _sublayers.length : index + 1];
<a name="l00749"></a>00749 }
<a name="l00750"></a>00750 
<a name="l00756"></a><a class="code" href="class_c_a_layer.html#a9b25eaf30ce84908a46fb9e4d20bcd73">00756</a> - (void)replaceSublayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aSublayer with:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00757"></a>00757 {
<a name="l00758"></a>00758     <span class="keywordflow">if</span> (aSublayer == aLayer)
<a name="l00759"></a>00759         <span class="keywordflow">return</span>;
<a name="l00760"></a>00760     
<a name="l00761"></a>00761     <span class="comment">// FIXME: EXCEPTION</span>
<a name="l00762"></a>00762     <span class="keywordflow">if</span> (aSublayer._superlayer != <span class="keyword">self</span>)
<a name="l00763"></a>00763     {
<a name="l00764"></a>00764         alert(<span class="stringliteral">&quot;EXCEPTION&quot;</span>);
<a name="l00765"></a>00765         <span class="keywordflow">return</span>;
<a name="l00766"></a>00766     }
<a name="l00767"></a>00767     
<a name="l00768"></a>00768     <a class="code" href="_c_a_layer_8j.html#a15cb1b6757121dfb227d46b0ce0f963f">ADJUST_CONTENTS_ZINDEX</a>(aLayer);
<a name="l00769"></a>00769     
<a name="l00770"></a>00770     [_sublayers replaceObjectAtIndex:[_sublayers indexOfObjectIdenticalTo:aSublayer] withObject:aLayer];
<a name="l00771"></a>00771     _DOMElement.replaceChild(<a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">DOM</a>(aSublayer), <a class="code" href="_c_a_layer_8j.html#aac46d63213c27c242670119b099448c4">DOM</a>(aLayer));
<a name="l00772"></a>00772 }
<a name="l00773"></a>00773 
<a name="l00774"></a>00774 <span class="comment">// Updating Layer Display</span>
<a name="l00775"></a>00775 <span class="comment">/*</span>
<a name="l00776"></a>00776 <span class="comment">    Updates the layers on screen.</span>
<a name="l00777"></a>00777 <span class="comment">    @ignore</span>
<a name="l00778"></a>00778 <span class="comment">*/</span>
<a name="l00779"></a><a class="code" href="class_c_a_layer.html#a8b5708ea5c69eba93e91d2104adf3789">00779</a> + (void)runLoopUpdateLayers
<a name="l00780"></a>00780 {
<a name="l00781"></a>00781     <span class="keywordflow">for</span> (UID in <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a>)
<a name="l00782"></a>00782     {
<a name="l00783"></a>00783         var layer = <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a>[UID],
<a name="l00784"></a>00784             mask = layer._runLoopUpdateMask;
<a name="l00785"></a>00785 
<a name="l00786"></a>00786         <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#a13368e69c48203d60d0e8eba3a151791">CALayerDOMUpdateMask</a>)
<a name="l00787"></a>00787             _CALayerUpdateDOM(layer, mask);
<a name="l00788"></a>00788         
<a name="l00789"></a>00789         <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#aea3fa0c520450b903260bc7d7d91e873">CALayerDisplayUpdateMask</a>)
<a name="l00790"></a>00790             [layer display];
<a name="l00791"></a>00791         
<a name="l00792"></a>00792         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">CALayerFrameSizeUpdateMask</a> || mask &amp; <a class="code" href="_c_a_layer_8j.html#a0d8d5fbf9708caaee8b1b1147e7ed988">CALayerCompositeUpdateMask</a>)
<a name="l00793"></a>00793             [layer composite];
<a name="l00794"></a>00794             
<a name="l00795"></a>00795         layer._runLoopUpdateMask = 0;
<a name="l00796"></a>00796     }
<a name="l00797"></a>00797     window.loop= <span class="keyword">false</span>;
<a name="l00798"></a>00798     <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a> = nil;
<a name="l00799"></a>00799 }
<a name="l00800"></a>00800 
<a name="l00801"></a>00801 <span class="comment">/*</span>
<a name="l00802"></a>00802 <span class="comment">    @ignore</span>
<a name="l00803"></a>00803 <span class="comment">*/</span>
<a name="l00804"></a><a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">00804</a> - (void)registerRunLoopUpdateWithMask:(<span class="keywordtype">unsigned</span>)anUpdateMask
<a name="l00805"></a>00805 {
<a name="l00806"></a>00806     <span class="keywordflow">if</span> (<a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a> == nil)
<a name="l00807"></a>00807     {
<a name="l00808"></a>00808         <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a> = {};
<a name="l00809"></a>00809         
<a name="l00810"></a>00810         [[<a class="code" href="class_c_p_run_loop.html" title="The main run loop for the application.">CPRunLoop</a> <a class="code" href="class_c_p_run_loop.html#aba93f1cef957bad4353ce060981c0b9d">currentRunLoop</a>] <a class="code" href="class_c_p_run_loop.html#a2b3b2247377a11043079b7949523156e">performSelector</a>:@selector(runLoopUpdateLayers)
<a name="l00811"></a>00811             <a class="code" href="class_c_p_run_loop.html#a2b3b2247377a11043079b7949523156e">target</a>:CALayer <a class="code" href="class_c_p_run_loop.html#a2b3b2247377a11043079b7949523156e">argument</a>:nil <a class="code" href="class_c_p_run_loop.html#a2b3b2247377a11043079b7949523156e">order</a>:0 <a class="code" href="class_c_p_run_loop.html#a2b3b2247377a11043079b7949523156e">modes</a>:[CPDefaultRunLoopMode]];
<a name="l00812"></a>00812     }
<a name="l00813"></a>00813     
<a name="l00814"></a>00814     _runLoopUpdateMask |= anUpdateMask;
<a name="l00815"></a>00815     <a class="code" href="_c_a_layer_8j.html#aa5c21f4390935ff640bffb4758e73603">CALayerRegisteredRunLoopUpdates</a>[[<span class="keyword">self</span> UID]] = <span class="keyword">self</span>;
<a name="l00816"></a>00816 }
<a name="l00817"></a>00817 
<a name="l00818"></a>00818 <span class="comment">/*</span>
<a name="l00819"></a>00819 <span class="comment">    @ignore</span>
<a name="l00820"></a>00820 <span class="comment">*/</span>
<a name="l00821"></a><a class="code" href="class_c_a_layer.html#a9c0c8c3d8dceff2a9dcc8c2b671c5b05">00821</a> - (void)setNeedsComposite
<a name="l00822"></a>00822 {
<a name="l00823"></a>00823     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerCompositeUpdateMask];
<a name="l00824"></a>00824 }
<a name="l00825"></a>00825 
<a name="l00829"></a><a class="code" href="class_c_a_layer.html#a3e6e077d5d09abe55d41c4a83ba958a2">00829</a> - (void)setNeedsDisplay
<a name="l00830"></a>00830 {
<a name="l00831"></a>00831     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerDisplayUpdateMask];
<a name="l00832"></a>00832 }
<a name="l00833"></a>00833 
<a name="l00838"></a><a class="code" href="class_c_a_layer.html#a23334a5dae089c3c757d2296e59a6748">00838</a> - (void)setNeedsDisplayOnBoundsChange:(BOOL)needsDisplayOnBoundsChange
<a name="l00839"></a>00839 {
<a name="l00840"></a>00840     _needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
<a name="l00841"></a>00841 }
<a name="l00842"></a>00842 
<a name="l00846"></a><a class="code" href="class_c_a_layer.html#a56af4982ce5f2166f4d0197d993216bc">00846</a> - (BOOL)needsDisplayOnBoundsChange
<a name="l00847"></a>00847 {
<a name="l00848"></a>00848     <span class="keywordflow">return</span> _needsDisplayOnBoundsChange;
<a name="l00849"></a>00849 }
<a name="l00850"></a>00850 
<a name="l00855"></a><a class="code" href="class_c_a_layer.html#aa35dd2b1254d2370842988a6f8198e12">00855</a> - (void)setNeedsDisplayInRect:(CGRect)aRect
<a name="l00856"></a>00856 {
<a name="l00857"></a>00857     _dirtyRect = aRect;
<a name="l00858"></a>00858     [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a7557b5b724e9fb8d705d9978cd31e760">display</a>];
<a name="l00859"></a>00859 }
<a name="l00860"></a>00860 
<a name="l00861"></a>00861 <span class="comment">// Mapping Between Coordinate and Time Spaces</span>
<a name="l00868"></a><a class="code" href="class_c_a_layer.html#a51d6f867f01acff491583d31ca58aa31">00868</a> <span class="comment"></span>- (CGPoint)convertPoint:(CGPoint)aPoint fromLayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00869"></a>00869 {
<a name="l00870"></a>00870     <span class="keywordflow">return</span> <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(aPoint, _CALayerGetTransform(aLayer, <span class="keyword">self</span>));
<a name="l00871"></a>00871 }
<a name="l00872"></a>00872 
<a name="l00879"></a><a class="code" href="class_c_a_layer.html#afd17be5c9be8946ce3cec5094bdc85d3">00879</a> - (CGPoint)convertPoint:(CGPoint)aPoint toLayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00880"></a>00880 {
<a name="l00881"></a>00881     <span class="keywordflow">return</span> <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(aPoint, _CALayerGetTransform(<span class="keyword">self</span>, aLayer));
<a name="l00882"></a>00882 }
<a name="l00883"></a>00883 
<a name="l00890"></a><a class="code" href="class_c_a_layer.html#ac02eb35f98056ecaaf29a66ad581a8c4">00890</a> - (CGRect)convertRect:(CGRect)aRect fromLayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00891"></a>00891 {
<a name="l00892"></a>00892     <span class="keywordflow">return</span> <a class="code" href="_c_g_affine_transform_8j.html#aa2cac55239f169c578848a871f67fcb2">CGRectApplyAffineTransform</a>(aRect, _CALayerGetTransform(aLayer, <span class="keyword">self</span>));
<a name="l00893"></a>00893 }
<a name="l00894"></a>00894 
<a name="l00901"></a><a class="code" href="class_c_a_layer.html#ab3ef6728f2afc9408da351267ef975b2">00901</a> - (CGRect)convertRect:(CGRect)aRect toLayer:(<a class="code" href="class_c_a_layer.html">CALayer</a>)aLayer
<a name="l00902"></a>00902 {
<a name="l00903"></a>00903     <span class="keywordflow">return</span> <a class="code" href="_c_g_affine_transform_8j.html#aa2cac55239f169c578848a871f67fcb2">CGRectApplyAffineTransform</a>(aRect, _CALayerGetTransform(<span class="keyword">self</span>, aLayer));
<a name="l00904"></a>00904 }
<a name="l00905"></a>00905 
<a name="l00906"></a>00906 <span class="comment">// Hit Testing</span>
<a name="l00911"></a><a class="code" href="class_c_a_layer.html#a3f4549769d61d6d0fe981eb9c79a617e">00911</a> <span class="comment"></span>- (BOOL)containsPoint:(CGPoint)aPoint
<a name="l00912"></a>00912 {
<a name="l00913"></a>00913     <span class="keywordflow">return</span> _CGRectContainsPoint(_bounds, aPoint);
<a name="l00914"></a>00914 }
<a name="l00915"></a>00915 
<a name="l00921"></a><a class="code" href="class_c_a_layer.html#ac2545c848c05b2e1a1fecb0aa9d54aed">00921</a> - (<a class="code" href="class_c_a_layer.html">CALayer</a>)hitTest:(CGPoint)aPoint
<a name="l00922"></a>00922 {
<a name="l00923"></a>00923     <span class="keywordflow">if</span> (_isHidden)
<a name="l00924"></a>00924         <span class="keywordflow">return</span> nil;
<a name="l00925"></a>00925     
<a name="l00926"></a>00926     var point = <a class="code" href="_c_g_affine_transform_8j.html#ab2e1fbd101ea6fc5c3d4cff1f59d7e36">CGPointApplyAffineTransform</a>(aPoint, _transformToLayer);
<a name="l00927"></a>00927     <span class="comment">//alert(point.x + &quot; &quot; + point.y);</span>
<a name="l00928"></a>00928     
<a name="l00929"></a>00929     <span class="keywordflow">if</span> (!_CGRectContainsPoint(_bounds, point))
<a name="l00930"></a>00930         <span class="keywordflow">return</span> nil;
<a name="l00931"></a>00931     
<a name="l00932"></a>00932     var layer = nil,
<a name="l00933"></a>00933         index = _sublayers.length;
<a name="l00934"></a>00934     
<a name="l00935"></a>00935     <span class="comment">// FIXME: this should take into account zPosition.</span>
<a name="l00936"></a>00936     <span class="keywordflow">while</span> (index--)
<a name="l00937"></a>00937         <span class="keywordflow">if</span> (layer = [_sublayers[index] hitTest:point])
<a name="l00938"></a>00938             <span class="keywordflow">return</span> layer;
<a name="l00939"></a>00939             
<a name="l00940"></a>00940     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00941"></a>00941 }
<a name="l00942"></a>00942 
<a name="l00943"></a>00943 <span class="comment">// Modifying the Delegate</span>
<a name="l00948"></a><a class="code" href="class_c_a_layer.html#a6c363814185fd280be2854d98ce9a19f">00948</a> <span class="comment"></span>- (void)setDelegate:(<span class="keywordtype">id</span>)aDelegate
<a name="l00949"></a>00949 {
<a name="l00950"></a>00950     <span class="keywordflow">if</span> (_delegate == aDelegate)
<a name="l00951"></a>00951         <span class="keywordflow">return</span>;
<a name="l00952"></a>00952     
<a name="l00953"></a>00953     _delegate = aDelegate;
<a name="l00954"></a>00954     
<a name="l00955"></a>00955     _delegateRespondsToDisplayLayerSelector         = [_delegate respondsToSelector:@selector(displayLayer:)];
<a name="l00956"></a>00956     _delegateRespondsToDrawLayerInContextSelector   = [_delegate respondsToSelector:@selector(drawLayer:inContext:)];
<a name="l00957"></a>00957     
<a name="l00958"></a>00958     <span class="keywordflow">if</span> (_delegateRespondsToDisplayLayerSelector || _delegateRespondsToDrawLayerInContextSelector)
<a name="l00959"></a>00959         [<span class="keyword">self</span> <a class="code" href="class_c_a_layer.html#a3e6e077d5d09abe55d41c4a83ba958a2">setNeedsDisplay</a>];
<a name="l00960"></a>00960 }
<a name="l00961"></a>00961 
<a name="l00965"></a><a class="code" href="class_c_a_layer.html#a503336c74ba6380d15e58223c2e6287c">00965</a> - (id)delegate
<a name="l00966"></a>00966 {
<a name="l00967"></a>00967     <span class="keywordflow">return</span> _delegate;
<a name="l00968"></a>00968 }
<a name="l00969"></a>00969 
<a name="l00970"></a>00970 <span class="comment">/* @ignore */</span>
<a name="l00971"></a>00971 - (void)_setOwningView:(<a class="code" href="class_c_p_view.html">CPView</a>)anOwningView
<a name="l00972"></a>00972 {
<a name="l00973"></a>00973     _owningView = anOwningView;
<a name="l00974"></a>00974     
<a name="l00975"></a>00975     <span class="keywordflow">if</span> (_owningView)
<a name="l00976"></a>00976     {
<a name="l00977"></a>00977         _owningView = anOwningView;
<a name="l00978"></a>00978         
<a name="l00979"></a>00979         _bounds.size = <a class="code" href="_c_g_geometry_8j.html#affb0172e44ea288a2660c9a5394db33a">CGSizeMakeCopy</a>([_owningView bounds].<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>);
<a name="l00980"></a>00980         _position = <a class="code" href="_c_g_geometry_8j.html#a06c96cb5931220da52ff44b8ce9b603e">CGPointMake</a>(_CGRectGetWidth(_bounds) * _anchorPoint.x, _CGRectGetHeight(_bounds) * _anchorPoint.y);
<a name="l00981"></a>00981     }
<a name="l00982"></a>00982     
<a name="l00983"></a>00983     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">CALayerGeometryPositionMask</a> | <a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">CALayerGeometryBoundsMask</a>);
<a name="l00984"></a>00984 }
<a name="l00985"></a>00985 
<a name="l00986"></a>00986 <span class="comment">/* @ignore */</span>
<a name="l00987"></a>00987 - (void)_owningViewBoundsChanged
<a name="l00988"></a>00988 {
<a name="l00989"></a>00989     _bounds.size = <a class="code" href="_c_g_geometry_8j.html#affb0172e44ea288a2660c9a5394db33a">CGSizeMakeCopy</a>([_owningView bounds].<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>);
<a name="l00990"></a>00990     _position = <a class="code" href="_c_g_geometry_8j.html#a06c96cb5931220da52ff44b8ce9b603e">CGPointMake</a>(_CGRectGetWidth(_bounds) * _anchorPoint.x, _CGRectGetHeight(_bounds) * _anchorPoint.y);
<a name="l00991"></a>00991         
<a name="l00992"></a>00992     _CALayerRecalculateGeometry(<span class="keyword">self</span>, <a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">CALayerGeometryPositionMask</a> | <a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">CALayerGeometryBoundsMask</a>);
<a name="l00993"></a>00993 }
<a name="l00994"></a>00994 
<a name="l00995"></a>00995 <span class="comment">/* @ignore */</span>
<a name="l00996"></a>00996 - (void)_update
<a name="l00997"></a>00997 {
<a name="l00998"></a>00998     window.loop = <span class="keyword">true</span>;
<a name="l00999"></a>00999     
<a name="l01000"></a>01000     var mask = _runLoopUpdateMask;
<a name="l01001"></a>01001 
<a name="l01002"></a>01002     <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#a13368e69c48203d60d0e8eba3a151791">CALayerDOMUpdateMask</a>)
<a name="l01003"></a>01003         _CALayerUpdateDOM(<span class="keyword">self</span>, mask);
<a name="l01004"></a>01004     
<a name="l01005"></a>01005     <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#aea3fa0c520450b903260bc7d7d91e873">CALayerDisplayUpdateMask</a>)
<a name="l01006"></a>01006         [<span class="keyword">self</span> display];
<a name="l01007"></a>01007     
<a name="l01008"></a>01008     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mask &amp; <a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">CALayerFrameSizeUpdateMask</a> || mask &amp; <a class="code" href="_c_a_layer_8j.html#a0d8d5fbf9708caaee8b1b1147e7ed988">CALayerCompositeUpdateMask</a>)
<a name="l01009"></a>01009         [<span class="keyword">self</span> composite];
<a name="l01010"></a>01010         
<a name="l01011"></a>01011     _runLoopUpdateMask = 0;
<a name="l01012"></a>01012     
<a name="l01013"></a>01013     window.loop = <span class="keyword">false</span>;
<a name="l01014"></a>01014 }
<a name="l01015"></a>01015 
<a name="l01016"></a>01016 <span class="keyword">@end</span>
<a name="l01017"></a>01017 
<a name="l01018"></a>01018 function _CALayerUpdateSublayerTransformForSublayers(aLayer)
<a name="l01019"></a>01019 {
<a name="l01020"></a>01020     var bounds = aLayer._bounds,
<a name="l01021"></a>01021         anchorPoint = aLayer._anchorPoint,
<a name="l01022"></a>01022         translateX = _CGRectGetWidth(bounds) * anchorPoint.x,
<a name="l01023"></a>01023         translateY = _CGRectGetHeight(bounds) * anchorPoint.y;
<a name="l01024"></a>01024     
<a name="l01025"></a>01025     aLayer._sublayerTransformForSublayers = <a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(
<a name="l01026"></a>01026         <a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">CGAffineTransformMakeTranslation</a>(-translateX, -translateY),
<a name="l01027"></a>01027         <a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(aLayer._sublayerTransform,
<a name="l01028"></a>01028         <a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">CGAffineTransformMakeTranslation</a>(translateX, translateY)));
<a name="l01029"></a>01029 }
<a name="l01030"></a>01030 
<a name="l01031"></a>01031 function _CALayerUpdateDOM(aLayer, aMask)
<a name="l01032"></a>01032 {
<a name="l01033"></a>01033     var DOMElementStyle = aLayer._DOMElement.style;
<a name="l01034"></a>01034     
<a name="l01035"></a>01035     <span class="keywordflow">if</span> (aMask &amp; <a class="code" href="_c_a_layer_8j.html#acd4260da148e61285fdf91c10bf2e661">CALayerZPositionUpdateMask</a>)
<a name="l01036"></a>01036         DOMElementStyle.zIndex = aLayer._zPosition;
<a name="l01037"></a>01037     
<a name="l01038"></a>01038     var <a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a> = aLayer._backingStoreFrame;
<a name="l01039"></a>01039     
<a name="l01040"></a>01040     <span class="keywordflow">if</span> (aMask &amp; <a class="code" href="_c_a_layer_8j.html#aaf1285d3b64e902c2c83bb85b7937e31">CALayerFrameOriginUpdateMask</a>)
<a name="l01041"></a>01041     {
<a name="l01042"></a>01042         DOMElementStyle.top = ROUND(_CGRectGetMinY(frame)) + &quot;px&quot;;
<a name="l01043"></a>01043         DOMElementStyle.left = ROUND(_CGRectGetMinX(frame)) + &quot;px&quot;;
<a name="l01044"></a>01044     }
<a name="l01045"></a>01045     
<a name="l01046"></a>01046     <span class="keywordflow">if</span> (aMask &amp; <a class="code" href="_c_a_layer_8j.html#a59e67f97b348d19a1eedb5fc71c97132">CALayerFrameSizeUpdateMask</a>)
<a name="l01047"></a>01047     {
<a name="l01048"></a>01048         var <a class="code" href="_c_p_segmented_control_8j.html#a2474a5474cbff19523a51eb1de01cda4">width</a> = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(0.0, ROUND(_CGRectGetWidth(frame))),
<a name="l01049"></a>01049             <a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a> = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(0.0, ROUND(_CGRectGetHeight(frame))),
<a name="l01050"></a>01050             DOMContentsElement = aLayer._DOMContentsElement;
<a name="l01051"></a>01051             
<a name="l01052"></a>01052         DOMElementStyle.width = width + &quot;px&quot;;
<a name="l01053"></a>01053         DOMElementStyle.height = <a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a> + &quot;px&quot;;
<a name="l01054"></a>01054         
<a name="l01055"></a>01055         <span class="keywordflow">if</span> (DOMContentsElement)
<a name="l01056"></a>01056         {
<a name="l01057"></a>01057             DOMContentsElement.width = width;
<a name="l01058"></a>01058             DOMContentsElement.height = <a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a>;
<a name="l01059"></a>01059             DOMContentsElement.style.width = width + &quot;px&quot;;
<a name="l01060"></a>01060             DOMContentsElement.style.height = <a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a> + &quot;px&quot;;
<a name="l01061"></a>01061         }
<a name="l01062"></a>01062     }
<a name="l01063"></a>01063 }
<a name="l01064"></a>01064 
<a name="l01065"></a>01065 function _CALayerRecalculateGeometry(aLayer, aGeometryChange)
<a name="l01066"></a>01066 {
<a name="l01067"></a>01067     var bounds = aLayer._bounds,
<a name="l01068"></a>01068         superlayer = aLayer._superlayer,
<a name="l01069"></a>01069         width = _CGRectGetWidth(bounds),
<a name="l01070"></a>01070         <a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a> = _CGRectGetHeight(bounds),
<a name="l01071"></a>01071         position = aLayer._position,
<a name="l01072"></a>01072         anchorPoint = aLayer._anchorPoint,
<a name="l01073"></a>01073         affineTransform = aLayer._affineTransform,
<a name="l01074"></a>01074         backingStoreFrameSize = _CGSizeMakeCopy(aLayer._backingStoreFrame),
<a name="l01075"></a>01075         hasCustomBackingStoreFrame = aLayer._hasCustomBackingStoreFrame;
<a name="l01076"></a>01076     
<a name="l01077"></a>01077     <span class="comment">// Go to anchor, transform, go back to bounds.</span>
<a name="l01078"></a>01078     aLayer._transformFromLayer =  <a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(
<a name="l01079"></a>01079         <a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">CGAffineTransformMakeTranslation</a>(-width * anchorPoint.x - _CGRectGetMinX(aLayer._bounds), -<a class="code" href="_c_p_screen_8j.html#a4540395d130d8a367becfe06b659b9f1">height</a> * anchorPoint.y - _CGRectGetMinY(aLayer._bounds)),
<a name="l01080"></a>01080         <a class="code" href="_c_g_affine_transform_8j.html#af365049e43d927195c26bd0352a1116f">CGAffineTransformConcat</a>(affineTransform,
<a name="l01081"></a>01081         <a class="code" href="_c_g_affine_transform_8j.html#af409e88c81cd51e67ad1b9c36ac8a3a1">CGAffineTransformMakeTranslation</a>(position.x, position.y)));
<a name="l01082"></a>01082 
<a name="l01083"></a>01083     <span class="keywordflow">if</span> (superlayer &amp;&amp; superlayer._hasSublayerTransform)
<a name="l01084"></a>01084     {
<a name="l01085"></a>01085         <span class="comment">// aLayer._transformFromLayer = CGAffineTransformConcat(aLayer._transformFromLayer, superlayer._sublayerTransformForSublayers);</span>
<a name="l01086"></a>01086         _CGAffineTransformConcatTo(aLayer._transformFromLayer, superlayer._sublayerTransformForSublayers, aLayer._transformFromLayer);
<a name="l01087"></a>01087     }
<a name="l01088"></a>01088         
<a name="l01089"></a>01089     aLayer._transformToLayer = <a class="code" href="_c_g_affine_transform_8j.html#a7fbeeee49fbad301876a71a146f7995a">CGAffineTransformInvert</a>(aLayer._transformFromLayer);
<a name="l01090"></a>01090 
<a name="l01091"></a>01091     <span class="comment">//aLayer._transformFromLayer.tx = ROUND(aLayer._transformFromLayer.tx);</span>
<a name="l01092"></a>01092     <span class="comment">//aLayer._transformFromLayer.ty = ROUND(aLayer._transformFromLayer.ty);</span>
<a name="l01093"></a>01093     
<a name="l01094"></a>01094     aLayer._frame = nil;
<a name="l01095"></a>01095     aLayer._standardBackingStoreFrame = [aLayer <a class="code" href="class_c_a_layer.html#ab3ef6728f2afc9408da351267ef975b2">convertRect</a>:bounds <a class="code" href="class_c_a_layer.html#ab3ef6728f2afc9408da351267ef975b2">toLayer</a>:nil];
<a name="l01096"></a>01096     
<a name="l01097"></a>01097     <span class="keywordflow">if</span> (superlayer)
<a name="l01098"></a>01098     {
<a name="l01099"></a>01099         var bounds = [superlayer bounds],
<a name="l01100"></a>01100             frame = [superlayer convertRect:bounds toLayer:nil];
<a name="l01101"></a>01101         
<a name="l01102"></a>01102         aLayer._standardBackingStoreFrame.origin.x -= _CGRectGetMinX(frame);
<a name="l01103"></a>01103         aLayer._standardBackingStoreFrame.origin.y -= _CGRectGetMinY(frame);
<a name="l01104"></a>01104     }
<a name="l01105"></a>01105 
<a name="l01106"></a>01106     <span class="comment">// We used to use CGRectIntegral here, but what we actually want, is the largest integral</span>
<a name="l01107"></a>01107     <span class="comment">// rect that would ever contain this box, since for any width/height, there are 2 (4) </span>
<a name="l01108"></a>01108     <span class="comment">// possible integral rects for it depending on it&apos;s position.  It&apos;s OK that this is sometimes</span>
<a name="l01109"></a>01109     <span class="comment">// bigger than the &quot;optimal&quot; bounding integral rect since that doesn&apos;t change drawing.</span>
<a name="l01110"></a>01110     
<a name="l01111"></a>01111     var origin = aLayer._standardBackingStoreFrame.origin,
<a name="l01112"></a>01112         <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a> = aLayer._standardBackingStoreFrame.size;
<a name="l01113"></a>01113     
<a name="l01114"></a>01114     origin.x = FLOOR(origin.x);
<a name="l01115"></a>01115     origin.y = FLOOR(origin.y);
<a name="l01116"></a>01116     <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width = CEIL(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width) + 1.0;
<a name="l01117"></a>01117     <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height = CEIL(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height) + 1.0;
<a name="l01118"></a>01118     
<a name="l01119"></a>01119     <span class="comment">// FIXME: This avoids the central issue that a position change is sometimes a display and sometimes</span>
<a name="l01120"></a>01120     <span class="comment">// a div move, and sometimes both.</span>
<a name="l01121"></a>01121     
<a name="l01122"></a>01122     <span class="comment">// Only use this frame if we don&apos;t currently have a custom backing store frame.</span>
<a name="l01123"></a>01123     <span class="keywordflow">if</span> (!hasCustomBackingStoreFrame)
<a name="l01124"></a>01124     {
<a name="l01125"></a>01125         var backingStoreFrame = <a class="code" href="_c_g_geometry_8j.html#a7521362038d81fa55cafbd6da5130335">CGRectMakeCopy</a>(aLayer._standardBackingStoreFrame);
<a name="l01126"></a>01126         
<a name="l01127"></a>01127         <span class="comment">// These values get rounded in the DOM, so don&apos;t both updating them if they&apos;re </span>
<a name="l01128"></a>01128         <span class="comment">// not going to be different after rounding.</span>
<a name="l01129"></a>01129         <span class="keywordflow">if</span> (ROUND(_CGRectGetMinX(backingStoreFrame)) != ROUND(_CGRectGetMinX(aLayer._backingStoreFrame)) ||
<a name="l01130"></a>01130             ROUND(_CGRectGetMinY(backingStoreFrame)) != ROUND(_CGRectGetMinY(aLayer._backingStoreFrame)))
<a name="l01131"></a>01131             [aLayer <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerFrameOriginUpdateMask];
<a name="l01132"></a>01132         
<a name="l01133"></a>01133         <span class="comment">// Any change in size due to a geometry change is purely due to rounding error.</span>
<a name="l01134"></a>01134         <span class="keywordflow">if</span> ((_CGRectGetWidth(backingStoreFrame) != ROUND(_CGRectGetWidth(aLayer._backingStoreFrame)) ||
<a name="l01135"></a>01135             _CGRectGetHeight(backingStoreFrame) != ROUND(_CGRectGetHeight(aLayer._backingStoreFrame))))
<a name="l01136"></a>01136             [aLayer <a class="code" href="class_c_a_layer.html#aab185cf261d3daf9e101e7b787421632">registerRunLoopUpdateWithMask</a>:CALayerFrameSizeUpdateMask];
<a name="l01137"></a>01137         
<a name="l01138"></a>01138         aLayer._backingStoreFrame = backingStoreFrame;
<a name="l01139"></a>01139     }
<a name="l01140"></a>01140 
<a name="l01141"></a>01141     <span class="keywordflow">if</span> (aGeometryChange &amp; <a class="code" href="_c_a_layer_8j.html#a9d7b1c58912534373644657a8e532d5c">CALayerGeometryBoundsMask</a> &amp;&amp; aLayer._needsDisplayOnBoundsChange)
<a name="l01142"></a>01142         [aLayer <a class="code" href="class_c_a_layer.html#a3e6e077d5d09abe55d41c4a83ba958a2">setNeedsDisplay</a>];
<a name="l01143"></a>01143     <span class="comment">// We need to recomposite if we have a custom backing store frame, OR</span>
<a name="l01144"></a>01144     <span class="comment">// If the change is not solely composed of position and anchor points changes.</span>
<a name="l01145"></a>01145     <span class="comment">// Anchor point and position changes simply move the object, requiring </span>
<a name="l01146"></a>01146     <span class="comment">// no re-rendering.</span>
<a name="l01147"></a>01147     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (hasCustomBackingStoreFrame || (aGeometryChange &amp; ~(<a class="code" href="_c_a_layer_8j.html#ac9837ddcbab2fccd293e6c8d9a5d78b3">CALayerGeometryPositionMask</a> | <a class="code" href="_c_a_layer_8j.html#a4481f9da252746e5b81eb67af6f9d0f8">CALayerGeometryAnchorPointMask</a>)))
<a name="l01148"></a>01148         [aLayer <a class="code" href="class_c_a_layer.html#a9c0c8c3d8dceff2a9dcc8c2b671c5b05">setNeedsComposite</a>];
<a name="l01149"></a>01149         
<a name="l01150"></a>01150     var sublayers = aLayer._sublayers,
<a name="l01151"></a>01151         index = 0,
<a name="l01152"></a>01152         count = sublayers.length;
<a name="l01153"></a>01153 
<a name="l01154"></a>01154     <span class="keywordflow">for</span> (; index &lt; count; ++index)
<a name="l01155"></a>01155         _CALayerRecalculateGeometry(sublayers[index], aGeometryChange);
<a name="l01156"></a>01156 }
<a name="l01157"></a>01157 
<a name="l01158"></a>01158 function _CALayerGetTransform(fromLayer, toLayer)
<a name="l01159"></a>01159 {
<a name="l01160"></a>01160     var transform = <a class="code" href="_c_g_affine_transform_8j.html#a072cf7a76d169af4182cf37674381d04">CGAffineTransformMakeIdentity</a>();
<a name="l01161"></a>01161     
<a name="l01162"></a>01162     <span class="keywordflow">if</span> (fromLayer)
<a name="l01163"></a>01163     {
<a name="l01164"></a>01164         var layer = fromLayer;
<a name="l01165"></a>01165         
<a name="l01166"></a>01166         <span class="comment">// If we have a fromLayer, &quot;climb up&quot; the layer tree until </span>
<a name="l01167"></a>01167         <span class="comment">// we hit the root node or we hit the toLayer.</span>
<a name="l01168"></a>01168         <span class="keywordflow">while</span> (layer &amp;&amp; layer != toLayer)
<a name="l01169"></a>01169         {
<a name="l01170"></a>01170             var transformFromLayer = layer._transformFromLayer;
<a name="l01171"></a>01171             
<a name="l01172"></a>01172             <span class="comment">//transform = CGAffineTransformConcat(transform, layer._transformFromLayer);</span>
<a name="l01173"></a>01173             _CGAffineTransformConcatTo(transform, transformFromLayer, transform);
<a name="l01174"></a>01174             
<a name="l01175"></a>01175             layer = layer._superlayer;
<a name="l01176"></a>01176         }
<a name="l01177"></a>01177         
<a name="l01178"></a>01178         <span class="comment">// If we hit toLayer, then we&apos;re done.</span>
<a name="l01179"></a>01179         <span class="keywordflow">if</span> (layer == toLayer)
<a name="l01180"></a>01180             <span class="keywordflow">return</span> transform;
<a name="l01181"></a>01181     }
<a name="l01182"></a>01182     
<a name="l01183"></a>01183     var layers = [],
<a name="l01184"></a>01184         layer = toLayer;
<a name="l01185"></a>01185     
<a name="l01186"></a>01186     <span class="keywordflow">while</span> (layer)
<a name="l01187"></a>01187     {
<a name="l01188"></a>01188         layers.push(layer);
<a name="l01189"></a>01189         layer = layer._superlayer;
<a name="l01190"></a>01190     }
<a name="l01191"></a>01191     
<a name="l01192"></a>01192     var index = layers.length;
<a name="l01193"></a>01193     
<a name="l01194"></a>01194     <span class="keywordflow">while</span> (index--)
<a name="l01195"></a>01195     {
<a name="l01196"></a>01196         var transformToLayer = layers[index]._transformToLayer;
<a name="l01197"></a>01197         
<a name="l01198"></a>01198         _CGAffineTransformConcatTo(transform, transformToLayer, transform);
<a name="l01199"></a>01199     }
<a name="l01200"></a>01200     
<a name="l01201"></a>01201     <span class="keywordflow">return</span> transform;
<a name="l01202"></a>01202 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:54 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_a_layer_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:28 GMT -->
</html>