| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 static const int DefaultHeight = 150; | 59 static const int DefaultHeight = 150; |
| 60 | 60 |
| 61 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it | 61 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it |
| 62 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, | 62 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, |
| 63 // in exchange for a smaller maximum canvas size. | 63 // in exchange for a smaller maximum canvas size. |
| 64 static const float MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS p
ixels | 64 static const float MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS p
ixels |
| 65 | 65 |
| 66 //In Skia, we will also limit width/height to 32767. | 66 //In Skia, we will also limit width/height to 32767. |
| 67 static const float MaxSkiaDim = 32767.0F; // Maximum width/height in CSS pixels. | 67 static const float MaxSkiaDim = 32767.0F; // Maximum width/height in CSS pixels. |
| 68 | 68 |
| 69 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document* doc
ument) | 69 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& doc
ument) |
| 70 : HTMLElement(tagName, document) | 70 : HTMLElement(tagName, document) |
| 71 , m_size(DefaultWidth, DefaultHeight) | 71 , m_size(DefaultWidth, DefaultHeight) |
| 72 , m_rendererIsCanvas(false) | 72 , m_rendererIsCanvas(false) |
| 73 , m_ignoreReset(false) | 73 , m_ignoreReset(false) |
| 74 , m_deviceScaleFactor(1) | 74 , m_deviceScaleFactor(1) |
| 75 , m_originClean(true) | 75 , m_originClean(true) |
| 76 , m_hasCreatedImageBuffer(false) | 76 , m_hasCreatedImageBuffer(false) |
| 77 , m_didClearImageBuffer(false) | 77 , m_didClearImageBuffer(false) |
| 78 , m_accelerationDisabled(false) | 78 , m_accelerationDisabled(false) |
| 79 , m_externallyAllocatedMemory(0) | 79 , m_externallyAllocatedMemory(0) |
| 80 { | 80 { |
| 81 ASSERT(hasTagName(canvasTag)); | 81 ASSERT(hasTagName(canvasTag)); |
| 82 ScriptWrappable::init(this); | 82 ScriptWrappable::init(this); |
| 83 } | 83 } |
| 84 | 84 |
| 85 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document* document) | 85 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document& document) |
| 86 { | 86 { |
| 87 return adoptRef(new HTMLCanvasElement(canvasTag, document)); | 87 return adoptRef(new HTMLCanvasElement(canvasTag, document)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(const QualifiedName& tag
Name, Document* document) | 90 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(const QualifiedName& tag
Name, Document& document) |
| 91 { | 91 { |
| 92 return adoptRef(new HTMLCanvasElement(tagName, document)); | 92 return adoptRef(new HTMLCanvasElement(tagName, document)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 HTMLCanvasElement::~HTMLCanvasElement() | 95 HTMLCanvasElement::~HTMLCanvasElement() |
| 96 { | 96 { |
| 97 setExternallyAllocatedMemory(0); | 97 setExternallyAllocatedMemory(0); |
| 98 HashSet<CanvasObserver*>::iterator end = m_observers.end(); | 98 HashSet<CanvasObserver*>::iterator end = m_observers.end(); |
| 99 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end;
++it) | 99 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end;
++it) |
| 100 (*it)->canvasDestroyed(this); | 100 (*it)->canvasDestroyed(this); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 FloatSize unscaledSize = size(); | 579 FloatSize unscaledSize = size(); |
| 580 FloatSize deviceSize = convertLogicalToDevice(unscaledSize); | 580 FloatSize deviceSize = convertLogicalToDevice(unscaledSize); |
| 581 IntSize size(deviceSize.width(), deviceSize.height()); | 581 IntSize size(deviceSize.width(), deviceSize.height()); |
| 582 AffineTransform transform; | 582 AffineTransform transform; |
| 583 if (size.width() && size.height()) | 583 if (size.width() && size.height()) |
| 584 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); | 584 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); |
| 585 return m_imageBuffer->baseTransform() * transform; | 585 return m_imageBuffer->baseTransform() * transform; |
| 586 } | 586 } |
| 587 | 587 |
| 588 } | 588 } |
| OLD | NEW |