OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 double quality; | 557 double quality; |
558 double* qualityPtr = nullptr; | 558 double* qualityPtr = nullptr; |
559 if (!qualityArgument.isEmpty()) { | 559 if (!qualityArgument.isEmpty()) { |
560 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 560 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
561 if (v8Value->IsNumber()) { | 561 if (v8Value->IsNumber()) { |
562 quality = v8Value.As<v8::Number>()->Value(); | 562 quality = v8Value.As<v8::Number>()->Value(); |
563 qualityPtr = &quality; | 563 qualityPtr = &quality; |
564 } | 564 } |
565 } | 565 } |
566 | 566 |
567 String encodingMimeType = toEncodingMimeType(mimeType); | |
568 | |
569 ImageData* imageData = toImageData(BackBuffer); | 567 ImageData* imageData = toImageData(BackBuffer); |
570 ScopedDisposal<ImageData> disposer(imageData); | 568 ScopedDisposal<ImageData> disposer(imageData); |
571 | 569 |
572 // Perform image encoding | |
573 Vector<char> encodedImage; | 570 Vector<char> encodedImage; |
574 ImageDataBuffer(imageData->size(), imageData->data()->data()).encodeImage(en
codingMimeType, qualityPtr, &encodedImage); | 571 String encodedMimeType; |
575 resultBlob = File::create(encodedImage.data(), encodedImage.size(), encoding
MimeType); | 572 ImageDataBuffer(imageData->size(), imageData->data()->data()).encodeImage(to
EncodingMimeType(mimeType), qualityPtr, &encodedImage, &encodedMimeType); |
576 | 573 |
| 574 resultBlob = File::create(encodedImage.data(), encodedImage.size(), encodedM
imeType); |
577 Platform::current()->mainThread()->postTask(FROM_HERE, bind(&FileCallback::h
andleEvent, callback, resultBlob)); | 575 Platform::current()->mainThread()->postTask(FROM_HERE, bind(&FileCallback::h
andleEvent, callback, resultBlob)); |
578 } | 576 } |
579 | 577 |
580 SecurityOrigin* HTMLCanvasElement::securityOrigin() const | 578 SecurityOrigin* HTMLCanvasElement::securityOrigin() const |
581 { | 579 { |
582 return document().securityOrigin(); | 580 return document().securityOrigin(); |
583 } | 581 } |
584 | 582 |
585 bool HTMLCanvasElement::originClean() const | 583 bool HTMLCanvasElement::originClean() const |
586 { | 584 { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 { | 941 { |
944 return FloatSize(width(), height()); | 942 return FloatSize(width(), height()); |
945 } | 943 } |
946 | 944 |
947 bool HTMLCanvasElement::isOpaque() const | 945 bool HTMLCanvasElement::isOpaque() const |
948 { | 946 { |
949 return m_context && !m_context->hasAlpha(); | 947 return m_context && !m_context->hasAlpha(); |
950 } | 948 } |
951 | 949 |
952 } // blink | 950 } // blink |
OLD | NEW |