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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); | 671 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); |
672 return; | 672 return; |
673 } | 673 } |
674 | 674 |
675 if (!isPaintable()) { | 675 if (!isPaintable()) { |
676 // If the canvas element's bitmap has no pixels | 676 // If the canvas element's bitmap has no pixels |
677 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, WTF::bind(&BlobCallback::handleEvent, wrapPersistent(callback), nullptr
)); | 677 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, WTF::bind(&BlobCallback::handleEvent, wrapPersistent(callback), nullptr
)); |
678 return; | 678 return; |
679 } | 679 } |
680 | 680 |
| 681 double startTime = WTF::monotonicallyIncreasingTime(); |
681 double quality = UndefinedQualityValue; | 682 double quality = UndefinedQualityValue; |
682 if (!qualityArgument.isEmpty()) { | 683 if (!qualityArgument.isEmpty()) { |
683 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 684 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
684 if (v8Value->IsNumber()) { | 685 if (v8Value->IsNumber()) { |
685 quality = v8Value.As<v8::Number>()->Value(); | 686 quality = v8Value.As<v8::Number>()->Value(); |
686 } | 687 } |
687 } | 688 } |
688 | 689 |
689 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal
lback); | 690 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal
lback); |
690 | 691 |
691 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob); | 692 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob); |
692 | 693 |
693 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD
ata->data(), encodingMimeType, imageData->size(), callback); | 694 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD
ata->data(), encodingMimeType, imageData->size(), callback, startTime); |
694 | 695 |
695 bool useIdlePeriodScheduling = (encodingMimeType != "image/webp"); | 696 bool useIdlePeriodScheduling = (encodingMimeType != "image/webp"); |
696 asyncCreator->scheduleAsyncBlobCreation(useIdlePeriodScheduling, quality); | 697 asyncCreator->scheduleAsyncBlobCreation(useIdlePeriodScheduling, quality); |
697 } | 698 } |
698 | 699 |
699 void HTMLCanvasElement::addListener(CanvasDrawListener* listener) | 700 void HTMLCanvasElement::addListener(CanvasDrawListener* listener) |
700 { | 701 { |
701 m_listeners.add(listener); | 702 m_listeners.add(listener); |
702 } | 703 } |
703 | 704 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1188 |
1188 bool HTMLCanvasElement::createSurfaceLayer() | 1189 bool HTMLCanvasElement::createSurfaceLayer() |
1189 { | 1190 { |
1190 DCHECK(!m_surfaceLayerBridge); | 1191 DCHECK(!m_surfaceLayerBridge); |
1191 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); | 1192 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); |
1192 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 1193 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
1193 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); | 1194 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); |
1194 } | 1195 } |
1195 | 1196 |
1196 } // namespace blink | 1197 } // namespace blink |
OLD | NEW |