Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: sky/engine/core/html/HTMLCanvasElement.cpp

Issue 714953002: Remove DocumentVisibilityObserver (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/html/HTMLCanvasElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // in exchange for a smaller maximum canvas size. 69 // in exchange for a smaller maximum canvas size.
70 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix els 70 static const int MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pix els
71 71
72 //In Skia, we will also limit width/height to 32767. 72 //In Skia, we will also limit width/height to 32767.
73 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels. 73 static const int MaxSkiaDim = 32767; // Maximum width/height in CSS pixels.
74 74
75 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver); 75 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver);
76 76
77 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) 77 inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
78 : HTMLElement(HTMLNames::canvasTag, document) 78 : HTMLElement(HTMLNames::canvasTag, document)
79 , DocumentVisibilityObserver(document)
80 , m_size(DefaultWidth, DefaultHeight) 79 , m_size(DefaultWidth, DefaultHeight)
81 , m_ignoreReset(false) 80 , m_ignoreReset(false)
82 , m_accelerationDisabled(false) 81 , m_accelerationDisabled(false)
83 , m_externallyAllocatedMemory(0) 82 , m_externallyAllocatedMemory(0)
84 , m_didFailToCreateImageBuffer(false) 83 , m_didFailToCreateImageBuffer(false)
85 , m_didClearImageBuffer(false) 84 , m_didClearImageBuffer(false)
86 { 85 {
87 } 86 }
88 87
89 DEFINE_NODE_FACTORY(HTMLCanvasElement) 88 DEFINE_NODE_FACTORY(HTMLCanvasElement)
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 644 }
646 m_didClearImageBuffer = false; 645 m_didClearImageBuffer = false;
647 } 646 }
648 647
649 AffineTransform HTMLCanvasElement::baseTransform() const 648 AffineTransform HTMLCanvasElement::baseTransform() const
650 { 649 {
651 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); 650 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer);
652 return m_imageBuffer->baseTransform(); 651 return m_imageBuffer->baseTransform();
653 } 652 }
654 653
655 void HTMLCanvasElement::didChangeVisibilityState(PageVisibilityState visibility)
656 {
657 if (!m_context)
658 return;
659 bool hidden = visibility != PageVisibilityStateVisible;
660 m_context->setIsHidden(hidden);
661 if (hidden) {
662 clearCopiedImage();
663 if (is3D()) {
664 discardImageBuffer();
665 }
666 }
667 }
668
669 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument)
670 {
671 setObservedDocument(document());
672 HTMLElement::didMoveToNewDocument(oldDocument);
673 }
674
675 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageMode mod e, SourceImageStatus* status) const 654 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageMode mod e, SourceImageStatus* status) const
676 { 655 {
677 if (!width() || !height()) { 656 if (!width() || !height()) {
678 *status = ZeroSizeCanvasSourceImageStatus; 657 *status = ZeroSizeCanvasSourceImageStatus;
679 return nullptr; 658 return nullptr;
680 } 659 }
681 660
682 if (!buffer()) { 661 if (!buffer()) {
683 *status = InvalidSourceImageStatus; 662 *status = InvalidSourceImageStatus;
684 return nullptr; 663 return nullptr;
(...skipping 12 matching lines...) Expand all
697 } 676 }
698 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled); 677 return m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled);
699 } 678 }
700 679
701 FloatSize HTMLCanvasElement::sourceSize() const 680 FloatSize HTMLCanvasElement::sourceSize() const
702 { 681 {
703 return FloatSize(width(), height()); 682 return FloatSize(width(), height());
704 } 683 }
705 684
706 } 685 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/HTMLCanvasElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698