| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 134 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| 135 { | 135 { |
| 136 if (name == widthAttr || name == heightAttr) | 136 if (name == widthAttr || name == heightAttr) |
| 137 reset(); | 137 reset(); |
| 138 HTMLElement::parseAttribute(name, value); | 138 HTMLElement::parseAttribute(name, value); |
| 139 } | 139 } |
| 140 | 140 |
| 141 LayoutObject* HTMLCanvasElement::createLayoutObject(const LayoutStyle& style) | 141 LayoutObject* HTMLCanvasElement::createLayoutObject(const ComputedStyle& style) |
| 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 LayoutHTMLCanvas(this); | 145 return new LayoutHTMLCanvas(this); |
| 146 return HTMLElement::createLayoutObject(style); | 146 return HTMLElement::createLayoutObject(style); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) | 149 void HTMLCanvasElement::didRecalcStyle(StyleRecalcChange) |
| 150 { | 150 { |
| 151 SkFilterQuality filterQuality = computedStyle()->imageRendering() == ImageRe
nderingPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality; | 151 SkFilterQuality filterQuality = ensureComputedStyle()->imageRendering() == I
mageRenderingPixelated ? kNone_SkFilterQuality : kLow_SkFilterQuality; |
| 152 if (is3D()) { | 152 if (is3D()) { |
| 153 toWebGLRenderingContextBase(m_context.get())->setFilterQuality(filterQua
lity); | 153 toWebGLRenderingContextBase(m_context.get())->setFilterQuality(filterQua
lity); |
| 154 setNeedsCompositingUpdate(); | 154 setNeedsCompositingUpdate(); |
| 155 } else if (hasImageBuffer()) { | 155 } else if (hasImageBuffer()) { |
| 156 m_imageBuffer->setFilterQuality(filterQuality); | 156 m_imageBuffer->setFilterQuality(filterQuality); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) | 160 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(ContainerNode
* node) |
| 161 { | 161 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 is3dContext = false; | 243 is3dContext = false; |
| 244 | 244 |
| 245 if (is3dContext) { | 245 if (is3dContext) { |
| 246 if (!m_context) { | 246 if (!m_context) { |
| 247 blink::Platform::current()->histogramEnumeration("Canvas.ContextType
", contextType, ContextTypeCount); | 247 blink::Platform::current()->histogramEnumeration("Canvas.ContextType
", contextType, ContextTypeCount); |
| 248 if (contextType == ContextWebgl2) { | 248 if (contextType == ContextWebgl2) { |
| 249 m_context = WebGL2RenderingContext::create(this, attributes); | 249 m_context = WebGL2RenderingContext::create(this, attributes); |
| 250 } else { | 250 } else { |
| 251 m_context = WebGLRenderingContext::create(this, attributes); | 251 m_context = WebGLRenderingContext::create(this, attributes); |
| 252 } | 252 } |
| 253 const LayoutStyle* style = computedStyle(); | 253 const ComputedStyle* style = ensureComputedStyle(); |
| 254 if (style && m_context) | 254 if (style && m_context) |
| 255 toWebGLRenderingContextBase(m_context.get())->setFilterQuality(s
tyle->imageRendering() == ImageRenderingPixelated ? kNone_SkFilterQuality : kLow
_SkFilterQuality); | 255 toWebGLRenderingContextBase(m_context.get())->setFilterQuality(s
tyle->imageRendering() == ImageRenderingPixelated ? kNone_SkFilterQuality : kLow
_SkFilterQuality); |
| 256 setNeedsCompositingUpdate(); | 256 setNeedsCompositingUpdate(); |
| 257 updateExternallyAllocatedMemory(); | 257 updateExternallyAllocatedMemory(); |
| 258 } else if (!m_context->is3d()) { | 258 } else if (!m_context->is3d()) { |
| 259 dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, "Canvas has an existing, non-WebGL context")); | 259 dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext
creationerror, false, true, "Canvas has an existing, non-WebGL context")); |
| 260 return; | 260 return; |
| 261 } | 261 } |
| 262 result.setWebGLRenderingContext(static_cast<WebGLRenderingContext*>(m_co
ntext.get())); | 262 result.setWebGLRenderingContext(static_cast<WebGLRenderingContext*>(m_co
ntext.get())); |
| 263 } | 263 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 surface = externalSurface; | 631 surface = externalSurface; |
| 632 } else { | 632 } else { |
| 633 surface = createImageBufferSurface(size(), &msaaSampleCount); | 633 surface = createImageBufferSurface(size(), &msaaSampleCount); |
| 634 } | 634 } |
| 635 m_imageBuffer = ImageBuffer::create(surface.release()); | 635 m_imageBuffer = ImageBuffer::create(surface.release()); |
| 636 if (!m_imageBuffer) | 636 if (!m_imageBuffer) |
| 637 return; | 637 return; |
| 638 m_imageBuffer->setClient(this); | 638 m_imageBuffer->setClient(this); |
| 639 | 639 |
| 640 document().updateRenderTreeIfNeeded(); | 640 document().updateRenderTreeIfNeeded(); |
| 641 const LayoutStyle* style = computedStyle(); | 641 const ComputedStyle* style = ensureComputedStyle(); |
| 642 m_imageBuffer->setFilterQuality((style && (style->imageRendering() == ImageR
enderingPixelated)) ? kNone_SkFilterQuality : kLow_SkFilterQuality); | 642 m_imageBuffer->setFilterQuality((style && (style->imageRendering() == ImageR
enderingPixelated)) ? kNone_SkFilterQuality : kLow_SkFilterQuality); |
| 643 | 643 |
| 644 m_didFailToCreateImageBuffer = false; | 644 m_didFailToCreateImageBuffer = false; |
| 645 | 645 |
| 646 updateExternallyAllocatedMemory(); | 646 updateExternallyAllocatedMemory(); |
| 647 | 647 |
| 648 if (is3D()) { | 648 if (is3D()) { |
| 649 // Early out for WebGL canvases | 649 // Early out for WebGL canvases |
| 650 return; | 650 return; |
| 651 } | 651 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 { | 869 { |
| 870 return FloatSize(width(), height()); | 870 return FloatSize(width(), height()); |
| 871 } | 871 } |
| 872 | 872 |
| 873 bool HTMLCanvasElement::isOpaque() const | 873 bool HTMLCanvasElement::isOpaque() const |
| 874 { | 874 { |
| 875 return m_context && !m_context->hasAlpha(); | 875 return m_context && !m_context->hasAlpha(); |
| 876 } | 876 } |
| 877 | 877 |
| 878 } // blink | 878 } // blink |
| OLD | NEW |