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

Side by Side Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 559103002: Reduce memory peaks when generating data urls for images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: toDataURL(): Fewer temporary coppies of image data Created 6 years, 3 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 | « Source/core/inspector/InspectorLayerTreeAgent.cpp ('k') | no next file » | 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) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
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 are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return true; 413 return true;
414 } 414 }
415 415
416 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con st 416 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con st
417 { 417 {
418 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 418 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
419 419
420 Vector<char> encodedImage; 420 Vector<char> encodedImage;
421 if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality , &encodedImage)) 421 if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality , &encodedImage))
422 return "data:,"; 422 return "data:,";
423 Vector<char> base64Data;
424 base64Encode(encodedImage, base64Data);
425 423
426 return "data:" + mimeType + ";base64," + base64Data; 424 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
427 } 425 }
428 426
429 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy pe, const double* quality) 427 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy pe, const double* quality)
430 { 428 {
431 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 429 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
432 430
433 Vector<char> encodedImage; 431 Vector<char> encodedImage;
434 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 432 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
435 return "data:,"; 433 return "data:,";
436 434
437 Vector<char> base64Data; 435 return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
438 base64Encode(encodedImage, base64Data);
439
440 return "data:" + mimeType + ";base64," + base64Data;
441 } 436 }
442 437
443 } // namespace blink 438 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorLayerTreeAgent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698