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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 if (!width() || !height()) { | 692 if (!width() || !height()) { |
692 *status = ZeroSizeCanvasSourceImageStatus; | 693 *status = ZeroSizeCanvasSourceImageStatus; |
693 return nullptr; | 694 return nullptr; |
694 } | 695 } |
695 | 696 |
696 if (!buffer()) { | 697 if (!buffer()) { |
697 *status = InvalidSourceImageStatus; | 698 *status = InvalidSourceImageStatus; |
698 return nullptr; | 699 return nullptr; |
699 } | 700 } |
700 | 701 |
701 if (mode == CopySourceImageIfVolatile) { | |
702 *status = NormalSourceImageStatus; | |
703 return copiedImage(); | |
704 } | |
705 | |
706 if (m_context && m_context->is3d()) { | 702 if (m_context && m_context->is3d()) { |
707 m_context->paintRenderingResultsToCanvas(); | 703 m_context->paintRenderingResultsToCanvas(); |
708 *status = ExternalSourceImageStatus; | 704 *status = ExternalSourceImageStatus; |
| 705 |
| 706 // can't create SkImage from WebGLImageBufferSurface (contains only SkBi
tmap) |
| 707 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); |
709 } else { | 708 } else { |
710 *status = NormalSourceImageStatus; | 709 *status = NormalSourceImageStatus; |
711 } | 710 } |
712 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); | 711 |
| 712 return StaticBitmapImage::create(m_imageBuffer->newImageSnapshot()); |
713 } | 713 } |
714 | 714 |
715 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 715 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
716 { | 716 { |
717 return !originClean(); | 717 return !originClean(); |
718 } | 718 } |
719 | 719 |
720 FloatSize HTMLCanvasElement::sourceSize() const | 720 FloatSize HTMLCanvasElement::sourceSize() const |
721 { | 721 { |
722 return FloatSize(width(), height()); | 722 return FloatSize(width(), height()); |
723 } | 723 } |
724 | 724 |
725 } | 725 } |
OLD | NEW |