Returns Canvas that draws into Surface. Subsequent calls return the same Canvas. Canvas returned is managed and owned by Surface, and is deleted when Surface is deleted. @return Canvas for Surface
()
| 659 | * @return Canvas for Surface |
| 660 | */ |
| 661 | @NotNull |
| 662 | public Canvas getCanvas() { |
| 663 | try { |
| 664 | if (_canvas == null) { |
| 665 | Stats.onNativeCall(); |
| 666 | long ptr = _nGetCanvas(_ptr); |
| 667 | _canvas = ptr == 0 ? null : new Canvas(ptr, false, this); |
| 668 | } |
| 669 | return _canvas; |
| 670 | } finally { |
| 671 | ReferenceUtil.reachabilityFence(this); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * <p>Returns a compatible Surface, or null.</p> |