| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const | 329 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const |
| 330 { | 330 { |
| 331 if (m_context) | 331 if (m_context) |
| 332 m_context->restoreCanvasMatrixClipStack(canvas); | 332 m_context->restoreCanvasMatrixClipStack(canvas); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void HTMLCanvasElement::doDeferredPaintInvalidation() | 335 void HTMLCanvasElement::doDeferredPaintInvalidation() |
| 336 { | 336 { |
| 337 ASSERT(!m_dirtyRect.isEmpty()); | 337 ASSERT(!m_dirtyRect.isEmpty()); |
| 338 if (is3D()) { | 338 if (!m_context->is2d()) { |
| 339 didFinalizeFrame(); | 339 didFinalizeFrame(); |
| 340 } else { | 340 } else { |
| 341 ASSERT(hasImageBuffer()); | 341 ASSERT(hasImageBuffer()); |
| 342 FloatRect srcRect(0, 0, size().width(), size().height()); | 342 FloatRect srcRect(0, 0, size().width(), size().height()); |
| 343 m_dirtyRect.intersect(srcRect); | 343 m_dirtyRect.intersect(srcRect); |
| 344 LayoutBox* lb = layoutBox(); | 344 LayoutBox* lb = layoutBox(); |
| 345 if (lb) { | 345 if (lb) { |
| 346 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect(
lb->contentBoxRect())); | 346 FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, FloatRect(
lb->contentBoxRect())); |
| 347 if (m_context->isAccelerated()) { | 347 if (m_context->isAccelerated()) { |
| 348 // Accelerated 2D canvases need the dirty rect to be expressed r
elative to the | 348 // Accelerated 2D canvases need the dirty rect to be expressed r
elative to the |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 454 } |
| 455 | 455 |
| 456 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) | 456 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) |
| 457 { | 457 { |
| 458 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and com
positing feature. | 458 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and com
positing feature. |
| 459 if (!m_context) | 459 if (!m_context) |
| 460 return; | 460 return; |
| 461 if (!paintsIntoCanvasBuffer() && !document().printing()) | 461 if (!paintsIntoCanvasBuffer() && !document().printing()) |
| 462 return; | 462 return; |
| 463 | 463 |
| 464 // TODO(junov): Paint is currently only implemented by ImageBitmap contexts. |
| 465 // We could improve the abstraction by making all context types paint |
| 466 // themselves (implement paint()). |
| 467 if (m_context->paint(context, pixelSnappedIntRect(r))) |
| 468 return; |
| 469 |
| 464 m_context->paintRenderingResultsToCanvas(FrontBuffer); | 470 m_context->paintRenderingResultsToCanvas(FrontBuffer); |
| 465 if (hasImageBuffer()) { | 471 if (hasImageBuffer()) { |
| 466 if (!context.contextDisabled()) { | 472 if (!context.contextDisabled()) { |
| 467 SkXfermode::Mode compositeOperator = !m_context || m_context->hasAlp
ha() ? SkXfermode::kSrcOver_Mode : SkXfermode::kSrc_Mode; | 473 SkXfermode::Mode compositeOperator = !m_context || m_context->hasAlp
ha() ? SkXfermode::kSrcOver_Mode : SkXfermode::kSrc_Mode; |
| 468 buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator
); | 474 buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator
); |
| 469 } | 475 } |
| 470 } else { | 476 } else { |
| 471 // When alpha is false, we should draw to opaque black. | 477 // When alpha is false, we should draw to opaque black. |
| 472 if (!m_context->hasAlpha()) | 478 if (!m_context->hasAlpha()) |
| 473 context.fillRect(FloatRect(r), Color(0, 0, 0)); | 479 context.fillRect(FloatRect(r), Color(0, 0, 0)); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 } | 1031 } |
| 1026 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); | 1032 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); |
| 1027 } | 1033 } |
| 1028 | 1034 |
| 1029 bool HTMLCanvasElement::isOpaque() const | 1035 bool HTMLCanvasElement::isOpaque() const |
| 1030 { | 1036 { |
| 1031 return m_context && !m_context->hasAlpha(); | 1037 return m_context && !m_context->hasAlpha(); |
| 1032 } | 1038 } |
| 1033 | 1039 |
| 1034 } // namespace blink | 1040 } // namespace blink |
| OLD | NEW |