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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it | 64 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it |
65 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, | 65 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, |
66 // in exchange for a smaller maximum canvas size. | 66 // in exchange for a smaller maximum canvas size. |
67 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els | 67 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix
els |
68 | 68 |
69 //In Skia, we will also limit width/height to 32767. | 69 //In Skia, we will also limit width/height to 32767. |
70 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. | 70 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. |
71 | 71 |
72 HTMLCanvasElement::HTMLCanvasElement(Document& document) | 72 HTMLCanvasElement::HTMLCanvasElement(Document& document) |
73 : HTMLElement(canvasTag, document) | 73 : HTMLElement(canvasTag, document) |
| 74 , DocumentVisibilityObserver(document) |
74 , m_size(DefaultWidth, DefaultHeight) | 75 , m_size(DefaultWidth, DefaultHeight) |
75 , m_rendererIsCanvas(false) | 76 , m_rendererIsCanvas(false) |
76 , m_ignoreReset(false) | 77 , m_ignoreReset(false) |
77 , m_accelerationDisabled(false) | 78 , m_accelerationDisabled(false) |
78 , m_externallyAllocatedMemory(0) | 79 , m_externallyAllocatedMemory(0) |
79 , m_originClean(true) | 80 , m_originClean(true) |
80 , m_didFailToCreateImageBuffer(false) | 81 , m_didFailToCreateImageBuffer(false) |
81 , m_didClearImageBuffer(false) | 82 , m_didClearImageBuffer(false) |
82 { | 83 { |
83 ScriptWrappable::init(this); | 84 ScriptWrappable::init(this); |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 m_copiedImage.clear(); | 565 m_copiedImage.clear(); |
565 m_didClearImageBuffer = false; | 566 m_didClearImageBuffer = false; |
566 } | 567 } |
567 | 568 |
568 AffineTransform HTMLCanvasElement::baseTransform() const | 569 AffineTransform HTMLCanvasElement::baseTransform() const |
569 { | 570 { |
570 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); | 571 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); |
571 return m_imageBuffer->baseTransform(); | 572 return m_imageBuffer->baseTransform(); |
572 } | 573 } |
573 | 574 |
| 575 void HTMLCanvasElement::didChangeVisibilityState(PageVisibilityState visibility) |
| 576 { |
| 577 if (hasImageBuffer()) { |
| 578 bool hidden = visibility != PageVisibilityStateVisible; |
| 579 if (hidden) { |
| 580 clearCopiedImage(); |
| 581 if (is3D()) { |
| 582 m_imageBuffer.clear(); |
| 583 } |
| 584 } |
| 585 if (hasImageBuffer()) { |
| 586 m_imageBuffer->setIsHidden(hidden); |
| 587 } |
| 588 } |
574 } | 589 } |
| 590 |
| 591 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) |
| 592 { |
| 593 setObservedDocument(document()); |
| 594 HTMLElement::didMoveToNewDocument(oldDocument); |
| 595 } |
| 596 |
| 597 } |
OLD | NEW |