Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: runtime/embedders/openglui/common/gl.dart

Issue 13345002: Cleaned up OpenGLUI samples and added Blasteroids. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library android_extension; 5 library android_extension;
6 import 'dart:async'; 6 import 'dart:async';
7 7
8 // A VERY simplified DOM. 8 // A VERY simplified DOM.
9 9
10 class BodyElement { 10 class BodyElement {
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 class Float32Array extends List<double> { 570 class Float32Array extends List<double> {
571 Float32Array.fromList(List a) { 571 Float32Array.fromList(List a) {
572 addAll(a); 572 addAll(a);
573 } 573 }
574 } 574 }
575 575
576 //------------------------------------------------------------------ 576 //------------------------------------------------------------------
577 // 2D canvas support 577 // 2D canvas support
578 578
579 int SetWidth(int handle, int width) 579 int _SetWidth(int handle, int width)
580 native "CanvasSetWidth"; 580 native "C2DSetWidth";
581 int SetHeight(int handle, int height) 581 int _SetHeight(int handle, int height)
582 native "CanvasSetHeight"; 582 native "C2DSetHeight";
583 583
584 double SetGlobalAlpha(int handle, double globalAlpha) 584 double _SetGlobalAlpha(int handle, double globalAlpha)
585 native "CanvasSetGlobalAlpha"; 585 native "C2DSetGlobalAlpha";
586 void SetFillStyle(int handle, fs) 586 void _SetFillStyle(int handle, fs)
587 native "CanvasSetFillStyle"; 587 native "C2DSetFillStyle";
588 String SetFont(int handle, String font) 588 String _SetFont(int handle, String font)
589 native "CanvasSetFont"; 589 native "C2DSetFont";
590 void SetGlobalCompositeOperation(int handle, String op) 590 void _SetGlobalCompositeOperation(int handle, String op)
591 native "CanvasSetGlobalCompositeOperation"; 591 native "C2DSetGlobalCompositeOperation";
592 SetLineCap(int handle, String lc) 592 _SetLineCap(int handle, String lc)
593 native "CanvasSetLineCap"; 593 native "C2DSetLineCap";
594 SetLineJoin(int handle, String lj) 594 _SetLineJoin(int handle, String lj)
595 native "CanvasSetLineJoin"; 595 native "C2DSetLineJoin";
596 SetLineWidth(int handle, double w) 596 _SetLineWidth(int handle, double w)
597 native "CanvasSetLineWidth"; 597 native "C2DSetLineWidth";
598 SetMiterLimit(int handle, double limit) 598 _SetMiterLimit(int handle, double limit)
599 native "CanvasSetMiterLimit"; 599 native "C2DSetMiterLimit";
600 SetShadowBlur(int handle, double blur) 600 _SetShadowBlur(int handle, double blur)
601 native "CanvasSetShadowBlur"; 601 native "C2DSetShadowBlur";
602 SetShadowColor(int handle, String color) 602 _SetShadowColor(int handle, String color)
603 native "CanvasSetShadowColor"; 603 native "C2DSetShadowColor";
604 SetShadowOffsetX(int handle, double offset) 604 _SetShadowOffsetX(int handle, double offset)
605 native "CanvasSetShadowOffsetX"; 605 native "C2DSetShadowOffsetX";
606 SetShadowOffsetY(int handle, double offset) 606 _SetShadowOffsetY(int handle, double offset)
607 native "CanvasSetShadowOffsetY"; 607 native "C2DSetShadowOffsetY";
608 void SetStrokeStyle(int handle, ss) 608 void _SetStrokeStyle(int handle, ss)
609 native "CanvasSetStrokeStyle"; 609 native "C2DSetStrokeStyle";
610 String SetTextAlign(int handle, String align) 610 String _SetTextAlign(int handle, String align)
611 native "CanvasSetTextAlign"; 611 native "C2DSetTextAlign";
612 String SetTextBaseline(int handle, String baseline) 612 String _SetTextBaseline(int handle, String baseline)
613 native "CanvasSetTextBaseline"; 613 native "C2DSetTextBaseline";
614 GetBackingStorePixelRatio(int handle) 614 _GetBackingStorePixelRatio(int handle)
615 native "CanvasGetBackingStorePixelRatio"; 615 native "C2DGetBackingStorePixelRatio";
616 void SetImageSmoothingEnabled(int handle, bool ise) 616 void _SetImageSmoothingEnabled(int handle, bool ise)
617 native "CanvasSetImageSmoothingEnabled"; 617 native "C2DSetImageSmoothingEnabled";
618 void SetLineDash(int handle, List v) 618 void _SetLineDash(int handle, List v)
619 native "CanvasSetLineDash"; 619 native "C2DSetLineDash";
620 SetLineDashOffset(int handle, int v) 620 _SetLineDashOffset(int handle, int v)
621 native "CanvasSetLineDashOffset"; 621 native "C2DSetLineDashOffset";
622 void Arc(int handle, double x, double y, double radius, 622 void _Arc(int handle, double x, double y, double radius,
623 double startAngle, double endAngle, [bool anticlockwise = false]) 623 double startAngle, double endAngle, [bool anticlockwise = false])
624 native "CanvasArc"; 624 native "C2DArc";
625 void ArcTo(int handle, double x1, double y1, 625 void _ArcTo(int handle, double x1, double y1,
626 double x2, double y2, double radius) 626 double x2, double y2, double radius)
627 native "CanvasArcTo"; 627 native "C2DArcTo";
628 void ArcTo2(int handle, double x1, double y1, 628 void _ArcTo2(int handle, double x1, double y1,
629 double x2, double y2, double radiusX, 629 double x2, double y2, double radiusX,
630 double radiusY, double rotation) 630 double radiusY, double rotation)
631 native "CanvasArcTo2"; 631 native "C2DArcTo2";
632 void BeginPath(int handle) 632 void _BeginPath(int handle)
633 native "CanvasBeginPath"; 633 native "C2DBeginPath";
634 void BezierCurveTo(int handle, double cp1x, double cp1y, 634 void _BezierCurveTo(int handle, double cp1x, double cp1y,
635 double cp2x, double cp2y, double x, double y) 635 double cp2x, double cp2y, double x, double y)
636 native "CanvasBezierCurveTo"; 636 native "C2DBezierCurveTo";
637 void ClearRect(int handle, double x, double y, double w, double h) 637 void _ClearRect(int handle, double x, double y, double w, double h)
638 native "CanvasClearRect"; 638 native "C2DClearRect";
639 void Clip(int handle) 639 void _Clip(int handle)
640 native "CanvasClip"; 640 native "C2DClip";
641 void ClosePath(int handle) 641 void _ClosePath(int handle)
642 native "CanvasClosePath"; 642 native "C2DClosePath";
643 ImageData CreateImageDataFromDimensions(int handle, num w, num h) 643 ImageData _CreateImageDataFromDimensions(int handle, num w, num h)
644 native "CanvasCreateImageDataFromDimensions"; 644 native "C2DCreateImageDataFromDimensions";
645 void DrawImage(int handle, String src_url, 645 void _DrawImage(int handle, String src_url,
646 int sx, int sy, 646 int sx, int sy,
647 bool has_src_dimensions, int sw, int sh, 647 bool has_src_dimensions, int sw, int sh,
648 int dx, int dy, 648 int dx, int dy,
649 bool has_dst_dimensions, int dw, int dh) 649 bool has_dst_dimensions, int dw, int dh)
650 native "CanvasDrawImage"; 650 native "C2DDrawImage";
651 void Fill(int handle) 651 void _Fill(int handle)
652 native "CanvasFill"; 652 native "C2DFill";
653 void FillRect(int handle, double x, double y, double w, double h) 653 void _FillRect(int handle, double x, double y, double w, double h)
654 native "CanvasFillRect"; 654 native "C2DFillRect";
655 void FillText(int handle, String text, double x, double y, double maxWidth) 655 void _FillText(int handle, String text, double x, double y, double maxWidth)
656 native "CanvasFillText"; 656 native "C2DFillText";
657 ImageData GetImageData(num sx, num sy, num sw, num sh) 657 ImageData _GetImageData(num sx, num sy, num sw, num sh)
658 native "CanvasGetImageData"; 658 native "C2DGetImageData";
659 void LineTo(int handle, double x, double y) 659 void _LineTo(int handle, double x, double y)
660 native "CanvasLineTo"; 660 native "C2DLineTo";
661 double MeasureText(int handle, String text) 661 double _MeasureText(int handle, String text)
662 native "CanvasMeasureText"; 662 native "C2DMeasureText";
663 void MoveTo(int handle, double x, double y) 663 void _MoveTo(int handle, double x, double y)
664 native "CanvasMoveTo"; 664 native "C2DMoveTo";
665 void PutImageData(int handle, ImageData imagedata, double dx, double dy) 665 void _PutImageData(int handle, ImageData imagedata, double dx, double dy)
666 native "CanvasPutImageData"; 666 native "C2DPutImageData";
667 void QuadraticCurveTo(int handle, double cpx, double cpy, 667 void _QuadraticCurveTo(int handle, double cpx, double cpy,
668 double x, double y) 668 double x, double y)
669 native "CanvasQuadraticCurveTo"; 669 native "C2DQuadraticCurveTo";
670 void Rect(int handle, double x, double y, double w, double h) 670 void _Rect(int handle, double x, double y, double w, double h)
671 native "CanvasRect"; 671 native "C2DRect";
672 void Restore(int handle) 672 void _Restore(int handle)
673 native "CanvasRestore"; 673 native "C2DRestore";
674 void Rotate(int handle, double a) 674 void _Rotate(int handle, double a)
675 native "CanvasRotate"; 675 native "C2DRotate";
676 void Save(int handle) 676 void _Save(int handle)
677 native "CanvasSave"; 677 native "C2DSave";
678 void Scale(int handle, double sx, double sy) 678 void _Scale(int handle, double sx, double sy)
679 native "CanvasScale"; 679 native "C2DScale";
680 void SetTransform(int handle, double m11, double m12, 680 void _SetTransform(int handle, double m11, double m12,
681 double m21, double m22, double dx, double dy) 681 double m21, double m22, double dx, double dy)
682 native "CanvasSetTransform"; 682 native "C2DSetTransform";
683 void Stroke(int handle) 683 void _Stroke(int handle)
684 native "CanvasStroke"; 684 native "C2DStroke";
685 void StrokeRect(int handle, double x, double y, double w, double h) 685 void _StrokeRect(int handle, double x, double y, double w, double h)
686 native "CanvasStrokeRect"; 686 native "C2DStrokeRect";
687 void StrokeText(int handle, String text, double x, double y, 687 void _StrokeText(int handle, String text, double x, double y,
688 double maxWidth) 688 double maxWidth)
689 native "CanvasStrokeText"; 689 native "C2DStrokeText";
690 void Transform(int handle, double m11, double m12, 690 void _Transform(int handle, double m11, double m12,
691 double m21, double m22, double dx, double dy) 691 double m21, double m22, double dx, double dy)
692 native "CanvasTransform"; 692 native "C2DTransform";
693 void Translate(int handle, double x, double y) 693 void _Translate(int handle, double x, double y)
694 native "CanvasTranslate"; 694 native "C2DTranslate";
695 695
696 void CreateNativeContext(int handle, int width, int height) 696 void _CreateNativeContext(int handle, int width, int height)
697 native "CanvasCreateNativeContext"; 697 native "C2DCreateNativeContext";
698 698
699 void SetFillGradient(int handle, bool isRadial, 699 void _SetFillGradient(int handle, bool isRadial,
700 double x0, double y0, double r0, 700 double x0, double y0, double r0,
701 double x1, double y1, double r1, 701 double x1, double y1, double r1,
702 List<double> positions, List<String> colors) 702 List<double> positions, List<String> colors)
703 native "CanvasSetFillGradient"; 703 native "C2DSetFillGradient";
704 704
705 void SetStrokeGradient(int handle, bool isRadial, 705 void _SetStrokeGradient(int handle, bool isRadial,
706 double x0, double y0, double r0, 706 double x0, double y0, double r0,
707 double x1, double y1, double r1, 707 double x1, double y1, double r1,
708 List<double> positions, List<String> colors) 708 List<double> positions, List<String> colors)
709 native "CanvasSetStrokeGradient"; 709 native "C2DSetStrokeGradient";
710 710
711 int GetImageWidth(String url) 711 int _GetImageWidth(String url)
712 native "CanvasGetImageWidth"; 712 native "C2DGetImageWidth";
713 713
714 int GetImageHeight(String url) 714 int _GetImageHeight(String url)
715 native "CanvasGetImageHeight"; 715 native "C2DGetImageHeight";
716 716
717 class CanvasGradient { 717 class CanvasGradient {
718 num _x0, _y0, _r0 = 0, _x1, _y1, _r1 = 0; 718 num _x0, _y0, _r0 = 0, _x1, _y1, _r1 = 0;
719 bool _isRadial; 719 bool _isRadial;
720 List<double> _colorStopPositions = []; 720 List<double> _colorStopPositions = [];
721 List<String> _colorStopColors = []; 721 List<String> _colorStopColors = [];
722 722
723 void addColorStop(num offset, String color) { 723 void addColorStop(num offset, String color) {
724 _colorStopPositions.add(offset.toDouble()); 724 _colorStopPositions.add(offset.toDouble());
725 _colorStopColors.add(color); 725 _colorStopColors.add(color);
726 } 726 }
727 727
728 CanvasGradient.linear(this._x0, this._y0, this._x1, this._y1) 728 CanvasGradient.linear(this._x0, this._y0, this._x1, this._y1)
729 : _isRadial = false; 729 : _isRadial = false;
730 730
731 CanvasGradient.radial(this._x0, this._y0, this._r0, 731 CanvasGradient.radial(this._x0, this._y0, this._r0,
732 this._x1, this._y1, this._r1) 732 this._x1, this._y1, this._r1)
733 : _isRadial = true; 733 : _isRadial = true;
734 734
735 void setAsFillStyle(_handle) { 735 void setAsFillStyle(_handle) {
736 SetFillGradient(_handle, _isRadial, 736 _SetFillGradient(_handle, _isRadial,
737 _x0.toDouble(), _y0.toDouble(), _r0.toDouble(), 737 _x0.toDouble(), _y0.toDouble(), _r0.toDouble(),
738 _x1.toDouble(), _y1.toDouble(), _r1.toDouble(), 738 _x1.toDouble(), _y1.toDouble(), _r1.toDouble(),
739 _colorStopPositions, _colorStopColors); 739 _colorStopPositions, _colorStopColors);
740 } 740 }
741 741
742 void setAsStrokeStyle(_handle) { 742 void setAsStrokeStyle(_handle) {
743 SetStrokeGradient(_handle, _isRadial, 743 _SetStrokeGradient(_handle, _isRadial,
744 _x0.toDouble(), _y0.toDouble(), _r0.toDouble(), 744 _x0.toDouble(), _y0.toDouble(), _r0.toDouble(),
745 _x1.toDouble(), _y1.toDouble(), _r1.toDouble(), 745 _x1.toDouble(), _y1.toDouble(), _r1.toDouble(),
746 _colorStopPositions, _colorStopColors); 746 _colorStopPositions, _colorStopColors);
747 } 747 }
748 } 748 }
749 749
750 class ImageElement extends Node { 750 class ImageElement extends Node {
751 Stream<Event> get onLoad => new _EventStream(this, 'load'); 751 Stream<Event> get onLoad => new _EventStream(this, 'load');
752 752
753 String _src; 753 String _src;
(...skipping 11 matching lines...) Expand all
765 // we hook into that here... 765 // we hook into that here...
766 void addListener(String eventType, EventListener handler) { 766 void addListener(String eventType, EventListener handler) {
767 super.addListener(eventType, handler); 767 super.addListener(eventType, handler);
768 if (eventType == 'load') { 768 if (eventType == 'load') {
769 var e = new Event('load'); 769 var e = new Event('load');
770 e.target = this; 770 e.target = this;
771 window._scheduleCallback(handler, e); 771 window._scheduleCallback(handler, e);
772 } 772 }
773 } 773 }
774 774
775 get width => _width == null ? _width = GetImageWidth(_src) : _width; 775 get width => _width == null ? _width = _GetImageWidth(_src) : _width;
776 get height => _height == null ? _height = GetImageHeight(_src) : _height; 776 get height => _height == null ? _height = _GetImageHeight(_src) : _height;
777 set width(int widthp) => _width = widthp; 777 set width(int widthp) => _width = widthp;
778 set height(int heightp) => _height = heightp; 778 set height(int heightp) => _height = heightp;
779 779
780 ImageElement({String srcp, int widthp, int heightp}) 780 ImageElement({String srcp, int widthp, int heightp})
781 : _src = srcp, 781 : _src = srcp,
782 _width = widthp, 782 _width = widthp,
783 _height = heightp { 783 _height = heightp {
784 if (_src != null) { 784 if (_src != null) {
785 if (_width == null) _width = GetImageWidth(_src); 785 if (_width == null) _width = _GetImageWidth(_src);
786 if (_height == null) _height = GetImageHeight(_src); 786 if (_height == null) _height = _GetImageHeight(_src);
787 } 787 }
788 } 788 }
789 } 789 }
790 790
791 class ImageData { 791 class ImageData {
792 final Uint8ClampedArray data; 792 final Uint8ClampedArray data;
793 final int height; 793 final int height;
794 final int width; 794 final int width;
795 ImageData(this.height, this.width, this.data); 795 ImageData(this.height, this.width, this.data);
796 } 796 }
(...skipping 22 matching lines...) Expand all
819 819
820 int _width, _height; 820 int _width, _height;
821 set width(int w) { _width = SetWidth(_handle, w); } 821 set width(int w) { _width = SetWidth(_handle, w); }
822 get width => _width; 822 get width => _width;
823 set height(int h) { _height = SetHeight(_handle, h); } 823 set height(int h) { _height = SetHeight(_handle, h); }
824 get height => _height; 824 get height => _height;
825 825
826 CanvasRenderingContext2D(canvas, width, height) : super(canvas) { 826 CanvasRenderingContext2D(canvas, width, height) : super(canvas) {
827 _width = width; 827 _width = width;
828 _height = height; 828 _height = height;
829 CreateNativeContext(_handle = next_handle++, width, height); 829 _CreateNativeContext(_handle = next_handle++, width, height);
830 } 830 }
831 831
832 double _alpha = 1.0; 832 double _alpha = 1.0;
833 set globalAlpha(num a) { 833 set globalAlpha(num a) {
834 _alpha = SetGlobalAlpha(_handle, a.toDouble()); 834 _alpha = _SetGlobalAlpha(_handle, a.toDouble());
835 } 835 }
836 get globalAlpha => _alpha; 836 get globalAlpha => _alpha;
837 837
838 // TODO(gram): make sure we support compound assignments like: 838 // TODO(gram): make sure we support compound assignments like:
839 // fillStyle = strokeStyle = "red" 839 // fillStyle = strokeStyle = "red"
840 var _fillStyle = "#000"; 840 var _fillStyle = "#000";
841 set fillStyle(fs) { 841 set fillStyle(fs) {
842 _fillStyle = fs; 842 _fillStyle = fs;
843 // TODO(gram): Support for CanvasPattern. 843 // TODO(gram): Support for CanvasPattern.
844 if (fs is CanvasGradient) { 844 if (fs is CanvasGradient) {
845 fs.setAsFillStyle(_handle); 845 fs.setAsFillStyle(_handle);
846 } else { 846 } else {
847 SetFillStyle(_handle, fs); 847 _SetFillStyle(_handle, fs);
848 } 848 }
849 } 849 }
850 get fillStyle => _fillStyle; 850 get fillStyle => _fillStyle;
851 851
852 String _font = "10px sans-serif"; 852 String _font = "10px sans-serif";
853 set font(String f) { _font = SetFont(_handle, f); } 853 set font(String f) { _font = _SetFont(_handle, f); }
854 get font => _font; 854 get font => _font;
855 855
856 String _globalCompositeOperation = "source-over"; 856 String _globalCompositeOperation = "source-over";
857 set globalCompositeOperation(String o) => 857 set globalCompositeOperation(String o) =>
858 SetGlobalCompositeOperation(_handle, _globalCompositeOperation = o); 858 _SetGlobalCompositeOperation(_handle, _globalCompositeOperation = o);
859 get globalCompositeOperation => _globalCompositeOperation; 859 get globalCompositeOperation => _globalCompositeOperation;
860 860
861 String _lineCap = "butt"; // "butt", "round", "square" 861 String _lineCap = "butt"; // "butt", "round", "square"
862 get lineCap => _lineCap; 862 get lineCap => _lineCap;
863 set lineCap(String lc) => SetLineCap(_handle, _lineCap = lc); 863 set lineCap(String lc) => _SetLineCap(_handle, _lineCap = lc);
864 864
865 int _lineDashOffset = 0; 865 int _lineDashOffset = 0;
866 get lineDashOffset => _lineDashOffset; 866 get lineDashOffset => _lineDashOffset;
867 set lineDashOffset(num v) { 867 set lineDashOffset(num v) {
868 _lineDashOffset = v.toInt(); 868 _lineDashOffset = v.toInt();
869 SetLineDashOffset(_handle, _lineDashOffset); 869 _SetLineDashOffset(_handle, _lineDashOffset);
870 } 870 }
871 871
872 String _lineJoin = "miter"; // "round", "bevel", "miter" 872 String _lineJoin = "miter"; // "round", "bevel", "miter"
873 get lineJoin => _lineJoin; 873 get lineJoin => _lineJoin;
874 set lineJoin(String lj) => SetLineJoin(_handle, _lineJoin = lj); 874 set lineJoin(String lj) => _SetLineJoin(_handle, _lineJoin = lj);
875 875
876 num _lineWidth = 1.0; 876 num _lineWidth = 1.0;
877 get lineWidth => _lineWidth; 877 get lineWidth => _lineWidth;
878 set lineWidth(num w) { 878 set lineWidth(num w) {
879 SetLineWidth(_handle, w.toDouble()); 879 _SetLineWidth(_handle, w.toDouble());
880 _lineWidth = w; 880 _lineWidth = w;
881 } 881 }
882 882
883 num _miterLimit = 10.0; // (default 10) 883 num _miterLimit = 10.0; // (default 10)
884 get miterLimit => _miterLimit; 884 get miterLimit => _miterLimit;
885 set miterLimit(num limit) { 885 set miterLimit(num limit) {
886 SetMiterLimit(_handle, limit.toDouble()); 886 _SetMiterLimit(_handle, limit.toDouble());
887 _miterLimit = limit; 887 _miterLimit = limit;
888 } 888 }
889 889
890 num _shadowBlur; 890 num _shadowBlur;
891 get shadowBlur => _shadowBlur; 891 get shadowBlur => _shadowBlur;
892 set shadowBlur(num blur) { 892 set shadowBlur(num blur) {
893 _shadowBlur = blur; 893 _shadowBlur = blur;
894 SetShadowBlur(_handle, blur.toDouble()); 894 _SetShadowBlur(_handle, blur.toDouble());
895 } 895 }
896 896
897 String _shadowColor; 897 String _shadowColor;
898 get shadowColor => _shadowColor; 898 get shadowColor => _shadowColor;
899 set shadowColor(String color) => 899 set shadowColor(String color) =>
900 SetShadowColor(_handle, _shadowColor = color); 900 _SetShadowColor(_handle, _shadowColor = color);
901 901
902 num _shadowOffsetX; 902 num _shadowOffsetX;
903 get shadowOffsetX => _shadowOffsetX; 903 get shadowOffsetX => _shadowOffsetX;
904 set shadowOffsetX(num offset) { 904 set shadowOffsetX(num offset) {
905 _shadowOffsetX = offset; 905 _shadowOffsetX = offset;
906 SetShadowOffsetX(_handle, offset.toDouble()); 906 _SetShadowOffsetX(_handle, offset.toDouble());
907 } 907 }
908 908
909 num _shadowOffsetY; 909 num _shadowOffsetY;
910 get shadowOffsetY => _shadowOffsetY; 910 get shadowOffsetY => _shadowOffsetY;
911 set shadowOffsetY(num offset) { 911 set shadowOffsetY(num offset) {
912 _shadowOffsetY = offset; 912 _shadowOffsetY = offset;
913 SetShadowOffsetY(_handle, offset.toDouble()); 913 _SetShadowOffsetY(_handle, offset.toDouble());
914 } 914 }
915 915
916 var _strokeStyle = "#000"; 916 var _strokeStyle = "#000";
917 get strokeStyle => _strokeStyle; 917 get strokeStyle => _strokeStyle;
918 set strokeStyle(ss) { 918 set strokeStyle(ss) {
919 _strokeStyle = ss; 919 _strokeStyle = ss;
920 // TODO(gram): Support for CanvasPattern. 920 // TODO(gram): Support for CanvasPattern.
921 if (ss is CanvasGradient) { 921 if (ss is CanvasGradient) {
922 ss.setAsStrokeStyle(_handle); 922 ss.setAsStrokeStyle(_handle);
923 } else { 923 } else {
924 SetStrokeStyle(_handle, ss); 924 _SetStrokeStyle(_handle, ss);
925 } 925 }
926 } 926 }
927 927
928 String _textAlign = "start"; 928 String _textAlign = "start";
929 get textAlign => _textAlign; 929 get textAlign => _textAlign;
930 set textAlign(String a) { _textAlign = SetTextAlign(_handle, a); } 930 set textAlign(String a) { _textAlign = _SetTextAlign(_handle, a); }
931 931
932 String _textBaseline = "alphabetic"; 932 String _textBaseline = "alphabetic";
933 get textBaseline => _textBaseline; 933 get textBaseline => _textBaseline;
934 set textBaseline(String b) { _textBaseline = SetTextBaseline(_handle, b); } 934 set textBaseline(String b) { _textBaseline = _SetTextBaseline(_handle, b); }
935 935
936 get webkitBackingStorePixelRatio => GetBackingStorePixelRatio(_handle); 936 get webkitBackingStorePixelRatio => _GetBackingStorePixelRatio(_handle);
937 937
938 bool _webkitImageSmoothingEnabled; 938 bool _webkitImageSmoothingEnabled;
939 get webkitImageSmoothingEnabled => _webkitImageSmoothingEnabled; 939 get webkitImageSmoothingEnabled => _webkitImageSmoothingEnabled;
940 set webkitImageSmoothingEnabled(bool v) => 940 set webkitImageSmoothingEnabled(bool v) =>
941 SetImageSmoothingEnabled(_webkitImageSmoothingEnabled = v); 941 _SetImageSmoothingEnabled(_webkitImageSmoothingEnabled = v);
942 942
943 get webkitLineDash => lineDash; 943 get webkitLineDash => lineDash;
944 set webkitLineDash(List v) => lineDash = v; 944 set webkitLineDash(List v) => lineDash = v;
945 945
946 get webkitLineDashOffset => lineDashOffset; 946 get webkitLineDashOffset => lineDashOffset;
947 set webkitLineDashOffset(num v) => lineDashOffset = v; 947 set webkitLineDashOffset(num v) => lineDashOffset = v;
948 948
949 // Methods 949 // Methods
950 950
951 void arc(num x, num y, num radius, num a1, num a2, bool anticlockwise) { 951 void arc(num x, num y, num radius, num a1, num a2, bool anticlockwise) {
952 if (radius < 0) { 952 if (radius < 0) {
953 // throw IndexSizeError 953 // throw IndexSizeError
954 } else { 954 } else {
955 Arc(_handle, x.toDouble(), y.toDouble(), radius.toDouble(), 955 _Arc(_handle, x.toDouble(), y.toDouble(), radius.toDouble(),
956 a1.toDouble(), a2.toDouble(), anticlockwise); 956 a1.toDouble(), a2.toDouble(), anticlockwise);
957 } 957 }
958 } 958 }
959 959
960 // Note - looking at the Dart docs it seems Dart doesn't support 960 // Note - looking at the Dart docs it seems Dart doesn't support
961 // the second form in the browser. 961 // the second form in the browser.
962 void arcTo(num x1, num y1, num x2, num y2, 962 void arcTo(num x1, num y1, num x2, num y2,
963 num radiusX, [num radiusY, num rotation]) { 963 num radiusX, [num radiusY, num rotation]) {
964 if (radiusY == null) { 964 if (radiusY == null) {
965 ArcTo(_handle, x1.toDouble(), y1.toDouble(), 965 _ArcTo(_handle, x1.toDouble(), y1.toDouble(),
966 x2.toDouble(), y2.toDouble(), radiusX.toDouble()); 966 x2.toDouble(), y2.toDouble(), radiusX.toDouble());
967 } else { 967 } else {
968 ArcTo2(_handle, x1.toDouble(), y1.toDouble(), 968 _ArcTo2(_handle, x1.toDouble(), y1.toDouble(),
969 x2.toDouble(), y2.toDouble(), 969 x2.toDouble(), y2.toDouble(),
970 radiusX.toDouble(), radiusY.toDouble(), 970 radiusX.toDouble(), radiusY.toDouble(),
971 rotation.toDouble()); 971 rotation.toDouble());
972 } 972 }
973 } 973 }
974 974
975 void beginPath() => BeginPath(_handle); 975 void beginPath() => _BeginPath(_handle);
976 976
977 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, 977 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y,
978 num x, num y) => 978 num x, num y) =>
979 BezierCurveTo(_handle, cp1x.toDouble(), cp1y.toDouble(), 979 _BezierCurveTo(_handle, cp1x.toDouble(), cp1y.toDouble(),
980 cp2x.toDouble(), cp2y.toDouble(), 980 cp2x.toDouble(), cp2y.toDouble(),
981 x.toDouble(), y.toDouble()); 981 x.toDouble(), y.toDouble());
982 982
983 void clearRect(num x, num y, num w, num h) => 983 void clearRect(num x, num y, num w, num h) =>
984 ClearRect(_handle, x.toDouble(), y.toDouble(), 984 _ClearRect(_handle, x.toDouble(), y.toDouble(),
985 w.toDouble(), h.toDouble()); 985 w.toDouble(), h.toDouble());
986 986
987 void clip() => Clip(_handle); 987 void clip() => _Clip(_handle);
988 988
989 void closePath() => ClosePath(_handle); 989 void closePath() => _ClosePath(_handle);
990 990
991 ImageData createImageData(var imagedata_OR_sw, [num sh = null]) { 991 ImageData createImageData(var imagedata_OR_sw, [num sh = null]) {
992 if (sh == null) { 992 if (sh == null) {
993 throw new Exception('Unimplemented createImageData(imagedata)'); 993 throw new Exception('Unimplemented createImageData(imagedata)');
994 } else { 994 } else {
995 return CreateImageDataFromDimensions(_handle, imagedata_OR_sw, sh); 995 return _CreateImageDataFromDimensions(_handle, imagedata_OR_sw, sh);
996 } 996 }
997 } 997 }
998 998
999 CanvasGradient createLinearGradient(num x0, num y0, num x1, num y1) { 999 CanvasGradient createLinearGradient(num x0, num y0, num x1, num y1) {
1000 return new CanvasGradient.linear(x0, y0, x1, y1); 1000 return new CanvasGradient.linear(x0, y0, x1, y1);
1001 } 1001 }
1002 1002
1003 CanvasPattern createPattern(canvas_OR_image, String repetitionType) { 1003 CanvasPattern createPattern(canvas_OR_image, String repetitionType) {
1004 throw new Exception('Unimplemented createPattern'); 1004 throw new Exception('Unimplemented createPattern');
1005 } 1005 }
1006 1006
1007 CanvasGradient createRadialGradient(num x0, num y0, num r0, 1007 CanvasGradient createRadialGradient(num x0, num y0, num r0,
1008 num x1, num y1, num r1) { 1008 num x1, num y1, num r1) {
1009 return new CanvasGradient.radial(x0, y0, r0, x1, y1, r1); 1009 return new CanvasGradient.radial(x0, y0, r0, x1, y1, r1);
1010 } 1010 }
1011 1011
1012 void drawImage(element, num x1, num y1, 1012 void _drawImage(element, num x1, num y1,
1013 [num w1, num h1, num x2, num y2, num w2, num h2]) { 1013 [num w1, num h1, num x2, num y2, num w2, num h2]) {
1014 if (element == null || element.src == null || element.src.length == 0) { 1014 if (element == null || element.src == null || element.src.length == 0) {
1015 throw "drawImage called with no valid src"; 1015 throw "drawImage called with no valid src";
1016 } else { 1016 } else {
1017 log("drawImage ${element.src}"); 1017 log("drawImage ${element.src}");
1018 } 1018 }
1019 var w = (element.width == null) ? 0 : element.width; 1019 var w = (element.width == null) ? 0 : element.width;
1020 var h = (element.height == null) ? 0 : element.height; 1020 var h = (element.height == null) ? 0 : element.height;
1021 if (!?w1) { // drawImage(element, dx, dy) 1021 if (!?w1) { // drawImage(element, dx, dy)
1022 DrawImage(_handle, element.src, 0, 0, false, w, h, 1022 _DrawImage(_handle, element.src, 0, 0, false, w, h,
1023 x1.toInt(), y1.toInt(), false, 0, 0); 1023 x1.toInt(), y1.toInt(), false, 0, 0);
1024 } else if (!?x2) { // drawImage(element, dx, dy, dw, dh) 1024 } else if (!?x2) { // drawImage(element, dx, dy, dw, dh)
1025 DrawImage(_handle, element.src, 0, 0, false, w, h, 1025 _DrawImage(_handle, element.src, 0, 0, false, w, h,
1026 x1.toInt(), y1.toInt(), true, w1.toInt(), h1.toInt()); 1026 x1.toInt(), y1.toInt(), true, w1.toInt(), h1.toInt());
1027 } else { // drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) 1027 } else { // drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh)
1028 DrawImage(_handle, element.src, 1028 _DrawImage(_handle, element.src,
1029 x1.toInt(), y1.toInt(), true, w1.toInt(), h1.toInt(), 1029 x1.toInt(), y1.toInt(), true, w1.toInt(), h1.toInt(),
1030 x2.toInt(), y2.toInt(), true, w2.toInt(), h2.toInt()); 1030 x2.toInt(), y2.toInt(), true, w2.toInt(), h2.toInt());
1031 } 1031 }
1032 } 1032 }
1033 1033
1034 void drawImageAtScale(element, Rect dest, {Rect sourceRect}) { 1034 void drawImage(source, num destX, num destY) {
1035 _drawImage(source, destX, destY);
1036 }
1037
1038 void drawImageScaled(source,
1039 num destX, num destY, num destWidth, num destHeight) {
1040 _drawImage(source, destX, destY, destWidth, destHeight);
1041 }
1042
1043 void drawImageScaledFromSource(source,
1044 num sourceX, num sourceY, num sourceWidth, num sourceHeight,
1045 num destX, num destY, num destWidth, num destHeight) {
1046 _drawImage(source, sourceX, sourceY, sourceWidth, sourceHeight,
1047 destX, destY, destWidth, destHeight);
1048 }
1049
1050 void drawImageToRect(source, Rect dest, {Rect sourceRect}) {
1035 if (sourceRect == null) { 1051 if (sourceRect == null) {
1036 drawImage(element, dest.left, dest.top, dest.width, dest.height); 1052 _drawImage(source, dest.left, dest.top, dest.width, dest.height);
1037 } else { 1053 } else {
1038 drawImage(element, 1054 _drawImage(source,
1039 sourceRect.left, sourceRect.top, sourceRect.width, sourceRect.height, 1055 sourceRect.left, sourceRect.top, sourceRect.width, sourceRect.height,
1040 dest.left, dest.top, dest.width, dest.height); 1056 dest.left, dest.top, dest.width, dest.height);
1041 } 1057 }
1042 } 1058 }
1043 1059
1044 void fill() => Fill(_handle); 1060 void fill() => _Fill(_handle);
1045 1061
1046 void fillRect(num x, num y, num w, num h) => 1062 void fillRect(num x, num y, num w, num h) =>
1047 FillRect(_handle, x.toDouble(), y.toDouble(), 1063 _FillRect(_handle, x.toDouble(), y.toDouble(),
1048 w.toDouble(), h.toDouble()); 1064 w.toDouble(), h.toDouble());
1049 1065
1050 void fillText(String text, num x, num y, [num maxWidth = -1]) => 1066 void fillText(String text, num x, num y, [num maxWidth = -1]) =>
1051 FillText(_handle, text, x.toDouble(), y.toDouble(), 1067 _FillText(_handle, text, x.toDouble(), y.toDouble(),
1052 maxWidth.toDouble()); 1068 maxWidth.toDouble());
1053 1069
1054 ImageData getImageData(num sx, num sy, num sw, num sh) => 1070 ImageData getImageData(num sx, num sy, num sw, num sh) =>
1055 GetImageData(sx, sy, sw, sh); 1071 _GetImageData(sx, sy, sw, sh);
1056 1072
1057 List<double> _lineDash = null; 1073 List<double> _lineDash = null;
1058 List<num> getLineDash() { 1074 List<num> getLineDash() {
1059 if (_lineDash == null) return []; 1075 if (_lineDash == null) return [];
1060 return _lineDash; // TODO(gram): should we return a copy? 1076 return _lineDash; // TODO(gram): should we return a copy?
1061 } 1077 }
1062 1078
1063 bool isPointInPath(num x, num y) { 1079 bool isPointInPath(num x, num y) {
1064 throw new Exception('Unimplemented isPointInPath'); 1080 throw new Exception('Unimplemented isPointInPath');
1065 } 1081 }
1066 1082
1067 void lineTo(num x, num y) { 1083 void lineTo(num x, num y) {
1068 LineTo(_handle, x.toDouble(), y.toDouble()); 1084 _LineTo(_handle, x.toDouble(), y.toDouble());
1069 } 1085 }
1070 1086
1071 TextMetrics measureText(String text) { 1087 TextMetrics measureText(String text) {
1072 double w = MeasureText(_handle, text); 1088 double w = _MeasureText(_handle, text);
1073 return new TextMetrics(w); 1089 return new TextMetrics(w);
1074 } 1090 }
1075 1091
1076 void moveTo(num x, num y) => 1092 void moveTo(num x, num y) =>
1077 MoveTo(_handle, x.toDouble(), y.toDouble()); 1093 _MoveTo(_handle, x.toDouble(), y.toDouble());
1078 1094
1079 void putImageData(ImageData imagedata, num dx, num dy, 1095 void putImageData(ImageData imagedata, num dx, num dy,
1080 [num dirtyX, num dirtyY, num dirtyWidth, num dirtyHeight]) { 1096 [num dirtyX, num dirtyY, num dirtyWidth, num dirtyHeight]) {
1081 if (dirtyX != null || dirtyY != null) { 1097 if (dirtyX != null || dirtyY != null) {
1082 throw new Exception('Unimplemented putImageData'); 1098 throw new Exception('Unimplemented putImageData');
1083 } else { 1099 } else {
1084 PutImageData(_handle, imagedata, dx, dy); 1100 _PutImageData(_handle, imagedata, dx, dy);
1085 } 1101 }
1086 } 1102 }
1087 1103
1088 void quadraticCurveTo(num cpx, num cpy, num x, num y) => 1104 void quadraticCurveTo(num cpx, num cpy, num x, num y) =>
1089 QuadraticCurveTo(_handle, cpx.toDouble(), cpy.toDouble(), 1105 _QuadraticCurveTo(_handle, cpx.toDouble(), cpy.toDouble(),
1090 x.toDouble(), y.toDouble()); 1106 x.toDouble(), y.toDouble());
1091 1107
1092 void rect(num x, num y, num w, num h) => 1108 void rect(num x, num y, num w, num h) =>
1093 Rect(_handle, x.toDouble(), y.toDouble(), w.toDouble(), h.toDouble()); 1109 _Rect(_handle, x.toDouble(), y.toDouble(), w.toDouble(), h.toDouble());
1094 1110
1095 void restore() => Restore(_handle); 1111 void restore() => _Restore(_handle);
1096 1112
1097 void rotate(num angle) => Rotate(_handle, angle.toDouble()); 1113 void rotate(num angle) => _Rotate(_handle, angle.toDouble());
1098 1114
1099 void save() => Save(_handle); 1115 void save() => _Save(_handle);
1100 1116
1101 void scale(num x, num y) => Scale(_handle, x.toDouble(), y.toDouble()); 1117 void scale(num x, num y) => _Scale(_handle, x.toDouble(), y.toDouble());
1102 1118
1103 void setFillColorHsl(int h, num s, num l, [num a = 1]) { 1119 void setFillColorHsl(int h, num s, num l, [num a = 1]) {
1104 throw new Exception('Unimplemented setFillColorHsl'); 1120 throw new Exception('Unimplemented setFillColorHsl');
1105 } 1121 }
1106 1122
1107 void setFillColorRgb(int r, int g, int b, [num a = 1]) { 1123 void setFillColorRgb(int r, int g, int b, [num a = 1]) {
1108 throw new Exception('Unimplemented setFillColorRgb'); 1124 throw new Exception('Unimplemented setFillColorRgb');
1109 } 1125 }
1110 1126
1111 void setLineDash(List<num> dash) { 1127 void setLineDash(List<num> dash) {
(...skipping 14 matching lines...) Expand all
1126 for (int i = 0; i < dash.length; i++) { 1142 for (int i = 0; i < dash.length; i++) {
1127 double v = dash[i].toDouble(); 1143 double v = dash[i].toDouble();
1128 if (v < 0) { 1144 if (v < 0) {
1129 valid = false; 1145 valid = false;
1130 break; 1146 break;
1131 } 1147 }
1132 new_dash[i] = v; 1148 new_dash[i] = v;
1133 } 1149 }
1134 } 1150 }
1135 if (valid) { 1151 if (valid) {
1136 SetLineDash(_handle, _lineDash = new_dash); 1152 _SetLineDash(_handle, _lineDash = new_dash);
1137 } 1153 }
1138 } 1154 }
1139 1155
1140 void setStrokeColorHsl(int h, num s, num l, [num a = 1]) { 1156 void setStrokeColorHsl(int h, num s, num l, [num a = 1]) {
1141 throw new Exception('Unimplemented setStrokeColorHsl'); 1157 throw new Exception('Unimplemented setStrokeColorHsl');
1142 } 1158 }
1143 1159
1144 void setStrokeColorRgb(int r, int g, int b, [num a = 1]) { 1160 void setStrokeColorRgb(int r, int g, int b, [num a = 1]) {
1145 throw new Exception('Unimplemented setStrokeColorRgb'); 1161 throw new Exception('Unimplemented setStrokeColorRgb');
1146 } 1162 }
1147 1163
1148 void setTransform(num m11, num m12, num m21, num m22, num dx, num dy) => 1164 void setTransform(num m11, num m12, num m21, num m22, num dx, num dy) =>
1149 SetTransform(_handle, m11.toDouble(), m12.toDouble(), 1165 _SetTransform(_handle, m11.toDouble(), m12.toDouble(),
1150 m21.toDouble(), m22.toDouble(), 1166 m21.toDouble(), m22.toDouble(),
1151 dx.toDouble(), dy.toDouble()); 1167 dx.toDouble(), dy.toDouble());
1152 1168
1153 void stroke() => Stroke(_handle); 1169 void stroke() => _Stroke(_handle);
1154 1170
1155 void strokeRect(num x, num y, num w, num h, [num lineWidth]) => 1171 void strokeRect(num x, num y, num w, num h, [num lineWidth]) =>
1156 StrokeRect(_handle, x.toDouble(), y.toDouble(), 1172 _StrokeRect(_handle, x.toDouble(), y.toDouble(),
1157 w.toDouble(), h.toDouble()); 1173 w.toDouble(), h.toDouble());
1158 1174
1159 void strokeText(String text, num x, num y, [num maxWidth = -1]) => 1175 void strokeText(String text, num x, num y, [num maxWidth = -1]) =>
1160 StrokeText(_handle, text, x.toDouble(), y.toDouble(), 1176 _StrokeText(_handle, text, x.toDouble(), y.toDouble(),
1161 maxWidth.toDouble()); 1177 maxWidth.toDouble());
1162 1178
1163 void transform(num m11, num m12, num m21, num m22, num dx, num dy) => 1179 void transform(num m11, num m12, num m21, num m22, num dx, num dy) =>
1164 Transform(_handle, m11.toDouble(), m12.toDouble(), 1180 _Transform(_handle, m11.toDouble(), m12.toDouble(),
1165 m21.toDouble(), m22.toDouble(), 1181 m21.toDouble(), m22.toDouble(),
1166 dx.toDouble(), dy.toDouble()); 1182 dx.toDouble(), dy.toDouble());
1167 1183
1168 void translate(num x, num y) => 1184 void translate(num x, num y) =>
1169 Translate(_handle, x.toDouble(), y.toDouble()); 1185 _Translate(_handle, x.toDouble(), y.toDouble());
1170 1186
1171 ImageData webkitGetImageDataHD(num sx, num sy, num sw, num sh) { 1187 ImageData webkitGetImageDataHD(num sx, num sy, num sw, num sh) {
1172 throw new Exception('Unimplemented webkitGetImageDataHD'); 1188 throw new Exception('Unimplemented webkitGetImageDataHD');
1173 } 1189 }
1174 1190
1175 void webkitPutImageDataHD(ImageData imagedata, num dx, num dy, 1191 void webkitPutImageDataHD(ImageData imagedata, num dx, num dy,
1176 [num dirtyX, num dirtyY, 1192 [num dirtyX, num dirtyY,
1177 num dirtyWidth, num dirtyHeight]) { 1193 num dirtyWidth, num dirtyHeight]) {
1178 throw new Exception('Unimplemented webkitGetImageDataHD'); 1194 throw new Exception('Unimplemented webkitGetImageDataHD');
1179 } 1195 }
1180 1196
1181 // TODO(vsm): Kill. 1197 // TODO(vsm): Kill.
1182 noSuchMethod(invocation) { 1198 noSuchMethod(invocation) {
1183 throw new Exception('Unimplemented/unknown ${invocation.memberName}'); 1199 throw new Exception('Unimplemented/unknown ${invocation.memberName}');
1184 } 1200 }
1185 } 1201 }
1186 1202
1203 var sfx_extension = 'raw';
1187 int _loadSample(String s) native "LoadSample"; 1204 int _loadSample(String s) native "LoadSample";
1188 int _playSample(String s) native "PlaySample"; 1205 int _playSample(String s) native "PlaySample";
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/android/main.cc ('k') | runtime/embedders/openglui/common/image_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698