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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return adoptRefWillBeRefCountedGarbageCollected(new HTMLCanvasElement(docume
nt)); | 91 return adoptRefWillBeRefCountedGarbageCollected(new HTMLCanvasElement(docume
nt)); |
92 } | 92 } |
93 | 93 |
94 HTMLCanvasElement::~HTMLCanvasElement() | 94 HTMLCanvasElement::~HTMLCanvasElement() |
95 { | 95 { |
96 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); | 96 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); |
97 #if !ENABLE(OILPAN) | 97 #if !ENABLE(OILPAN) |
98 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); | 98 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); |
99 for (HashSet<RawPtr<CanvasObserver> >::iterator it = m_observers.begin(); it
!= end; ++it) | 99 for (HashSet<RawPtr<CanvasObserver> >::iterator it = m_observers.begin(); it
!= end; ++it) |
100 (*it)->canvasDestroyed(this); | 100 (*it)->canvasDestroyed(this); |
101 m_context.clear(); // Ensure this goes away before the ImageBuffer. | 101 // Ensure these go away before the ImageBuffer. |
| 102 m_contextStateSaver.clear(); |
| 103 m_context.clear(); |
102 #endif | 104 #endif |
103 } | 105 } |
104 | 106 |
105 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 107 void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
106 { | 108 { |
107 if (name == widthAttr || name == heightAttr) | 109 if (name == widthAttr || name == heightAttr) |
108 reset(); | 110 reset(); |
109 HTMLElement::parseAttribute(name, value); | 111 HTMLElement::parseAttribute(name, value); |
110 } | 112 } |
111 | 113 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol
ationQuality); | 510 m_imageBuffer->context()->setImageInterpolationQuality(CanvasDefaultInterpol
ationQuality); |
509 // Enabling MSAA overrides a request to disable antialiasing. This is true r
egardless of whether the | 511 // Enabling MSAA overrides a request to disable antialiasing. This is true r
egardless of whether the |
510 // rendering mode is accelerated or not. For consistency, we don't want to a
pply AA in accelerated | 512 // rendering mode is accelerated or not. For consistency, we don't want to a
pply AA in accelerated |
511 // canvases but not in unaccelerated canvases. | 513 // canvases but not in unaccelerated canvases. |
512 if (!msaaSampleCount && document().settings() && !document().settings()->ant
ialiased2dCanvasEnabled()) | 514 if (!msaaSampleCount && document().settings() && !document().settings()->ant
ialiased2dCanvasEnabled()) |
513 m_imageBuffer->context()->setShouldAntialias(false); | 515 m_imageBuffer->context()->setShouldAntialias(false); |
514 // GraphicsContext's defaults don't always agree with the 2d canvas spec. | 516 // GraphicsContext's defaults don't always agree with the 2d canvas spec. |
515 // See CanvasRenderingContext2D::State::State() for more information. | 517 // See CanvasRenderingContext2D::State::State() for more information. |
516 m_imageBuffer->context()->setMiterLimit(10); | 518 m_imageBuffer->context()->setMiterLimit(10); |
517 m_imageBuffer->context()->setStrokeThickness(1); | 519 m_imageBuffer->context()->setStrokeThickness(1); |
| 520 #if !ASSERT_DISABLED |
| 521 m_imageBuffer->context()->disableDestructionChecks(); // 2D canvas is allowe
d to leave context in an unfinalized state. |
| 522 #endif |
518 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer-
>context())); | 523 m_contextStateSaver = adoptPtr(new GraphicsContextStateSaver(*m_imageBuffer-
>context())); |
519 | 524 |
520 if (m_context) | 525 if (m_context) |
521 setNeedsCompositingUpdate(); | 526 setNeedsCompositingUpdate(); |
522 } | 527 } |
523 | 528 |
524 void HTMLCanvasElement::notifySurfaceInvalid() | 529 void HTMLCanvasElement::notifySurfaceInvalid() |
525 { | 530 { |
526 if (m_context && m_context->is2d()) { | 531 if (m_context && m_context->is2d()) { |
527 CanvasRenderingContext2D* context2d = toCanvasRenderingContext2D(m_conte
xt.get()); | 532 CanvasRenderingContext2D* context2d = toCanvasRenderingContext2D(m_conte
xt.get()); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 { | 700 { |
696 return !originClean(); | 701 return !originClean(); |
697 } | 702 } |
698 | 703 |
699 FloatSize HTMLCanvasElement::sourceSize() const | 704 FloatSize HTMLCanvasElement::sourceSize() const |
700 { | 705 { |
701 return FloatSize(width(), height()); | 706 return FloatSize(width(), height()); |
702 } | 707 } |
703 | 708 |
704 } | 709 } |
OLD | NEW |