Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 1889153003: Remove ImageData::dispose() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reverted Handle.h Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/ImageData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 592 }
593 593
594 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const 594 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const
595 { 595 {
596 if (!isPaintable()) 596 if (!isPaintable())
597 return String("data:,"); 597 return String("data:,");
598 598
599 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL ); 599 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL );
600 600
601 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL); 601 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL);
602 ScopedDisposal<ImageData> disposer(imageData);
603 602
604 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU RL(encodingMimeType, quality); 603 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU RL(encodingMimeType, quality);
605 } 604 }
606 605
607 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const 606 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const
608 { 607 {
609 if (!originClean()) { 608 if (!originClean()) {
610 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); 609 exceptionState.throwSecurityError("Tainted canvases may not be exported. ");
611 return String(); 610 return String();
612 } 611 }
(...skipping 24 matching lines...) Expand all
637 if (!qualityArgument.isEmpty()) { 636 if (!qualityArgument.isEmpty()) {
638 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); 637 v8::Local<v8::Value> v8Value = qualityArgument.v8Value();
639 if (v8Value->IsNumber()) { 638 if (v8Value->IsNumber()) {
640 quality = v8Value.As<v8::Number>()->Value(); 639 quality = v8Value.As<v8::Number>()->Value();
641 } 640 }
642 } 641 }
643 642
644 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal lback); 643 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal lback);
645 644
646 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob); 645 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob);
647 // imageData unref its data, which we still keep alive for the async toBlob thread 646
648 ScopedDisposal<ImageData> disposer(imageData);
649 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD ata->data(), encodingMimeType, imageData->size(), callback); 647 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD ata->data(), encodingMimeType, imageData->size(), callback);
650 648
651 if (encodingMimeType == DefaultMimeType) 649 if (encodingMimeType == DefaultMimeType)
652 asyncCreator->scheduleAsyncBlobCreation(true); 650 asyncCreator->scheduleAsyncBlobCreation(true);
653 else 651 else
654 asyncCreator->scheduleAsyncBlobCreation(false, quality); 652 asyncCreator->scheduleAsyncBlobCreation(false, quality);
655 } 653 }
656 654
657 void HTMLCanvasElement::addListener(CanvasDrawListener* listener) 655 void HTMLCanvasElement::addListener(CanvasDrawListener* listener)
658 { 656 {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1114 }
1117 1115
1118 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists( const LayoutPoint& location) 1116 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists( const LayoutPoint& location)
1119 { 1117 {
1120 if (m_context && m_context->is2d()) 1118 if (m_context && m_context->is2d())
1121 return m_context->getControlAndIdIfHitRegionExists(location); 1119 return m_context->getControlAndIdIfHitRegionExists(location);
1122 return std::make_pair(nullptr, String()); 1120 return std::make_pair(nullptr, String());
1123 } 1121 }
1124 1122
1125 } // namespace blink 1123 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/ImageData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698