| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 "core/rendering/RenderLayer.h" | 46 #include "core/rendering/RenderLayer.h" |
| 47 #include "platform/MIMETypeRegistry.h" | 47 #include "platform/MIMETypeRegistry.h" |
| 48 #include "platform/RuntimeEnabledFeatures.h" | 48 #include "platform/RuntimeEnabledFeatures.h" |
| 49 #include "platform/graphics/Canvas2DImageBufferSurface.h" | 49 #include "platform/graphics/Canvas2DImageBufferSurface.h" |
| 50 #include "platform/graphics/GraphicsContextStateSaver.h" | 50 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 51 #include "platform/graphics/ImageBuffer.h" | 51 #include "platform/graphics/ImageBuffer.h" |
| 52 #include "platform/graphics/RecordingImageBufferSurface.h" | 52 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 53 #include "platform/graphics/StaticBitmapImage.h" |
| 53 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 54 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 54 #include "platform/graphics/gpu/WebGLImageBufferSurface.h" | 55 #include "platform/graphics/gpu/WebGLImageBufferSurface.h" |
| 55 #include "platform/transforms/AffineTransform.h" | 56 #include "platform/transforms/AffineTransform.h" |
| 56 #include "public/platform/Platform.h" | 57 #include "public/platform/Platform.h" |
| 57 #include <math.h> | 58 #include <math.h> |
| 58 #include <v8.h> | 59 #include <v8.h> |
| 59 | 60 |
| 60 namespace blink { | 61 namespace blink { |
| 61 | 62 |
| 62 using namespace HTMLNames; | 63 using namespace HTMLNames; |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 if (!width() || !height()) { | 725 if (!width() || !height()) { |
| 725 *status = ZeroSizeCanvasSourceImageStatus; | 726 *status = ZeroSizeCanvasSourceImageStatus; |
| 726 return nullptr; | 727 return nullptr; |
| 727 } | 728 } |
| 728 | 729 |
| 729 if (!buffer()) { | 730 if (!buffer()) { |
| 730 *status = InvalidSourceImageStatus; | 731 *status = InvalidSourceImageStatus; |
| 731 return nullptr; | 732 return nullptr; |
| 732 } | 733 } |
| 733 | 734 |
| 734 if (mode == CopySourceImageIfVolatile) { | |
| 735 *status = NormalSourceImageStatus; | |
| 736 return copiedImage(); | |
| 737 } | |
| 738 | |
| 739 if (m_context && m_context->is3d()) { | 735 if (m_context && m_context->is3d()) { |
| 740 m_context->paintRenderingResultsToCanvas(); | 736 m_context->paintRenderingResultsToCanvas(); |
| 741 *status = ExternalSourceImageStatus; | 737 *status = ExternalSourceImageStatus; |
| 738 |
| 739 // can't create SkImage from WebGLImageBufferSurface (contains only SkBi
tmap) |
| 740 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); |
| 742 } else { | 741 } else { |
| 743 *status = NormalSourceImageStatus; | 742 *status = NormalSourceImageStatus; |
| 744 } | 743 } |
| 745 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); | 744 |
| 745 return StaticBitmapImage::create(m_imageBuffer->newImageSnapshot()); |
| 746 } | 746 } |
| 747 | 747 |
| 748 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 748 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
| 749 { | 749 { |
| 750 return !originClean(); | 750 return !originClean(); |
| 751 } | 751 } |
| 752 | 752 |
| 753 FloatSize HTMLCanvasElement::sourceSize() const | 753 FloatSize HTMLCanvasElement::sourceSize() const |
| 754 { | 754 { |
| 755 return FloatSize(width(), height()); | 755 return FloatSize(width(), height()); |
| 756 } | 756 } |
| 757 | 757 |
| 758 } | 758 } |
| OLD | NEW |