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

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

Issue 309933004: Fix imageSourceURL() for WebGL elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread). 369 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread).
370 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType)) 370 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType))
371 lowercaseMimeType = "image/png"; 371 lowercaseMimeType = "image/png";
372 372
373 return lowercaseMimeType; 373 return lowercaseMimeType;
374 } 374 }
375 375
376 const AtomicString HTMLCanvasElement::imageSourceURL() const 376 const AtomicString HTMLCanvasElement::imageSourceURL() const
377 { 377 {
378 return AtomicString(toDataURLInternal("image/png", 0)); 378 return AtomicString(toDataURLInternal("image/png", 0, true));
379 } 379 }
380 380
381 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double * quality) const 381 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double * quality, bool isSaving) const
382 { 382 {
383 if (m_size.isEmpty() || !buffer()) 383 if (m_size.isEmpty() || !buffer())
384 return String("data:,"); 384 return String("data:,");
385 385
386 String encodingMimeType = toEncodingMimeType(mimeType); 386 String encodingMimeType = toEncodingMimeType(mimeType);
387 387
388 // Try to get ImageData first, as that may avoid lossy conversions. 388 // Try to get ImageData first, as that may avoid lossy conversions.
389 RefPtrWillBeRawPtr<ImageData> imageData = getImageData(); 389 RefPtrWillBeRawPtr<ImageData> imageData = getImageData();
390 390
391 if (imageData) 391 if (imageData)
392 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData-> data()), encodingMimeType, quality); 392 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData-> data()), encodingMimeType, quality);
393 393
394 if (m_context) 394 if (m_context && m_context->is3d()) {
395 toWebGLRenderingContext(m_context.get())->setSavingImage(isSaving);
395 m_context->paintRenderingResultsToCanvas(); 396 m_context->paintRenderingResultsToCanvas();
397 toWebGLRenderingContext(m_context.get())->setSavingImage(false);
398 }
396 399
397 return buffer()->toDataURL(encodingMimeType, quality); 400 return buffer()->toDataURL(encodingMimeType, quality);
398 } 401 }
399 402
400 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) const 403 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) const
401 { 404 {
402 if (!m_originClean) { 405 if (!m_originClean) {
403 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); 406 exceptionState.throwSecurityError("Tainted canvases may not be exported. ");
404 return String(); 407 return String();
405 } 408 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 { 699 {
697 return !originClean(); 700 return !originClean();
698 } 701 }
699 702
700 FloatSize HTMLCanvasElement::sourceSize() const 703 FloatSize HTMLCanvasElement::sourceSize() const
701 { 704 {
702 return FloatSize(width(), height()); 705 return FloatSize(width(), height());
703 } 706 }
704 707
705 } 708 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/core/html/canvas/WebGLRenderingContextBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698