| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 if (!m_context->isAccelerated()) | 296 if (!m_context->isAccelerated()) |
| 297 return true; | 297 return true; |
| 298 | 298 |
| 299 if (renderBox() && renderBox()->hasAcceleratedCompositing()) | 299 if (renderBox() && renderBox()->hasAcceleratedCompositing()) |
| 300 return false; | 300 return false; |
| 301 | 301 |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, boo
l useLowQualityScale) | 306 void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r) |
| 307 { | 307 { |
| 308 // Clear the dirty rect | 308 // Clear the dirty rect |
| 309 m_dirtyRect = FloatRect(); | 309 m_dirtyRect = FloatRect(); |
| 310 | 310 |
| 311 if (context->paintingDisabled()) | 311 if (context->paintingDisabled()) |
| 312 return; | 312 return; |
| 313 | 313 |
| 314 if (m_context) { | 314 if (m_context) { |
| 315 if (!paintsIntoCanvasBuffer() && !document().printing()) | 315 if (!paintsIntoCanvasBuffer() && !document().printing()) |
| 316 return; | 316 return; |
| 317 m_context->paintRenderingResultsToCanvas(); | 317 m_context->paintRenderingResultsToCanvas(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 if (hasImageBuffer()) { | 320 if (hasImageBuffer()) { |
| 321 ImageBuffer* imageBuffer = buffer(); | 321 ImageBuffer* imageBuffer = buffer(); |
| 322 if (imageBuffer) { | 322 if (imageBuffer) { |
| 323 CompositeOperator compositeOperator = !m_context || m_context->hasAl
pha() ? CompositeSourceOver : CompositeCopy; | 323 CompositeOperator compositeOperator = !m_context || m_context->hasAl
pha() ? CompositeSourceOver : CompositeCopy; |
| 324 if (m_presentedImage) | 324 if (m_presentedImage) |
| 325 context->drawImage(m_presentedImage.get(), pixelSnappedIntRect(r
), compositeOperator, DoNotRespectImageOrientation, useLowQualityScale); | 325 context->drawImage(m_presentedImage.get(), pixelSnappedIntRect(r
), compositeOperator, DoNotRespectImageOrientation); |
| 326 else | 326 else |
| 327 context->drawImageBuffer(imageBuffer, pixelSnappedIntRect(r), co
mpositeOperator, blink::WebBlendModeNormal, useLowQualityScale); | 327 context->drawImageBuffer(imageBuffer, pixelSnappedIntRect(r), co
mpositeOperator, blink::WebBlendModeNormal); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 if (is3D()) | 331 if (is3D()) |
| 332 toWebGLRenderingContext(m_context.get())->markLayerComposited(); | 332 toWebGLRenderingContext(m_context.get())->markLayerComposited(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool HTMLCanvasElement::is3D() const | 335 bool HTMLCanvasElement::is3D() const |
| 336 { | 336 { |
| 337 return m_context && m_context->is3d(); | 337 return m_context && m_context->is3d(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 m_didFailToCreateImageBuffer = false; | 475 m_didFailToCreateImageBuffer = false; |
| 476 | 476 |
| 477 updateExternallyAllocatedMemory(); | 477 updateExternallyAllocatedMemory(); |
| 478 | 478 |
| 479 if (is3D()) { | 479 if (is3D()) { |
| 480 // Early out for WebGL canvases | 480 // Early out for WebGL canvases |
| 481 return; | 481 return; |
| 482 } | 482 } |
| 483 | 483 |
| 484 m_imageBuffer->context()->setShouldClampToSourceRect(false); | 484 m_imageBuffer->context()->setShouldClampToSourceRect(false); |
| 485 m_imageBuffer->context()->setImageInterpolationQuality(DefaultInterpolationQ
uality); | 485 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol
ationQuality); |
| 486 // Enabling MSAA overrides a request to disable antialiasing. This is true r
egardless of whether the | 486 // Enabling MSAA overrides a request to disable antialiasing. This is true r
egardless of whether the |
| 487 // rendering mode is accelerated or not. For consistency, we don't want to a
pply AA in accelerated | 487 // rendering mode is accelerated or not. For consistency, we don't want to a
pply AA in accelerated |
| 488 // canvases but not in unaccelerated canvases. | 488 // canvases but not in unaccelerated canvases. |
| 489 if (!msaaSampleCount && document().settings() && !document().settings()->ant
ialiased2dCanvasEnabled()) | 489 if (!msaaSampleCount && document().settings() && !document().settings()->ant
ialiased2dCanvasEnabled()) |
| 490 m_imageBuffer->context()->setShouldAntialias(false); | 490 m_imageBuffer->context()->setShouldAntialias(false); |
| 491 // GraphicsContext's defaults don't always agree with the 2d canvas spec. | 491 // GraphicsContext's defaults don't always agree with the 2d canvas spec. |
| 492 // See CanvasRenderingContext2D::State::State() for more information. | 492 // See CanvasRenderingContext2D::State::State() for more information. |
| 493 m_imageBuffer->context()->setMiterLimit(10); | 493 m_imageBuffer->context()->setMiterLimit(10); |
| 494 m_imageBuffer->context()->setStrokeThickness(1); | 494 m_imageBuffer->context()->setStrokeThickness(1); |
| 495 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer-
>context())); | 495 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer-
>context())); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 { | 653 { |
| 654 return !originClean(); | 654 return !originClean(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 FloatSize HTMLCanvasElement::sourceSize() const | 657 FloatSize HTMLCanvasElement::sourceSize() const |
| 658 { | 658 { |
| 659 return FloatSize(width(), height()); | 659 return FloatSize(width(), height()); |
| 660 } | 660 } |
| 661 | 661 |
| 662 } | 662 } |
| OLD | NEW |