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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 { | 142 { |
143 LocalFrame* frame = document().frame(); | 143 LocalFrame* frame = document().frame(); |
144 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) | 144 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
145 return new RenderHTMLCanvas(this); | 145 return new RenderHTMLCanvas(this); |
146 return HTMLElement::createRenderer(style); | 146 return HTMLElement::createRenderer(style); |
147 } | 147 } |
148 | 148 |
149 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) | 149 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) |
150 { | 150 { |
151 SkPaint::FilterLevel filterLevel = computedStyle()->imageRendering() == Imag
eRenderingPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel; | 151 SkPaint::FilterLevel filterLevel = computedStyle()->imageRendering() == Imag
eRenderingPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel; |
152 if (m_context && m_context->is3d()) { | 152 if (is3D()) { |
153 toWebGLRenderingContext(m_context.get())->setFilterLevel(filterLevel); | 153 toWebGLRenderingContext(m_context.get())->setFilterLevel(filterLevel); |
154 setNeedsCompositingUpdate(); | 154 setNeedsCompositingUpdate(); |
| 155 } else if (hasImageBuffer()) { |
| 156 m_imageBuffer->setFilterLevel(filterLevel); |
155 } | 157 } |
156 } | 158 } |
157 | 159 |
158 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) | 160 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) |
159 { | 161 { |
160 setIsInCanvasSubtree(true); | 162 setIsInCanvasSubtree(true); |
161 return HTMLElement::insertedInto(node); | 163 return HTMLElement::insertedInto(node); |
162 } | 164 } |
163 | 165 |
164 void HTMLCanvasElement::addObserver(CanvasObserver* observer) | 166 void HTMLCanvasElement::addObserver(CanvasObserver* observer) |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 return; | 622 return; |
621 | 623 |
622 int msaaSampleCount; | 624 int msaaSampleCount; |
623 OwnPtr<ImageBufferSurface> surface = createImageBufferSurface(size(), &msaaS
ampleCount); | 625 OwnPtr<ImageBufferSurface> surface = createImageBufferSurface(size(), &msaaS
ampleCount); |
624 if (!surface->isValid()) | 626 if (!surface->isValid()) |
625 return; | 627 return; |
626 | 628 |
627 m_imageBuffer = ImageBuffer::create(surface.release()); | 629 m_imageBuffer = ImageBuffer::create(surface.release()); |
628 m_imageBuffer->setClient(this); | 630 m_imageBuffer->setClient(this); |
629 | 631 |
| 632 document().updateRenderTreeIfNeeded(); |
| 633 RenderStyle* style = computedStyle(); |
| 634 m_imageBuffer->setFilterLevel((style && (style->imageRendering() == ImageRen
deringPixelated)) ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel); |
| 635 |
630 m_didFailToCreateImageBuffer = false; | 636 m_didFailToCreateImageBuffer = false; |
631 | 637 |
632 updateExternallyAllocatedMemory(); | 638 updateExternallyAllocatedMemory(); |
633 | 639 |
634 if (is3D()) { | 640 if (is3D()) { |
635 // Early out for WebGL canvases | 641 // Early out for WebGL canvases |
636 return; | 642 return; |
637 } | 643 } |
638 | 644 |
639 m_imageBuffer->setClient(this); | 645 m_imageBuffer->setClient(this); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (!isPaintable()) { | 812 if (!isPaintable()) { |
807 *status = InvalidSourceImageStatus; | 813 *status = InvalidSourceImageStatus; |
808 return nullptr; | 814 return nullptr; |
809 } | 815 } |
810 | 816 |
811 if (!m_context) { | 817 if (!m_context) { |
812 *status = NormalSourceImageStatus; | 818 *status = NormalSourceImageStatus; |
813 return createTransparentImage(size()); | 819 return createTransparentImage(size()); |
814 } | 820 } |
815 | 821 |
| 822 m_imageBuffer->willAccessPixels(); |
| 823 |
816 if (m_context->is3d()) { | 824 if (m_context->is3d()) { |
817 m_context->paintRenderingResultsToCanvas(BackBuffer); | 825 m_context->paintRenderingResultsToCanvas(BackBuffer); |
818 *status = ExternalSourceImageStatus; | 826 *status = ExternalSourceImageStatus; |
819 | 827 |
820 // can't create SkImage from WebGLImageBufferSurface (contains only SkBi
tmap) | 828 // can't create SkImage from WebGLImageBufferSurface (contains only SkBi
tmap) |
821 return buffer()->copyImage(DontCopyBackingStore, Unscaled); | 829 return buffer()->copyImage(DontCopyBackingStore, Unscaled); |
822 } | 830 } |
823 | 831 |
824 RefPtr<SkImage> image = buffer()->newImageSnapshot(); | 832 RefPtr<SkImage> image = buffer()->newImageSnapshot(); |
825 if (image) { | 833 if (image) { |
826 *status = NormalSourceImageStatus; | 834 *status = NormalSourceImageStatus; |
827 return StaticBitmapImage::create(image.release()); | 835 return StaticBitmapImage::create(image.release()); |
828 } | 836 } |
829 | 837 |
830 *status = InvalidSourceImageStatus; | 838 *status = InvalidSourceImageStatus; |
831 return nullptr; | 839 return nullptr; |
832 } | 840 } |
833 | 841 |
834 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 842 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
835 { | 843 { |
836 return !originClean(); | 844 return !originClean(); |
837 } | 845 } |
838 | 846 |
839 FloatSize HTMLCanvasElement::sourceSize() const | 847 FloatSize HTMLCanvasElement::sourceSize() const |
840 { | 848 { |
841 return FloatSize(width(), height()); | 849 return FloatSize(width(), height()); |
842 } | 850 } |
843 | 851 |
844 } | 852 } |
OLD | NEW |