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

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

Issue 54653004: Break dependency of platform/graphics on html/ImageData.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move struct into ImageBuffer.h Created 7 years, 1 month 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 | Source/core/html/canvas/WebGLRenderingContext.cpp » ('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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 if (m_size.isEmpty() || !buffer()) 386 if (m_size.isEmpty() || !buffer())
387 return String("data:,"); 387 return String("data:,");
388 388
389 String encodingMimeType = toEncodingMimeType(mimeType); 389 String encodingMimeType = toEncodingMimeType(mimeType);
390 390
391 // Try to get ImageData first, as that may avoid lossy conversions. 391 // Try to get ImageData first, as that may avoid lossy conversions.
392 RefPtr<ImageData> imageData = getImageData(); 392 RefPtr<ImageData> imageData = getImageData();
393 393
394 if (imageData) 394 if (imageData)
395 return ImageDataToDataURL(*imageData, encodingMimeType, quality); 395 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData-> data()), encodingMimeType, quality);
396 396
397 if (m_context) 397 if (m_context)
398 m_context->paintRenderingResultsToCanvas(); 398 m_context->paintRenderingResultsToCanvas();
399 399
400 return buffer()->toDataURL(encodingMimeType, quality); 400 return buffer()->toDataURL(encodingMimeType, quality);
401 } 401 }
402 402
403 PassRefPtr<ImageData> HTMLCanvasElement::getImageData() 403 PassRefPtr<ImageData> HTMLCanvasElement::getImageData()
404 { 404 {
405 if (!m_context || !m_context->is3d()) 405 if (!m_context || !m_context->is3d())
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 ASSERT(m_hasCreatedImageBuffer); 552 ASSERT(m_hasCreatedImageBuffer);
553 IntSize unscaledSize = size(); 553 IntSize unscaledSize = size();
554 IntSize size = convertLogicalToDevice(unscaledSize); 554 IntSize size = convertLogicalToDevice(unscaledSize);
555 AffineTransform transform; 555 AffineTransform transform;
556 if (size.width() && size.height()) 556 if (size.width() && size.height())
557 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig ht() / unscaledSize.height()); 557 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig ht() / unscaledSize.height());
558 return m_imageBuffer->baseTransform() * transform; 558 return m_imageBuffer->baseTransform() * transform;
559 } 559 }
560 560
561 } 561 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/canvas/WebGLRenderingContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698