Chromium Code Reviews| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 { | 282 { |
| 283 if (rect.isEmpty()) | 283 if (rect.isEmpty()) |
| 284 return; | 284 return; |
| 285 m_imageBufferIsClear = false; | 285 m_imageBufferIsClear = false; |
| 286 clearCopiedImage(); | 286 clearCopiedImage(); |
| 287 if (layoutObject()) | 287 if (layoutObject()) |
| 288 layoutObject()->setMayNeedPaintInvalidation(); | 288 layoutObject()->setMayNeedPaintInvalidation(); |
| 289 m_dirtyRect.unite(rect); | 289 m_dirtyRect.unite(rect); |
| 290 if (m_context && m_context->is2d() && hasImageBuffer()) | 290 if (m_context && m_context->is2d() && hasImageBuffer()) |
| 291 buffer()->didDraw(rect); | 291 buffer()->didDraw(rect); |
| 292 notifyObserversCanvasChanged(m_dirtyRect); | 292 notifyObserversCanvasChanged(rect); |
|
Stephen White
2015/05/27 15:46:02
Out of curiosity, is this a bugfix / optimization?
Justin Novosad
2015/05/27 20:08:16
Drive-by optimization. We use to do these notifica
| |
| 293 } | 293 } |
| 294 | 294 |
| 295 void HTMLCanvasElement::didFinalizeFrame() | 295 void HTMLCanvasElement::didFinalizeFrame() |
| 296 { | 296 { |
| 297 if (m_dirtyRect.isEmpty()) | 297 if (m_dirtyRect.isEmpty()) |
| 298 return; | 298 return; |
| 299 | 299 |
| 300 // Propagate the m_dirtyRect accumulated so far to the compositor | 300 // Propagate the m_dirtyRect accumulated so far to the compositor |
| 301 // before restarting with a blank dirty rect. | 301 // before restarting with a blank dirty rect. |
| 302 FloatRect srcRect(0, 0, size().width(), size().height()); | 302 FloatRect srcRect(0, 0, size().width(), size().height()); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 m_didFailToCreateImageBuffer = false; | 675 m_didFailToCreateImageBuffer = false; |
| 676 | 676 |
| 677 updateExternallyAllocatedMemory(); | 677 updateExternallyAllocatedMemory(); |
| 678 | 678 |
| 679 if (is3D()) { | 679 if (is3D()) { |
| 680 // Early out for WebGL canvases | 680 // Early out for WebGL canvases |
| 681 return; | 681 return; |
| 682 } | 682 } |
| 683 | 683 |
| 684 m_imageBuffer->setClient(this); | 684 m_imageBuffer->setClient(this); |
| 685 m_imageBuffer->context()->setShouldClampToSourceRect(false); | |
| 686 m_imageBuffer->context()->disableAntialiasingOptimizationForHairlineImages() ; | |
| 687 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol ationQuality); | 685 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol ationQuality); |
|
Stephen White
2015/05/27 15:46:02
Is this still used / necessary? If we're no longer
Justin Novosad
2015/05/27 20:08:16
Acknowledged.
| |
| 688 // Enabling MSAA overrides a request to disable antialiasing. This is true r egardless of whether the | 686 // Enabling MSAA overrides a request to disable antialiasing. This is true r egardless of whether the |
| 689 // rendering mode is accelerated or not. For consistency, we don't want to a pply AA in accelerated | 687 // rendering mode is accelerated or not. For consistency, we don't want to a pply AA in accelerated |
| 690 // canvases but not in unaccelerated canvases. | 688 // canvases but not in unaccelerated canvases. |
| 691 if (!msaaSampleCount && document().settings() && !document().settings()->ant ialiased2dCanvasEnabled()) | 689 if (!msaaSampleCount && document().settings() && !document().settings()->ant ialiased2dCanvasEnabled()) |
| 692 m_imageBuffer->context()->setShouldAntialias(false); | 690 m_imageBuffer->context()->setShouldAntialias(false); |
| 693 #if ENABLE(ASSERT) | 691 #if ENABLE(ASSERT) |
| 694 m_imageBuffer->context()->disableDestructionChecks(); // 2D canvas is allowe d to leave context in an unfinalized state. | 692 m_imageBuffer->context()->disableDestructionChecks(); // 2D canvas is allowe d to leave context in an unfinalized state. |
| 695 #endif | 693 #endif |
| 696 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer- >context())); | 694 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer- >context())); |
| 697 | 695 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 { | 896 { |
| 899 return FloatSize(width(), height()); | 897 return FloatSize(width(), height()); |
| 900 } | 898 } |
| 901 | 899 |
| 902 bool HTMLCanvasElement::isOpaque() const | 900 bool HTMLCanvasElement::isOpaque() const |
| 903 { | 901 { |
| 904 return m_context && !m_context->hasAlpha(); | 902 return m_context && !m_context->hasAlpha(); |
| 905 } | 903 } |
| 906 | 904 |
| 907 } // blink | 905 } // blink |
| OLD | NEW |