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

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

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 592 }
593 } 593 }
594 } 594 }
595 595
596 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) 596 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument)
597 { 597 {
598 setObservedDocument(document()); 598 setObservedDocument(document());
599 HTMLElement::didMoveToNewDocument(oldDocument); 599 HTMLElement::didMoveToNewDocument(oldDocument);
600 } 600 }
601 601
602 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(HTMLCanvasElement* canvas, ExceptionState& exceptionState, CanvasImageSourceUsage usage, bool* isVo latile) const
603 {
604 if (isVolatile)
605 *isVolatile = false;
606 if (!width() || !height()) {
607 if (usage == PatternCanvasImageSourceUsage)
608 exceptionState.throwDOMException(InvalidStateError, String::format(" The canvas %s is 0.", canvas->width() ? "height" : "width"));
609 return nullptr;
610 }
611
612 if (usage == PatternCanvasImageSourceUsage || canvas == this)
613 return copiedImage();
Stephen White 2014/02/27 18:53:41 You might want to check the canvas-to-canvas self-
614
615 if (m_context && m_context->is3d()) {
616 m_context->paintRenderingResultsToCanvas();
617 *isVolatile = true;
Stephen White 2014/02/27 18:53:41 Please add a comment here indicating that this onl
618 }
619 return buffer() ? m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled) : nullptr;
602 } 620 }
621
622 bool HTMLCanvasElement::wouldTaintOrigin(CanvasRenderingContext* dst) const
623 {
624 return !originClean();
625 }
626
627 FloatSize HTMLCanvasElement::sourceSize() const
628 {
629 return FloatSize(width(), height());
630 }
631
632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698