Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: Source/core/html/HTMLCanvasElement.cpp

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: pdr corrections + needsrebaselines Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698