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

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

Issue 1084313004: Oilpan: keep ImageData on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ensure timely disposal of temporary ImageData buffers Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 return AtomicString(toDataURLInternal("image/png", 0, FrontBuffer)); 477 return AtomicString(toDataURLInternal("image/png", 0, FrontBuffer));
478 } 478 }
479 479
480 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double * quality, SourceDrawingBuffer sourceBuffer) const 480 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double * quality, SourceDrawingBuffer sourceBuffer) const
481 { 481 {
482 if (!isPaintable()) 482 if (!isPaintable())
483 return String("data:,"); 483 return String("data:,");
484 484
485 String encodingMimeType = toEncodingMimeType(mimeType); 485 String encodingMimeType = toEncodingMimeType(mimeType);
486 if (!m_context) { 486 if (!m_context) {
487 RefPtrWillBeRawPtr<ImageData> imageData = ImageData::create(m_size); 487 ImageData* imageData = ImageData::create(m_size);
488 ScopedDisposal<ImageData> disposer(imageData);
488 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toD ataURL(encodingMimeType, quality); 489 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toD ataURL(encodingMimeType, quality);
489 } 490 }
490 491
491 if (m_context->is3d()) { 492 if (m_context->is3d()) {
492 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL(). 493 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
493 RefPtrWillBeRawPtr<ImageData> imageData = 494 ImageData* imageData = toWebGLRenderingContextBase(m_context.get())->pai ntRenderingResultsToImageData(sourceBuffer);
494 toWebGLRenderingContextBase(m_context.get())->paintRenderingResultsT oImageData(sourceBuffer); 495 ScopedDisposal<ImageData> disposer(imageData);
495 if (imageData) 496 if (imageData)
496 return ImageDataBuffer(imageData->size(), imageData->data()->data()) .toDataURL(encodingMimeType, quality); 497 return ImageDataBuffer(imageData->size(), imageData->data()->data()) .toDataURL(encodingMimeType, quality);
497 m_context->paintRenderingResultsToCanvas(sourceBuffer); 498 m_context->paintRenderingResultsToCanvas(sourceBuffer);
498 } 499 }
499 500
500 return buffer()->toDataURL(encodingMimeType, quality); 501 return buffer()->toDataURL(encodingMimeType, quality);
501 } 502 }
502 503
503 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const 504 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const
504 { 505 {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 { 878 {
878 return FloatSize(width(), height()); 879 return FloatSize(width(), height());
879 } 880 }
880 881
881 bool HTMLCanvasElement::isOpaque() const 882 bool HTMLCanvasElement::isOpaque() const
882 { 883 {
883 return m_context && !m_context->hasAlpha(); 884 return m_context && !m_context->hasAlpha();
884 } 885 }
885 886
886 } // blink 887 } // blink
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/core/html/ImageData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698