| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it | 66 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it |
| 67 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, | 67 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, |
| 68 // in exchange for a smaller maximum canvas size. | 68 // in exchange for a smaller maximum canvas size. |
| 69 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els | 69 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els |
| 70 | 70 |
| 71 //In Skia, we will also limit width/height to 32767. | 71 //In Skia, we will also limit width/height to 32767. |
| 72 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. | 72 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. |
| 73 | 73 |
| 74 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver); | 74 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver); |
| 75 | 75 |
| 76 HTMLCanvasElement::HTMLCanvasElement(Document& document) | 76 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) |
| 77 : HTMLElement(canvasTag, document) | 77 : HTMLElement(canvasTag, document) |
| 78 , DocumentVisibilityObserver(document) | 78 , DocumentVisibilityObserver(document) |
| 79 , m_size(DefaultWidth, DefaultHeight) | 79 , m_size(DefaultWidth, DefaultHeight) |
| 80 , m_ignoreReset(false) | 80 , m_ignoreReset(false) |
| 81 , m_accelerationDisabled(false) | 81 , m_accelerationDisabled(false) |
| 82 , m_externallyAllocatedMemory(0) | 82 , m_externallyAllocatedMemory(0) |
| 83 , m_originClean(true) | 83 , m_originClean(true) |
| 84 , m_didFailToCreateImageBuffer(false) | 84 , m_didFailToCreateImageBuffer(false) |
| 85 , m_didClearImageBuffer(false) | 85 , m_didClearImageBuffer(false) |
| 86 { | 86 { |
| 87 ScriptWrappable::init(this); | 87 ScriptWrappable::init(this); |
| 88 } | 88 } |
| 89 | 89 |
| 90 PassRefPtrWillBeRawPtr<HTMLCanvasElement> HTMLCanvasElement::create(Document& do
cument) | 90 DEFINE_NODE_FACTORY(HTMLCanvasElement) |
| 91 { | |
| 92 return adoptRefWillBeRefCountedGarbageCollected(new HTMLCanvasElement(docume
nt)); | |
| 93 } | |
| 94 | 91 |
| 95 HTMLCanvasElement::~HTMLCanvasElement() | 92 HTMLCanvasElement::~HTMLCanvasElement() |
| 96 { | 93 { |
| 97 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); | 94 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external
lyAllocatedMemory); |
| 98 #if !ENABLE(OILPAN) | 95 #if !ENABLE(OILPAN) |
| 99 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); | 96 HashSet<RawPtr<CanvasObserver> >::iterator end = m_observers.end(); |
| 100 for (HashSet<RawPtr<CanvasObserver> >::iterator it = m_observers.begin(); it
!= end; ++it) | 97 for (HashSet<RawPtr<CanvasObserver> >::iterator it = m_observers.begin(); it
!= end; ++it) |
| 101 (*it)->canvasDestroyed(this); | 98 (*it)->canvasDestroyed(this); |
| 102 // Ensure these go away before the ImageBuffer. | 99 // Ensure these go away before the ImageBuffer. |
| 103 m_contextStateSaver.clear(); | 100 m_contextStateSaver.clear(); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 { | 696 { |
| 700 return !originClean(); | 697 return !originClean(); |
| 701 } | 698 } |
| 702 | 699 |
| 703 FloatSize HTMLCanvasElement::sourceSize() const | 700 FloatSize HTMLCanvasElement::sourceSize() const |
| 704 { | 701 { |
| 705 return FloatSize(width(), height()); | 702 return FloatSize(width(), height()); |
| 706 } | 703 } |
| 707 | 704 |
| 708 } | 705 } |
| OLD | NEW |