| OLD | NEW |
| 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 | 6 |
| 7 class CanvasElement { | 7 class CanvasElement { |
| 8 int _height; | 8 int _height; |
| 9 int _width; | 9 int _width; |
| 10 | 10 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 final int height; | 388 final int height; |
| 389 final int width; | 389 final int width; |
| 390 ImageData(this.height, this.width, this.data); | 390 ImageData(this.height, this.width, this.data); |
| 391 } | 391 } |
| 392 | 392 |
| 393 class TextMetrics { | 393 class TextMetrics { |
| 394 final num width; | 394 final num width; |
| 395 TextMetrics(this.width); | 395 TextMetrics(this.width); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void shutdown() { |
| 399 CanvasRenderingContext2D.next_handle = 0; |
| 400 } |
| 401 |
| 398 class CanvasRenderingContext2D extends CanvasRenderingContext { | 402 class CanvasRenderingContext2D extends CanvasRenderingContext { |
| 399 // TODO(gram): We need to support multiple contexts, for cached content | 403 // TODO(gram): We need to support multiple contexts, for cached content |
| 400 // prerendered to an offscreen buffer. For this we will use handles, with | 404 // prerendered to an offscreen buffer. For this we will use handles, with |
| 401 // handle 0 being the physical display. | 405 // handle 0 being the physical display. |
| 402 static int _next_handle = 0; | 406 static int next_handle = 0; |
| 403 int _handle = 0; | 407 int _handle = 0; |
| 404 get handle => _handle; | 408 get handle => _handle; |
| 405 | 409 |
| 406 int _width, _height; | 410 int _width, _height; |
| 407 set width(int w) { _width = C2DSetWidth(_handle, w); } | 411 set width(int w) { _width = C2DSetWidth(_handle, w); } |
| 408 get width => _width; | 412 get width => _width; |
| 409 set height(int h) { _height = C2DSetHeight(_handle, h); } | 413 set height(int h) { _height = C2DSetHeight(_handle, h); } |
| 410 get height => _height; | 414 get height => _height; |
| 411 | 415 |
| 412 CanvasRenderingContext2D(canvas, width, height) : super(canvas) { | 416 CanvasRenderingContext2D(canvas, width, height) : super(canvas) { |
| 413 _width = width; | 417 _width = width; |
| 414 _height = height; | 418 _height = height; |
| 415 C2DCreateNativeContext(_handle = _next_handle++, width, height); | 419 C2DCreateNativeContext(_handle = next_handle++, width, height); |
| 416 } | 420 } |
| 417 | 421 |
| 418 double _alpha = 1.0; | 422 double _alpha = 1.0; |
| 419 set globalAlpha(num a) { | 423 set globalAlpha(num a) { |
| 420 _alpha = C2DSetGlobalAlpha(_handle, a.toDouble()); | 424 _alpha = C2DSetGlobalAlpha(_handle, a.toDouble()); |
| 421 } | 425 } |
| 422 get globalAlpha => _alpha; | 426 get globalAlpha => _alpha; |
| 423 | 427 |
| 424 // TODO(gram): make sure we support compound assignments like: | 428 // TODO(gram): make sure we support compound assignments like: |
| 425 // fillStyle = strokeStyle = "red" | 429 // fillStyle = strokeStyle = "red" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 num dirtyWidth, num dirtyHeight]) { | 736 num dirtyWidth, num dirtyHeight]) { |
| 733 throw new Exception('Unimplemented webkitGetImageDataHD'); | 737 throw new Exception('Unimplemented webkitGetImageDataHD'); |
| 734 } | 738 } |
| 735 | 739 |
| 736 // TODO(vsm): Kill. | 740 // TODO(vsm): Kill. |
| 737 noSuchMethod(invocation) { | 741 noSuchMethod(invocation) { |
| 738 throw new Exception('Unimplemented/unknown ${invocation.memberName}'); | 742 throw new Exception('Unimplemented/unknown ${invocation.memberName}'); |
| 739 } | 743 } |
| 740 } | 744 } |
| 741 | 745 |
| OLD | NEW |