| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 static const int DefaultHeight = 150; | 58 static const int DefaultHeight = 150; |
| 59 | 59 |
| 60 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it | 60 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it |
| 61 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, | 61 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, |
| 62 // in exchange for a smaller maximum canvas size. | 62 // in exchange for a smaller maximum canvas size. |
| 63 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els | 63 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els |
| 64 | 64 |
| 65 //In Skia, we will also limit width/height to 32767. | 65 //In Skia, we will also limit width/height to 32767. |
| 66 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. | 66 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. |
| 67 | 67 |
| 68 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& doc
ument) | 68 HTMLCanvasElement::HTMLCanvasElement(Document& document) |
| 69 : HTMLElement(tagName, document) | 69 : HTMLElement(canvasTag, document) |
| 70 , m_size(DefaultWidth, DefaultHeight) | 70 , m_size(DefaultWidth, DefaultHeight) |
| 71 , m_rendererIsCanvas(false) | 71 , m_rendererIsCanvas(false) |
| 72 , m_ignoreReset(false) | 72 , m_ignoreReset(false) |
| 73 , m_accelerationDisabled(false) | 73 , m_accelerationDisabled(false) |
| 74 , m_externallyAllocatedMemory(0) | 74 , m_externallyAllocatedMemory(0) |
| 75 , m_deviceScaleFactor(1) | 75 , m_deviceScaleFactor(1) |
| 76 , m_originClean(true) | 76 , m_originClean(true) |
| 77 , m_hasCreatedImageBuffer(false) | 77 , m_hasCreatedImageBuffer(false) |
| 78 , m_didClearImageBuffer(false) | 78 , m_didClearImageBuffer(false) |
| 79 { | 79 { |
| 80 ASSERT(hasTagName(canvasTag)); | |
| 81 ScriptWrappable::init(this); | 80 ScriptWrappable::init(this); |
| 82 } | 81 } |
| 83 | 82 |
| 84 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document& document) | 83 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document& document) |
| 85 { | 84 { |
| 86 return adoptRef(new HTMLCanvasElement(canvasTag, document)); | 85 return adoptRef(new HTMLCanvasElement(document)); |
| 87 } | |
| 88 | |
| 89 PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(const QualifiedName& tag
Name, Document& document) | |
| 90 { | |
| 91 return adoptRef(new HTMLCanvasElement(tagName, document)); | |
| 92 } | 86 } |
| 93 | 87 |
| 94 HTMLCanvasElement::~HTMLCanvasElement() | 88 HTMLCanvasElement::~HTMLCanvasElement() |
| 95 { | 89 { |
| 96 setExternallyAllocatedMemory(0); | 90 setExternallyAllocatedMemory(0); |
| 97 HashSet<CanvasObserver*>::iterator end = m_observers.end(); | 91 HashSet<CanvasObserver*>::iterator end = m_observers.end(); |
| 98 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end;
++it) | 92 for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end;
++it) |
| 99 (*it)->canvasDestroyed(this); | 93 (*it)->canvasDestroyed(this); |
| 100 | 94 |
| 101 m_context.clear(); // Ensure this goes away before the ImageBuffer. | 95 m_context.clear(); // Ensure this goes away before the ImageBuffer. |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 ASSERT(m_hasCreatedImageBuffer); | 549 ASSERT(m_hasCreatedImageBuffer); |
| 556 IntSize unscaledSize = size(); | 550 IntSize unscaledSize = size(); |
| 557 IntSize size = convertLogicalToDevice(unscaledSize); | 551 IntSize size = convertLogicalToDevice(unscaledSize); |
| 558 AffineTransform transform; | 552 AffineTransform transform; |
| 559 if (size.width() && size.height()) | 553 if (size.width() && size.height()) |
| 560 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); | 554 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); |
| 561 return m_imageBuffer->baseTransform() * transform; | 555 return m_imageBuffer->baseTransform() * transform; |
| 562 } | 556 } |
| 563 | 557 |
| 564 } | 558 } |
| OLD | NEW |