| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "DartHTMLCanvasElement.h" | 31 #include "DartHTMLCanvasElement.h" |
| 32 | 32 |
| 33 #include "CanvasContextAttributes.h" |
| 33 #include "CanvasRenderingContext.h" | 34 #include "CanvasRenderingContext.h" |
| 34 #include "CanvasRenderingContext2D.h" | 35 #include "CanvasRenderingContext2D.h" |
| 35 #include "DartDOMWrapper.h" | 36 #include "DartDOMWrapper.h" |
| 36 #include "DartCanvasRenderingContext2D.h" | 37 #include "DartCanvasRenderingContext2D.h" |
| 37 #if ENABLE(WEBGL) | 38 #if ENABLE(WEBGL) |
| 38 #include "DartWebGLRenderingContext.h" | 39 #include "DartWebGLRenderingContext.h" |
| 39 #endif | 40 #endif |
| 40 #include "HTMLCanvasElement.h" | 41 #include "HTMLCanvasElement.h" |
| 41 #if ENABLE(WEBGL) | 42 #if ENABLE(WEBGL) |
| 42 #include "DartUtilities.h" | 43 #include "DartUtilities.h" |
| 44 #include "WebGLContextAttributes.h" |
| 43 #include "WebGLRenderingContext.h" | 45 #include "WebGLRenderingContext.h" |
| 44 #endif | 46 #endif |
| 45 | 47 |
| 46 | |
| 47 namespace WebCore { | 48 namespace WebCore { |
| 48 | 49 |
| 49 namespace DartHTMLCanvasElementInternal { | 50 namespace DartHTMLCanvasElementInternal { |
| 50 | 51 |
| 51 void toDataURLCallback(Dart_NativeArguments args) | 52 void toDataURLCallback(Dart_NativeArguments args) |
| 52 { | 53 { |
| 53 DartApiScope dartApiScope; | 54 DartApiScope dartApiScope; |
| 54 Dart_Handle exception; | 55 Dart_Handle exception; |
| 55 { | 56 { |
| 56 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement
>(args); | 57 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement
>(args); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 Dart_Handle exception; | 84 Dart_Handle exception; |
| 84 { | 85 { |
| 85 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement
>(args); | 86 HTMLCanvasElement* receiver = DartDOMWrapper::receiver<HTMLCanvasElement
>(args); |
| 86 | 87 |
| 87 const ParameterAdapter< String > contextId(Dart_GetNativeArgument(args,
1)); | 88 const ParameterAdapter< String > contextId(Dart_GetNativeArgument(args,
1)); |
| 88 if (!contextId.conversionSuccessful()) { | 89 if (!contextId.conversionSuccessful()) { |
| 89 exception = contextId.exception(); | 90 exception = contextId.exception(); |
| 90 goto fail; | 91 goto fail; |
| 91 } | 92 } |
| 92 | 93 |
| 93 // FIXME: implement support for CanvasContextAttributes. | 94 RefPtr<CanvasContextAttributes> attrs; |
| 94 CanvasRenderingContext* result = receiver->getContext(contextId, 0); | 95 #if ENABLE(WEBGL) |
| 96 const String& contextIdStr = contextId; |
| 97 if (contextIdStr == "experimental-webgl" || contextIdStr == "webkit-3d")
{ |
| 98 attrs = WebGLContextAttributes::create(); |
| 99 // FIXME: IDL doesn't mention second argument, but JS |
| 100 // passes map with parameters describing desired context |
| 101 // features. |
| 102 } |
| 103 #endif |
| 104 CanvasRenderingContext* result = receiver->getContext(contextId, attrs.g
et()); |
| 95 if (!result) | 105 if (!result) |
| 96 return; | 106 return; |
| 97 if (result->is2d()) | 107 if (result->is2d()) |
| 98 DartDOMWrapper::returnValue(args, static_cast<CanvasRenderingContext
2D*>(result)); | 108 DartDOMWrapper::returnValue(args, static_cast<CanvasRenderingContext
2D*>(result)); |
| 99 #if ENABLE(WEBGL) | 109 #if ENABLE(WEBGL) |
| 100 else if (result->is3d()) | 110 else if (result->is3d()) |
| 101 DartDOMWrapper::returnValue(args, static_cast<WebGLRenderingContext*
>(result)); | 111 DartDOMWrapper::returnValue(args, static_cast<WebGLRenderingContext*
>(result)); |
| 102 #endif | 112 #endif |
| 103 else | 113 else |
| 104 ASSERT_NOT_REACHED(); | 114 ASSERT_NOT_REACHED(); |
| 105 return; | 115 return; |
| 106 } | 116 } |
| 107 | 117 |
| 108 fail: | 118 fail: |
| 109 Dart_ThrowException(exception); | 119 Dart_ThrowException(exception); |
| 110 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 111 } | 121 } |
| 112 | 122 |
| 113 } // namespace DartHTMLCanvasElementInternal | 123 } // namespace DartHTMLCanvasElementInternal |
| 114 | 124 |
| 115 } // namespace WebCore | 125 } // namespace WebCore |
| OLD | NEW |