| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 #include "V8HTMLCanvasElement.h" | 33 #include "V8HTMLCanvasElement.h" |
| 34 | 34 |
| 35 #include "V8CanvasRenderingContext2D.h" | 35 #include "V8CanvasRenderingContext2D.h" |
| 36 #include "V8Node.h" | 36 #include "V8Node.h" |
| 37 #include "V8WebGLRenderingContext.h" | 37 #include "V8WebGLRenderingContext.h" |
| 38 #include "V8WebGLShareGroup.h" |
| 38 #include "bindings/v8/V8Binding.h" | 39 #include "bindings/v8/V8Binding.h" |
| 39 #include "core/html/HTMLCanvasElement.h" | 40 #include "core/html/HTMLCanvasElement.h" |
| 40 #include "core/html/canvas/Canvas2DContextAttributes.h" | 41 #include "core/html/canvas/Canvas2DContextAttributes.h" |
| 41 #include "core/html/canvas/CanvasRenderingContext.h" | 42 #include "core/html/canvas/CanvasRenderingContext.h" |
| 42 #include "core/html/canvas/WebGLContextAttributes.h" | 43 #include "core/html/canvas/WebGLContextAttributes.h" |
| 43 #include "core/inspector/InspectorCanvasInstrumentation.h" | 44 #include "core/inspector/InspectorCanvasInstrumentation.h" |
| 44 #include "wtf/MathExtras.h" | 45 #include "wtf/MathExtras.h" |
| 45 #include "wtf/text/WTFString.h" | 46 #include "wtf/text/WTFString.h" |
| 46 | 47 |
| 47 namespace WebCore { | 48 namespace WebCore { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 webGLAttrs->setStencil(jsAttrs->Get(stencil)->BooleanValue()); | 68 webGLAttrs->setStencil(jsAttrs->Get(stencil)->BooleanValue()); |
| 68 v8::Handle<v8::String> antialias = v8::String::NewSymbol("antialias"
); | 69 v8::Handle<v8::String> antialias = v8::String::NewSymbol("antialias"
); |
| 69 if (jsAttrs->Has(antialias)) | 70 if (jsAttrs->Has(antialias)) |
| 70 webGLAttrs->setAntialias(jsAttrs->Get(antialias)->BooleanValue()
); | 71 webGLAttrs->setAntialias(jsAttrs->Get(antialias)->BooleanValue()
); |
| 71 v8::Handle<v8::String> premultipliedAlpha = v8::String::NewSymbol("p
remultipliedAlpha"); | 72 v8::Handle<v8::String> premultipliedAlpha = v8::String::NewSymbol("p
remultipliedAlpha"); |
| 72 if (jsAttrs->Has(premultipliedAlpha)) | 73 if (jsAttrs->Has(premultipliedAlpha)) |
| 73 webGLAttrs->setPremultipliedAlpha(jsAttrs->Get(premultipliedAlph
a)->BooleanValue()); | 74 webGLAttrs->setPremultipliedAlpha(jsAttrs->Get(premultipliedAlph
a)->BooleanValue()); |
| 74 v8::Handle<v8::String> preserveDrawingBuffer = v8::String::NewSymbol
("preserveDrawingBuffer"); | 75 v8::Handle<v8::String> preserveDrawingBuffer = v8::String::NewSymbol
("preserveDrawingBuffer"); |
| 75 if (jsAttrs->Has(preserveDrawingBuffer)) | 76 if (jsAttrs->Has(preserveDrawingBuffer)) |
| 76 webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawin
gBuffer)->BooleanValue()); | 77 webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawin
gBuffer)->BooleanValue()); |
| 78 v8::Handle<v8::String> group = v8::String::NewSymbol("group"); |
| 79 if (jsAttrs->Has(group)) { |
| 80 v8::Handle<v8::Value> value = jsAttrs->Get(group); |
| 81 if (value->IsObject()) { |
| 82 webGLAttrs->setGroup(V8WebGLShareGroup::toNative(value->ToOb
ject())); |
| 83 } |
| 84 } |
| 77 } | 85 } |
| 78 attrs = webGLAttrs; | 86 attrs = webGLAttrs; |
| 79 } else { | 87 } else { |
| 80 RefPtr<Canvas2DContextAttributes> canvas2DAttrs = Canvas2DContextAttribu
tes::create(); | 88 RefPtr<Canvas2DContextAttributes> canvas2DAttrs = Canvas2DContextAttribu
tes::create(); |
| 81 if (args.Length() > 1 && args[1]->IsObject()) { | 89 if (args.Length() > 1 && args[1]->IsObject()) { |
| 82 v8::Handle<v8::Object> jsAttrs = args[1]->ToObject(); | 90 v8::Handle<v8::Object> jsAttrs = args[1]->ToObject(); |
| 83 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); | 91 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); |
| 84 if (jsAttrs->Has(alpha)) | 92 if (jsAttrs->Has(alpha)) |
| 85 canvas2DAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue()); | 93 canvas2DAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue()); |
| 86 } | 94 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 quality = args[1]->NumberValue(); | 144 quality = args[1]->NumberValue(); |
| 137 qualityPtr = &quality; | 145 qualityPtr = &quality; |
| 138 } | 146 } |
| 139 | 147 |
| 140 String result = canvas->toDataURL(type, qualityPtr, ec); | 148 String result = canvas->toDataURL(type, qualityPtr, ec); |
| 141 setDOMException(ec, args.GetIsolate()); | 149 setDOMException(ec, args.GetIsolate()); |
| 142 v8SetReturnValue(args, v8StringOrUndefined(result, args.GetIsolate())); | 150 v8SetReturnValue(args, v8StringOrUndefined(result, args.GetIsolate())); |
| 143 } | 151 } |
| 144 | 152 |
| 145 } // namespace WebCore | 153 } // namespace WebCore |
| OLD | NEW |