| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "core/html/canvas/WebGLContextAttributes.h" | 42 #include "core/html/canvas/WebGLContextAttributes.h" |
| 43 #include "core/html/canvas/WebGLContextEvent.h" | 43 #include "core/html/canvas/WebGLContextEvent.h" |
| 44 #include "core/html/canvas/WebGLRenderingContext.h" | 44 #include "core/html/canvas/WebGLRenderingContext.h" |
| 45 #include "core/rendering/RenderHTMLCanvas.h" | 45 #include "core/rendering/RenderHTMLCanvas.h" |
| 46 #include "platform/MIMETypeRegistry.h" | 46 #include "platform/MIMETypeRegistry.h" |
| 47 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
| 48 #include "platform/graphics/Canvas2DImageBufferSurface.h" | 48 #include "platform/graphics/Canvas2DImageBufferSurface.h" |
| 49 #include "platform/graphics/GraphicsContextStateSaver.h" | 49 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 50 #include "platform/graphics/ImageBuffer.h" | 50 #include "platform/graphics/ImageBuffer.h" |
| 51 #include "platform/graphics/RecordingImageBufferSurface.h" | 51 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 52 #include "platform/graphics/StaticBitmapImage.h" |
| 52 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 53 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 53 #include "platform/graphics/gpu/WebGLImageBufferSurface.h" | 54 #include "platform/graphics/gpu/WebGLImageBufferSurface.h" |
| 54 #include "platform/transforms/AffineTransform.h" | 55 #include "platform/transforms/AffineTransform.h" |
| 55 #include "public/platform/Platform.h" | 56 #include "public/platform/Platform.h" |
| 56 #include <math.h> | 57 #include <math.h> |
| 57 #include <v8.h> | 58 #include <v8.h> |
| 58 | 59 |
| 59 namespace blink { | 60 namespace blink { |
| 60 | 61 |
| 61 using namespace HTMLNames; | 62 using namespace HTMLNames; |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 if (!width() || !height()) { | 689 if (!width() || !height()) { |
| 689 *status = ZeroSizeCanvasSourceImageStatus; | 690 *status = ZeroSizeCanvasSourceImageStatus; |
| 690 return nullptr; | 691 return nullptr; |
| 691 } | 692 } |
| 692 | 693 |
| 693 if (!buffer()) { | 694 if (!buffer()) { |
| 694 *status = InvalidSourceImageStatus; | 695 *status = InvalidSourceImageStatus; |
| 695 return nullptr; | 696 return nullptr; |
| 696 } | 697 } |
| 697 | 698 |
| 698 if (mode == CopySourceImageIfVolatile) { | |
| 699 *status = NormalSourceImageStatus; | |
| 700 return copiedImage(); | |
| 701 } | |
| 702 | |
| 703 if (m_context && m_context->is3d()) { | 699 if (m_context && m_context->is3d()) { |
| 704 m_context->paintRenderingResultsToCanvas(); | 700 m_context->paintRenderingResultsToCanvas(); |
| 705 *status = ExternalSourceImageStatus; | 701 *status = ExternalSourceImageStatus; |
| 702 |
| 703 // can't create SkImage from WebGLImageBufferSurface (contains only SkBi
tmap) |
| 704 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); |
| 706 } else { | 705 } else { |
| 707 *status = NormalSourceImageStatus; | 706 *status = NormalSourceImageStatus; |
| 708 } | 707 } |
| 709 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); | 708 |
| 709 return StaticBitmapImage::create(m_imageBuffer->newImageSnapshot()); |
| 710 } | 710 } |
| 711 | 711 |
| 712 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 712 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
| 713 { | 713 { |
| 714 return !originClean(); | 714 return !originClean(); |
| 715 } | 715 } |
| 716 | 716 |
| 717 FloatSize HTMLCanvasElement::sourceSize() const | 717 FloatSize HTMLCanvasElement::sourceSize() const |
| 718 { | 718 { |
| 719 return FloatSize(width(), height()); | 719 return FloatSize(width(), height()); |
| 720 } | 720 } |
| 721 | 721 |
| 722 } | 722 } |
| OLD | NEW |