WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-103864-20121203225308.patch (text/plain), 50.12 KB, created by
Jae Hyun Park
on 2012-12-03 22:55:01 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jae Hyun Park
Created:
2012-12-03 22:55:01 PST
Size:
50.12 KB
patch
obsolete
>Subversion Revision: 136461 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 6ab368fdd0887ccb909dc2ba2791a9713a67b5e4..8bef1c9943ae4da2cd5c089ac9063754a280ebf2 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,67 @@ >+2012-12-03 Jae Hyun Park <jae.park@company100.net> >+ >+ Coordinated Graphics: Move AreaAllocator and UpdateAtlas to CoordinatedGraphics >+ https://bugs.webkit.org/show_bug.cgi?id=103864 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ AreaAllocator and UpdateAtlas is only used for Coordinated Graphics. >+ So, these must be moved to CoordinatedGraphics to clarify the code. >+ >+ No new test, because no change of behavior. >+ >+ * CMakeLists.txt: >+ * Target.pri: >+ * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/AreaAllocator.cpp. >+ (WebKit): >+ (WebKit::AreaAllocator::AreaAllocator): >+ (WebKit::AreaAllocator::~AreaAllocator): >+ (WebKit::AreaAllocator::expand): >+ (WebKit::AreaAllocator::expandBy): >+ (WebKit::AreaAllocator::release): >+ (WebKit::AreaAllocator::overhead): >+ (WebKit::AreaAllocator::roundAllocation): >+ (WebKit::GeneralAreaAllocator::GeneralAreaAllocator): >+ (WebKit::GeneralAreaAllocator::~GeneralAreaAllocator): >+ (WebKit::GeneralAreaAllocator::freeNode): >+ (WebKit::GeneralAreaAllocator::expand): >+ (WebKit::fitsWithin): >+ (WebKit::GeneralAreaAllocator::allocate): >+ (WebKit::GeneralAreaAllocator::allocateFromNode): >+ (WebKit::GeneralAreaAllocator::splitNode): >+ (WebKit::GeneralAreaAllocator::updateLargestFree): >+ (WebKit::GeneralAreaAllocator::release): >+ (WebKit::GeneralAreaAllocator::overhead): >+ * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h: Renamed from Source/WebKit2/WebProcess/WebPage/AreaAllocator.h. >+ (WebCore::nextPowerOfTwo): >+ (WebCore): >+ (WebKit): >+ (AreaAllocator): >+ (WebKit::AreaAllocator::size): >+ (WebKit::AreaAllocator::minimumAllocation): >+ (WebKit::AreaAllocator::setMinimumAllocation): >+ (WebKit::AreaAllocator::margin): >+ (WebKit::AreaAllocator::setMargin): >+ (GeneralAreaAllocator): >+ (Node): >+ * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp. >+ (WebKit): >+ (WebKit::UpdateAtlas::UpdateAtlas): >+ (WebKit::UpdateAtlas::~UpdateAtlas): >+ (WebKit::UpdateAtlas::buildLayoutIfNeeded): >+ (WebKit::UpdateAtlas::didSwapBuffers): >+ (WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer): >+ * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h: Renamed from Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h. >+ (WebCore): >+ (WebKit): >+ (UpdateAtlasClient): >+ (UpdateAtlas): >+ (WebKit::UpdateAtlas::size): >+ (WebKit::UpdateAtlas::flags): >+ (WebKit::UpdateAtlas::addTimeInactive): >+ (WebKit::UpdateAtlas::isInactive): >+ (WebKit::UpdateAtlas::isInUse): >+ > 2012-12-03 Tim Horton <timothy_horton@apple.com> > > PDFPlugin: <embed> and <object> PDFs affect their parent frame's page scale >diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt >index ef6ec86b158e65e1adf44463c03435df82f801c5..fd249595f5c53c1d1a73dd78f4094f532883d76e 100644 >--- a/Source/WebKit2/CMakeLists.txt >+++ b/Source/WebKit2/CMakeLists.txt >@@ -481,11 +481,9 @@ SET(WebKit2_SOURCES > WebProcess/WebPage/EventDispatcher.cpp > WebProcess/WebPage/FindController.cpp > >- WebProcess/WebPage/AreaAllocator.cpp > WebProcess/WebPage/LayerTreeHost.cpp > WebProcess/WebPage/PageOverlay.cpp > WebProcess/WebPage/TapHighlightController.cpp >- WebProcess/WebPage/UpdateAtlas.cpp > WebProcess/WebPage/WebBackForwardListProxy.cpp > WebProcess/WebPage/WebContextMenu.cpp > WebProcess/WebPage/WebFrame.cpp >@@ -495,10 +493,12 @@ SET(WebKit2_SOURCES > WebProcess/WebPage/WebPageGroupProxy.cpp > WebProcess/WebPage/WebUndoStep.cpp > >+ WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp >+ WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp > ) > > SET(WebKit2_MESSAGES_IN_FILES >diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri >index f43401636425b655e6d6fef623be4316184939ea..02748804128b49da73a80a826ddf4d7b3e1ade8c 100644 >--- a/Source/WebKit2/Target.pri >+++ b/Source/WebKit2/Target.pri >@@ -363,18 +363,18 @@ HEADERS += \ > WebProcess/WebCoreSupport/WebSearchPopupMenu.h \ > WebProcess/WebCoreSupport/WebVibrationClient.h \ > WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h \ >- WebProcess/WebPage/AreaAllocator.h \ > WebProcess/WebPage/DrawingArea.h \ > WebProcess/WebPage/DrawingAreaImpl.h \ > WebProcess/WebPage/EventDispatcher.h \ > WebProcess/WebPage/FindController.h \ >+ WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h \ > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h \ >+ WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h \ > WebProcess/WebPage/TapHighlightController.h \ > WebProcess/WebPage/PageOverlay.h \ >- WebProcess/WebPage/UpdateAtlas.h \ > WebProcess/WebPage/WebContextMenu.h \ > WebProcess/WebPage/WebFrame.h \ > WebProcess/WebPage/WebInspector.h \ >@@ -744,21 +744,21 @@ SOURCES += \ > WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp \ > WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp \ > WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp \ >- WebProcess/WebPage/AreaAllocator.cpp \ > WebProcess/WebPage/DecoderAdapter.cpp \ > WebProcess/WebPage/DrawingArea.cpp \ > WebProcess/WebPage/DrawingAreaImpl.cpp \ > WebProcess/WebPage/EncoderAdapter.cpp \ > WebProcess/WebPage/EventDispatcher.cpp \ > WebProcess/WebPage/FindController.cpp \ >+ WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp \ > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp \ >+ WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp \ > WebProcess/WebPage/TapHighlightController.cpp \ > WebProcess/WebPage/LayerTreeHost.cpp \ > WebProcess/WebPage/PageOverlay.cpp \ >- WebProcess/WebPage/UpdateAtlas.cpp \ > WebProcess/WebPage/WebBackForwardListProxy.cpp \ > WebProcess/WebPage/WebContextMenu.cpp \ > WebProcess/WebPage/WebFrame.cpp \ >diff --git a/Source/WebKit2/WebProcess/WebPage/AreaAllocator.cpp b/Source/WebKit2/WebProcess/WebPage/AreaAllocator.cpp >deleted file mode 100644 >index 602efeb5f1aefa7e7af2251741ef67b1411b573c..0000000000000000000000000000000000000000 >--- a/Source/WebKit2/WebProcess/WebPage/AreaAllocator.cpp >+++ /dev/null >@@ -1,331 +0,0 @@ >-/* >- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2.1 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Lesser General Public License for more details. >- * >- * You should have received a copy of the GNU Lesser General Public >- * License along with this library; if not, write to the Free Software >- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >- * >- */ >- >-#include "config.h" >- >-#include "AreaAllocator.h" >- >-namespace WebKit { >- >-AreaAllocator::AreaAllocator(const WebCore::IntSize& size) >- : m_size(size) >- , m_minAlloc(1, 1) >- , m_margin(0, 0) >-{ >-} >- >-AreaAllocator::~AreaAllocator() >-{ >-} >- >-void AreaAllocator::expand(const WebCore::IntSize& size) >-{ >- m_size = m_size.expandedTo(size); >-} >- >-void AreaAllocator::expandBy(const WebCore::IntSize& size) >-{ >- m_size += size; >-} >- >-void AreaAllocator::release(const WebCore::IntRect&) >-{ >-} >- >-int AreaAllocator::overhead() const >-{ >- return 0; >-} >- >-WebCore::IntSize AreaAllocator::roundAllocation(const WebCore::IntSize& size) const >-{ >- int width = size.width() + m_margin.width(); >- int height = size.height() + m_margin.height(); >- int extra = width % m_minAlloc.width(); >- if (extra) >- width += m_minAlloc.width() - extra; >- extra = height % m_minAlloc.height(); >- if (extra) >- height += m_minAlloc.height() - extra; >- >- return WebCore::IntSize(width, height); >-} >- >-GeneralAreaAllocator::GeneralAreaAllocator(const WebCore::IntSize& size) >- : AreaAllocator(WebCore::nextPowerOfTwo(size)) >-{ >- m_root = new Node(); >- m_root->rect = WebCore::IntRect(0, 0, m_size.width(), m_size.height()); >- m_root->largestFree = m_size; >- m_root->parent = 0; >- m_root->left = 0; >- m_root->right = 0; >- m_nodeCount = 1; >- setMinimumAllocation(WebCore::IntSize(8, 8)); >-} >- >-GeneralAreaAllocator::~GeneralAreaAllocator() >-{ >- freeNode(m_root); >-} >- >-void GeneralAreaAllocator::freeNode(Node* node) >-{ >- if (node) { >- freeNode(node->left); >- freeNode(node->right); >- } >- delete node; >-} >- >-void GeneralAreaAllocator::expand(const WebCore::IntSize& size) >-{ >- AreaAllocator::expand(WebCore::nextPowerOfTwo(size)); >- >- if (m_root->rect.size() == m_size) >- return; // No change. >- >- if (!m_root->left && m_root->largestFree.width() > 0) { >- // No allocations have occurred, so just adjust the root size. >- m_root->rect = WebCore::IntRect(0, 0, m_size.width(), m_size.height()); >- m_root->largestFree = m_size; >- return; >- } >- >- // Add extra nodes above the current root to expand the tree. >- Node* oldRoot = m_root; >- Split split; >- if (m_size.width() >= m_size.height()) >- split = SplitOnX; >- else >- split = SplitOnY; >- >- while (m_root->rect.size() != m_size) { >- if (m_root->rect.width() == m_size.width()) >- split = SplitOnY; >- else if (m_root->rect.height() == m_size.height()) >- split = SplitOnX; >- Node* parent = new Node(); >- Node* right = new Node(); >- m_nodeCount += 2; >- m_root->parent = parent; >- parent->parent = 0; >- parent->left = m_root; >- parent->right = right; >- parent->largestFree = m_root->rect.size(); >- right->parent = parent; >- right->left = 0; >- right->right = 0; >- right->largestFree = m_root->rect.size(); >- if (split == SplitOnX) { >- parent->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y(), >- m_root->rect.width() * 2, m_root->rect.height()); >- right->rect = WebCore::IntRect(m_root->rect.x() + m_root->rect.width(), m_root->rect.y(), >- m_root->rect.width(), m_root->rect.height()); >- } else { >- parent->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y(), >- m_root->rect.width(), m_root->rect.height() * 2); >- right->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y() + m_root->rect.width(), >- m_root->rect.width(), m_root->rect.height()); >- } >- split = (split == SplitOnX ? SplitOnY : SplitOnX); >- m_root = parent; >- } >- updateLargestFree(oldRoot); >-} >- >-static inline bool fitsWithin(const WebCore::IntSize& size1, const WebCore::IntSize& size2) >-{ >- return size1.width() <= size2.width() && size1.height() <= size2.height(); >-} >- >-WebCore::IntRect GeneralAreaAllocator::allocate(const WebCore::IntSize& size) >-{ >- WebCore::IntSize rounded = roundAllocation(size); >- rounded = WebCore::nextPowerOfTwo(rounded); >- if (rounded.width() <= 0 || rounded.width() > m_size.width() >- || rounded.height() <= 0 || rounded.height() > m_size.height()) >- return WebCore::IntRect(); >- >- WebCore::IntPoint point = allocateFromNode(rounded, m_root); >- if (point.x() >= 0) >- return WebCore::IntRect(point, size); >- return WebCore::IntRect(); >-} >- >-WebCore::IntPoint GeneralAreaAllocator::allocateFromNode(const WebCore::IntSize& size, Node* node) >-{ >- // Find the best node to insert into, which should be >- // a node with the least amount of unused space that is >- // big enough to contain the requested size. >- while (node) { >- // Go down a level and determine if the left or right >- // sub-tree contains the best chance of allocation. >- Node* left = node->left; >- Node* right = node->right; >- if (left && fitsWithin(size, left->largestFree)) { >- if (right && fitsWithin(size, right->largestFree)) { >- if (left->largestFree.width() < right->largestFree.width() >- || left->largestFree.height() < right->largestFree.height()) { >- // The largestFree values may be a little oversized, >- // so try the left sub-tree and then the right sub-tree. >- WebCore::IntPoint point = allocateFromNode(size, left); >- if (point.x() >= 0) >- return point; >- return allocateFromNode(size, right); >- } >- node = right; >- } else >- node = left; >- } else if (right && fitsWithin(size, right->largestFree)) >- node = right; >- else if (left || right) { >- // Neither sub-node has enough space to allocate from. >- return WebCore::IntPoint(-1, -1); >- } else if (fitsWithin(size, node->largestFree)) { >- // Do we need to split this node into smaller pieces? >- Split split; >- if (fitsWithin(WebCore::IntSize(size.width() * 2, size.height() * 2), node->largestFree)) { >- // Split in either direction: choose the inverse of >- // the parent node's split direction to try to balance >- // out the wasted space as further subdivisions happen. >- if (node->parent >- && node->parent->left->rect.x() == node->parent->right->rect.x()) >- split = SplitOnX; >- else if (node->parent) >- split = SplitOnY; >- else if (node->rect.width() >= node->rect.height()) >- split = SplitOnX; >- else >- split = SplitOnY; >- } else if (fitsWithin(WebCore::IntSize(size.width() * 2, size.height()), node->largestFree)) { >- // Split along the X direction. >- split = SplitOnX; >- } else if (fitsWithin(WebCore::IntSize(size.width(), size.height() * 2), node->largestFree)) { >- // Split along the Y direction. >- split = SplitOnY; >- } else { >- // Cannot split further - allocate this node. >- node->largestFree = WebCore::IntSize(0, 0); >- updateLargestFree(node); >- return node->rect.location(); >- } >- >- // Split the node, then go around again using the left sub-tree. >- node = splitNode(node, split); >- } else { >- // Cannot possibly fit into this node. >- break; >- } >- } >- return WebCore::IntPoint(-1, -1); >-} >- >-GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode >- (Node* node, Split split) >-{ >- Node* left = new Node(); >- Node* right = new Node(); >- m_nodeCount += 2; >- left->parent = node; >- left->left = 0; >- left->right = 0; >- right->parent = node; >- right->left = 0; >- right->right = 0; >- node->left = left; >- node->right = right; >- >- if (split == SplitOnX) { >- left->rect = WebCore::IntRect(node->rect.x(), node->rect.y(), >- node->rect.width() / 2, node->rect.height()); >- right->rect = WebCore::IntRect(left->rect.maxX(), node->rect.y(), >- node->rect.width() / 2, node->rect.height()); >- } else { >- left->rect = WebCore::IntRect(node->rect.x(), node->rect.y(), >- node->rect.width(), node->rect.height() / 2); >- right->rect = WebCore::IntRect(node->rect.x(), left->rect.maxY(), >- node->rect.width(), node->rect.height() / 2); >- } >- >- left->largestFree = left->rect.size(); >- right->largestFree = right->rect.size(); >- node->largestFree = right->largestFree; >- return left; >-} >- >-void GeneralAreaAllocator::updateLargestFree(Node* node) >-{ >- while ((node = node->parent)) { >- node->largestFree = WebCore::IntSize( >- std::max(node->left->largestFree.width(), node->right->largestFree.width()), >- std::max(node->left->largestFree.height(), node->right->largestFree.height()) >- ); >- } >-} >- >-void GeneralAreaAllocator::release(const WebCore::IntRect& rect) >-{ >- // Locate the node that contains the allocated region. >- Node* node = m_root; >- WebCore::IntPoint point = rect.location(); >- while (node) { >- if (node->left && node->left->rect.contains(point)) >- node = node->left; >- else if (node->right && node->right->rect.contains(point)) >- node = node->right; >- else if (node->rect.contains(point)) >- break; >- else >- return; // Point is completely outside the tree. >- } >- if (!node) >- return; >- >- // Mark the node as free and then work upwards through the tree >- // recombining and deleting nodes until we reach a sibling >- // that is still allocated. >- node->largestFree = node->rect.size(); >- while (node->parent) { >- if (node->parent->left == node) { >- if (node->parent->right->largestFree != node->parent->right->rect.size()) >- break; >- } else { >- if (node->parent->left->largestFree != node->parent->left->rect.size()) >- break; >- } >- node = node->parent; >- freeNode(node->left); >- freeNode(node->right); >- m_nodeCount -= 2; >- node->left = 0; >- node->right = 0; >- node->largestFree = node->rect.size(); >- } >- >- // Make the rest of our ancestors have the correct "largest free size". >- updateLargestFree(node); >-} >- >-int GeneralAreaAllocator::overhead() const >-{ >- return m_nodeCount * sizeof(Node); >-} >- >-} // namespace >diff --git a/Source/WebKit2/WebProcess/WebPage/AreaAllocator.h b/Source/WebKit2/WebProcess/WebPage/AreaAllocator.h >deleted file mode 100644 >index ae88716c86d1c1a13adbdb4ea93a4781eed3539e..0000000000000000000000000000000000000000 >--- a/Source/WebKit2/WebProcess/WebPage/AreaAllocator.h >+++ /dev/null >@@ -1,110 +0,0 @@ >-/* >- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2.1 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Lesser General Public License for more details. >- * >- * You should have received a copy of the GNU Lesser General Public >- * License along with this library; if not, write to the Free Software >- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >- * >- */ >- >-#ifndef AreaAllocator_h >-#define AreaAllocator_h >- >-#include <IntPoint.h> >-#include <IntRect.h> >-#include <IntSize.h> >- >-namespace WebCore { >-inline int nextPowerOfTwo(int number) >-{ >- // This is a fast trick to get nextPowerOfTwo for an integer. >- --number; >- number |= number >> 1; >- number |= number >> 2; >- number |= number >> 4; >- number |= number >> 8; >- number |= number >> 16; >- number++; >- return number; >-} >- >-inline IntSize nextPowerOfTwo(const IntSize& size) >-{ >- return IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height())); >-} >-} // namespace WebCore >- >-namespace WebKit { >- >-class AreaAllocator { >-public: >- AreaAllocator(const WebCore::IntSize&); >- virtual ~AreaAllocator(); >- >- WebCore::IntSize size() const { return m_size; } >- >- WebCore::IntSize minimumAllocation() const { return m_minAlloc; } >- void setMinimumAllocation(const WebCore::IntSize& size) { m_minAlloc = size; } >- >- WebCore::IntSize margin() const { return m_margin; } >- void setMargin(const WebCore::IntSize &margin) { m_margin = margin; } >- >- virtual void expand(const WebCore::IntSize&); >- void expandBy(const WebCore::IntSize&); >- >- virtual WebCore::IntRect allocate(const WebCore::IntSize&) = 0; >- virtual void release(const WebCore::IntRect&); >- >- virtual int overhead() const; >- >-protected: >- WebCore::IntSize m_size; >- WebCore::IntSize m_minAlloc; >- WebCore::IntSize m_margin; >- >- WebCore::IntSize roundAllocation(const WebCore::IntSize&) const; >-}; >- >-class GeneralAreaAllocator : public AreaAllocator { >-public: >- GeneralAreaAllocator(const WebCore::IntSize&); >- virtual ~GeneralAreaAllocator(); >- >- void expand(const WebCore::IntSize&); >- WebCore::IntRect allocate(const WebCore::IntSize&); >- void release(const WebCore::IntRect&); >- int overhead() const; >- >-private: >- enum Split { SplitOnX, SplitOnY }; >- >- struct Node { >- WebCore::IntRect rect; >- WebCore::IntSize largestFree; >- Node* parent; >- Node* left; >- Node* right; >- }; >- >- Node* m_root; >- int m_nodeCount; >- >- static void freeNode(Node*); >- WebCore::IntPoint allocateFromNode(const WebCore::IntSize&, Node*); >- Node* splitNode(Node*, Split); >- static void updateLargestFree(Node*); >-}; >- >-} // namespace WebKit >- >-#endif >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3befcdac852012cfe93c87a5a9321a81d7535846 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp >@@ -0,0 +1,335 @@ >+/* >+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Lesser General Public >+ * License as published by the Free Software Foundation; either >+ * version 2.1 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Lesser General Public License for more details. >+ * >+ * You should have received a copy of the GNU Lesser General Public >+ * License along with this library; if not, write to the Free Software >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >+ * >+ */ >+ >+#include "config.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "AreaAllocator.h" >+ >+namespace WebKit { >+ >+AreaAllocator::AreaAllocator(const WebCore::IntSize& size) >+ : m_size(size) >+ , m_minAlloc(1, 1) >+ , m_margin(0, 0) >+{ >+} >+ >+AreaAllocator::~AreaAllocator() >+{ >+} >+ >+void AreaAllocator::expand(const WebCore::IntSize& size) >+{ >+ m_size = m_size.expandedTo(size); >+} >+ >+void AreaAllocator::expandBy(const WebCore::IntSize& size) >+{ >+ m_size += size; >+} >+ >+void AreaAllocator::release(const WebCore::IntRect&) >+{ >+} >+ >+int AreaAllocator::overhead() const >+{ >+ return 0; >+} >+ >+WebCore::IntSize AreaAllocator::roundAllocation(const WebCore::IntSize& size) const >+{ >+ int width = size.width() + m_margin.width(); >+ int height = size.height() + m_margin.height(); >+ int extra = width % m_minAlloc.width(); >+ if (extra) >+ width += m_minAlloc.width() - extra; >+ extra = height % m_minAlloc.height(); >+ if (extra) >+ height += m_minAlloc.height() - extra; >+ >+ return WebCore::IntSize(width, height); >+} >+ >+GeneralAreaAllocator::GeneralAreaAllocator(const WebCore::IntSize& size) >+ : AreaAllocator(WebCore::nextPowerOfTwo(size)) >+{ >+ m_root = new Node(); >+ m_root->rect = WebCore::IntRect(0, 0, m_size.width(), m_size.height()); >+ m_root->largestFree = m_size; >+ m_root->parent = 0; >+ m_root->left = 0; >+ m_root->right = 0; >+ m_nodeCount = 1; >+ setMinimumAllocation(WebCore::IntSize(8, 8)); >+} >+ >+GeneralAreaAllocator::~GeneralAreaAllocator() >+{ >+ freeNode(m_root); >+} >+ >+void GeneralAreaAllocator::freeNode(Node* node) >+{ >+ if (node) { >+ freeNode(node->left); >+ freeNode(node->right); >+ } >+ delete node; >+} >+ >+void GeneralAreaAllocator::expand(const WebCore::IntSize& size) >+{ >+ AreaAllocator::expand(WebCore::nextPowerOfTwo(size)); >+ >+ if (m_root->rect.size() == m_size) >+ return; // No change. >+ >+ if (!m_root->left && m_root->largestFree.width() > 0) { >+ // No allocations have occurred, so just adjust the root size. >+ m_root->rect = WebCore::IntRect(0, 0, m_size.width(), m_size.height()); >+ m_root->largestFree = m_size; >+ return; >+ } >+ >+ // Add extra nodes above the current root to expand the tree. >+ Node* oldRoot = m_root; >+ Split split; >+ if (m_size.width() >= m_size.height()) >+ split = SplitOnX; >+ else >+ split = SplitOnY; >+ >+ while (m_root->rect.size() != m_size) { >+ if (m_root->rect.width() == m_size.width()) >+ split = SplitOnY; >+ else if (m_root->rect.height() == m_size.height()) >+ split = SplitOnX; >+ Node* parent = new Node(); >+ Node* right = new Node(); >+ m_nodeCount += 2; >+ m_root->parent = parent; >+ parent->parent = 0; >+ parent->left = m_root; >+ parent->right = right; >+ parent->largestFree = m_root->rect.size(); >+ right->parent = parent; >+ right->left = 0; >+ right->right = 0; >+ right->largestFree = m_root->rect.size(); >+ if (split == SplitOnX) { >+ parent->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y(), >+ m_root->rect.width() * 2, m_root->rect.height()); >+ right->rect = WebCore::IntRect(m_root->rect.x() + m_root->rect.width(), m_root->rect.y(), >+ m_root->rect.width(), m_root->rect.height()); >+ } else { >+ parent->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y(), >+ m_root->rect.width(), m_root->rect.height() * 2); >+ right->rect = WebCore::IntRect(m_root->rect.x(), m_root->rect.y() + m_root->rect.width(), >+ m_root->rect.width(), m_root->rect.height()); >+ } >+ split = (split == SplitOnX ? SplitOnY : SplitOnX); >+ m_root = parent; >+ } >+ updateLargestFree(oldRoot); >+} >+ >+static inline bool fitsWithin(const WebCore::IntSize& size1, const WebCore::IntSize& size2) >+{ >+ return size1.width() <= size2.width() && size1.height() <= size2.height(); >+} >+ >+WebCore::IntRect GeneralAreaAllocator::allocate(const WebCore::IntSize& size) >+{ >+ WebCore::IntSize rounded = roundAllocation(size); >+ rounded = WebCore::nextPowerOfTwo(rounded); >+ if (rounded.width() <= 0 || rounded.width() > m_size.width() >+ || rounded.height() <= 0 || rounded.height() > m_size.height()) >+ return WebCore::IntRect(); >+ >+ WebCore::IntPoint point = allocateFromNode(rounded, m_root); >+ if (point.x() >= 0) >+ return WebCore::IntRect(point, size); >+ return WebCore::IntRect(); >+} >+ >+WebCore::IntPoint GeneralAreaAllocator::allocateFromNode(const WebCore::IntSize& size, Node* node) >+{ >+ // Find the best node to insert into, which should be >+ // a node with the least amount of unused space that is >+ // big enough to contain the requested size. >+ while (node) { >+ // Go down a level and determine if the left or right >+ // sub-tree contains the best chance of allocation. >+ Node* left = node->left; >+ Node* right = node->right; >+ if (left && fitsWithin(size, left->largestFree)) { >+ if (right && fitsWithin(size, right->largestFree)) { >+ if (left->largestFree.width() < right->largestFree.width() >+ || left->largestFree.height() < right->largestFree.height()) { >+ // The largestFree values may be a little oversized, >+ // so try the left sub-tree and then the right sub-tree. >+ WebCore::IntPoint point = allocateFromNode(size, left); >+ if (point.x() >= 0) >+ return point; >+ return allocateFromNode(size, right); >+ } >+ node = right; >+ } else >+ node = left; >+ } else if (right && fitsWithin(size, right->largestFree)) >+ node = right; >+ else if (left || right) { >+ // Neither sub-node has enough space to allocate from. >+ return WebCore::IntPoint(-1, -1); >+ } else if (fitsWithin(size, node->largestFree)) { >+ // Do we need to split this node into smaller pieces? >+ Split split; >+ if (fitsWithin(WebCore::IntSize(size.width() * 2, size.height() * 2), node->largestFree)) { >+ // Split in either direction: choose the inverse of >+ // the parent node's split direction to try to balance >+ // out the wasted space as further subdivisions happen. >+ if (node->parent >+ && node->parent->left->rect.x() == node->parent->right->rect.x()) >+ split = SplitOnX; >+ else if (node->parent) >+ split = SplitOnY; >+ else if (node->rect.width() >= node->rect.height()) >+ split = SplitOnX; >+ else >+ split = SplitOnY; >+ } else if (fitsWithin(WebCore::IntSize(size.width() * 2, size.height()), node->largestFree)) { >+ // Split along the X direction. >+ split = SplitOnX; >+ } else if (fitsWithin(WebCore::IntSize(size.width(), size.height() * 2), node->largestFree)) { >+ // Split along the Y direction. >+ split = SplitOnY; >+ } else { >+ // Cannot split further - allocate this node. >+ node->largestFree = WebCore::IntSize(0, 0); >+ updateLargestFree(node); >+ return node->rect.location(); >+ } >+ >+ // Split the node, then go around again using the left sub-tree. >+ node = splitNode(node, split); >+ } else { >+ // Cannot possibly fit into this node. >+ break; >+ } >+ } >+ return WebCore::IntPoint(-1, -1); >+} >+ >+GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode >+ (Node* node, Split split) >+{ >+ Node* left = new Node(); >+ Node* right = new Node(); >+ m_nodeCount += 2; >+ left->parent = node; >+ left->left = 0; >+ left->right = 0; >+ right->parent = node; >+ right->left = 0; >+ right->right = 0; >+ node->left = left; >+ node->right = right; >+ >+ if (split == SplitOnX) { >+ left->rect = WebCore::IntRect(node->rect.x(), node->rect.y(), >+ node->rect.width() / 2, node->rect.height()); >+ right->rect = WebCore::IntRect(left->rect.maxX(), node->rect.y(), >+ node->rect.width() / 2, node->rect.height()); >+ } else { >+ left->rect = WebCore::IntRect(node->rect.x(), node->rect.y(), >+ node->rect.width(), node->rect.height() / 2); >+ right->rect = WebCore::IntRect(node->rect.x(), left->rect.maxY(), >+ node->rect.width(), node->rect.height() / 2); >+ } >+ >+ left->largestFree = left->rect.size(); >+ right->largestFree = right->rect.size(); >+ node->largestFree = right->largestFree; >+ return left; >+} >+ >+void GeneralAreaAllocator::updateLargestFree(Node* node) >+{ >+ while ((node = node->parent)) { >+ node->largestFree = WebCore::IntSize( >+ std::max(node->left->largestFree.width(), node->right->largestFree.width()), >+ std::max(node->left->largestFree.height(), node->right->largestFree.height()) >+ ); >+ } >+} >+ >+void GeneralAreaAllocator::release(const WebCore::IntRect& rect) >+{ >+ // Locate the node that contains the allocated region. >+ Node* node = m_root; >+ WebCore::IntPoint point = rect.location(); >+ while (node) { >+ if (node->left && node->left->rect.contains(point)) >+ node = node->left; >+ else if (node->right && node->right->rect.contains(point)) >+ node = node->right; >+ else if (node->rect.contains(point)) >+ break; >+ else >+ return; // Point is completely outside the tree. >+ } >+ if (!node) >+ return; >+ >+ // Mark the node as free and then work upwards through the tree >+ // recombining and deleting nodes until we reach a sibling >+ // that is still allocated. >+ node->largestFree = node->rect.size(); >+ while (node->parent) { >+ if (node->parent->left == node) { >+ if (node->parent->right->largestFree != node->parent->right->rect.size()) >+ break; >+ } else { >+ if (node->parent->left->largestFree != node->parent->left->rect.size()) >+ break; >+ } >+ node = node->parent; >+ freeNode(node->left); >+ freeNode(node->right); >+ m_nodeCount -= 2; >+ node->left = 0; >+ node->right = 0; >+ node->largestFree = node->rect.size(); >+ } >+ >+ // Make the rest of our ancestors have the correct "largest free size". >+ updateLargestFree(node); >+} >+ >+int GeneralAreaAllocator::overhead() const >+{ >+ return m_nodeCount * sizeof(Node); >+} >+ >+} // namespace >+ >+#endif // USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h >new file mode 100644 >index 0000000000000000000000000000000000000000..17f2edac96255f222b5af7858b3512128543ee02 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h >@@ -0,0 +1,114 @@ >+/* >+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Lesser General Public >+ * License as published by the Free Software Foundation; either >+ * version 2.1 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Lesser General Public License for more details. >+ * >+ * You should have received a copy of the GNU Lesser General Public >+ * License along with this library; if not, write to the Free Software >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >+ * >+ */ >+ >+#ifndef AreaAllocator_h >+#define AreaAllocator_h >+ >+#include <IntPoint.h> >+#include <IntRect.h> >+#include <IntSize.h> >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+namespace WebCore { >+inline int nextPowerOfTwo(int number) >+{ >+ // This is a fast trick to get nextPowerOfTwo for an integer. >+ --number; >+ number |= number >> 1; >+ number |= number >> 2; >+ number |= number >> 4; >+ number |= number >> 8; >+ number |= number >> 16; >+ number++; >+ return number; >+} >+ >+inline IntSize nextPowerOfTwo(const IntSize& size) >+{ >+ return IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height())); >+} >+} // namespace WebCore >+ >+namespace WebKit { >+ >+class AreaAllocator { >+public: >+ AreaAllocator(const WebCore::IntSize&); >+ virtual ~AreaAllocator(); >+ >+ WebCore::IntSize size() const { return m_size; } >+ >+ WebCore::IntSize minimumAllocation() const { return m_minAlloc; } >+ void setMinimumAllocation(const WebCore::IntSize& size) { m_minAlloc = size; } >+ >+ WebCore::IntSize margin() const { return m_margin; } >+ void setMargin(const WebCore::IntSize &margin) { m_margin = margin; } >+ >+ virtual void expand(const WebCore::IntSize&); >+ void expandBy(const WebCore::IntSize&); >+ >+ virtual WebCore::IntRect allocate(const WebCore::IntSize&) = 0; >+ virtual void release(const WebCore::IntRect&); >+ >+ virtual int overhead() const; >+ >+protected: >+ WebCore::IntSize m_size; >+ WebCore::IntSize m_minAlloc; >+ WebCore::IntSize m_margin; >+ >+ WebCore::IntSize roundAllocation(const WebCore::IntSize&) const; >+}; >+ >+class GeneralAreaAllocator : public AreaAllocator { >+public: >+ GeneralAreaAllocator(const WebCore::IntSize&); >+ virtual ~GeneralAreaAllocator(); >+ >+ void expand(const WebCore::IntSize&); >+ WebCore::IntRect allocate(const WebCore::IntSize&); >+ void release(const WebCore::IntRect&); >+ int overhead() const; >+ >+private: >+ enum Split { SplitOnX, SplitOnY }; >+ >+ struct Node { >+ WebCore::IntRect rect; >+ WebCore::IntSize largestFree; >+ Node* parent; >+ Node* left; >+ Node* right; >+ }; >+ >+ Node* m_root; >+ int m_nodeCount; >+ >+ static void freeNode(Node*); >+ WebCore::IntPoint allocateFromNode(const WebCore::IntSize&, Node*); >+ Node* splitNode(Node*, Split); >+ static void updateLargestFree(Node*); >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(COORDINATED_GRAPHICS) >+ >+#endif // AreaAllocator_h >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9a5418f1eaaa3487b4e424b9a95620208309754e >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp >@@ -0,0 +1,99 @@ >+/* >+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >+ >+ This library is free software; you can redistribute it and/or >+ modify it under the terms of the GNU Library General Public >+ License as published by the Free Software Foundation; either >+ version 2 of the License, or (at your option) any later version. >+ >+ This library is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ Library General Public License for more details. >+ >+ You should have received a copy of the GNU Library General Public License >+ along with this library; see the file COPYING.LIB. If not, write to >+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "UpdateAtlas.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "GraphicsContext.h" >+#include "IntRect.h" >+#include <wtf/MathExtras.h> >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+UpdateAtlas::UpdateAtlas(UpdateAtlasClient* client, int dimension, ShareableBitmap::Flags flags) >+ : m_client(client) >+ , m_flags(flags) >+ , m_inactivityInSeconds(0) >+ , m_isVaild(true) >+{ >+ static int nextID = 0; >+ m_ID = ++nextID; >+ IntSize size = nextPowerOfTwo(IntSize(dimension, dimension)); >+ m_surface = ShareableSurface::create(size, flags, ShareableSurface::SupportsGraphicsSurface); >+ >+ if (!m_surface->createHandle(m_handle)) { >+ m_isVaild = false; >+ return; >+ } >+ m_client->createUpdateAtlas(m_ID, m_handle); >+} >+ >+UpdateAtlas::~UpdateAtlas() >+{ >+ if (m_isVaild) >+ m_client->removeUpdateAtlas(m_ID); >+} >+ >+void UpdateAtlas::buildLayoutIfNeeded() >+{ >+ if (!m_areaAllocator) { >+ m_areaAllocator = adoptPtr(new GeneralAreaAllocator(size())); >+ m_areaAllocator->setMinimumAllocation(IntSize(32, 32)); >+ } >+} >+ >+void UpdateAtlas::didSwapBuffers() >+{ >+ m_areaAllocator.clear(); >+} >+ >+PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize& size, IntPoint& offset) >+{ >+ m_inactivityInSeconds = 0; >+ buildLayoutIfNeeded(); >+ IntRect rect = m_areaAllocator->allocate(size); >+ >+ // No available buffer was found, returning null. >+ if (rect.isEmpty()) >+ return PassOwnPtr<GraphicsContext>(); >+ >+ if (!m_isVaild) >+ return PassOwnPtr<GraphicsContext>(); >+ >+ atlasID = m_ID; >+ >+ // FIXME: Use tri-state buffers, to allow faster updates. >+ offset = rect.location(); >+ OwnPtr<GraphicsContext> graphicsContext = m_surface->createGraphicsContext(rect); >+ >+ if (flags() & ShareableBitmap::SupportsAlpha) { >+ graphicsContext->setCompositeOperation(CompositeCopy); >+ graphicsContext->fillRect(IntRect(IntPoint::zero(), size), Color::transparent, ColorSpaceDeviceRGB); >+ graphicsContext->setCompositeOperation(CompositeSourceOver); >+ } >+ >+ return graphicsContext.release(); >+} >+ >+} >+#endif >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7cefe9c979421586273f4e0cd309a20234c71ad1 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h >@@ -0,0 +1,82 @@ >+/* >+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >+ >+ This library is free software; you can redistribute it and/or >+ modify it under the terms of the GNU Library General Public >+ License as published by the Free Software Foundation; either >+ version 2 of the License, or (at your option) any later version. >+ >+ This library is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ Library General Public License for more details. >+ >+ You should have received a copy of the GNU Library General Public License >+ along with this library; see the file COPYING.LIB. If not, write to >+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ Boston, MA 02110-1301, USA. >+ */ >+ >+#ifndef UpdateAtlas_h >+#define UpdateAtlas_h >+ >+#include "AreaAllocator.h" >+#include "IntSize.h" >+#include "ShareableSurface.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+namespace WebCore { >+class GraphicsContext; >+class IntPoint; >+} >+ >+namespace WebKit { >+ >+class UpdateAtlasClient { >+public: >+ virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&) = 0; >+ virtual void removeUpdateAtlas(int atlasID) = 0; >+}; >+ >+class UpdateAtlas { >+ WTF_MAKE_NONCOPYABLE(UpdateAtlas); >+public: >+ UpdateAtlas(UpdateAtlasClient*, int dimension, ShareableBitmap::Flags); >+ ~UpdateAtlas(); >+ >+ inline WebCore::IntSize size() const { return m_surface->size(); } >+ >+ // Returns a null pointer of there is no available buffer. >+ PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize&, WebCore::IntPoint& offset); >+ void didSwapBuffers(); >+ ShareableBitmap::Flags flags() const { return m_flags; } >+ >+ void addTimeInactive(double seconds) >+ { >+ ASSERT(!isInUse()); >+ m_inactivityInSeconds += seconds; >+ } >+ bool isInactive() const >+ { >+ const double inactiveSecondsTolerance = 3; >+ return m_inactivityInSeconds > inactiveSecondsTolerance; >+ } >+ bool isInUse() const { return m_areaAllocator; } >+ >+private: >+ void buildLayoutIfNeeded(); >+ >+private: >+ UpdateAtlasClient* m_client; >+ OwnPtr<GeneralAreaAllocator> m_areaAllocator; >+ ShareableBitmap::Flags m_flags; >+ RefPtr<ShareableSurface> m_surface; >+ ShareableSurface::Handle m_handle; >+ double m_inactivityInSeconds; >+ int m_ID; >+ bool m_isVaild; >+}; >+ >+} >+#endif >+#endif // UpdateAtlas_h >diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp >deleted file mode 100644 >index 9a5418f1eaaa3487b4e424b9a95620208309754e..0000000000000000000000000000000000000000 >--- a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp >+++ /dev/null >@@ -1,99 +0,0 @@ >-/* >- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >- >- This library is free software; you can redistribute it and/or >- modify it under the terms of the GNU Library General Public >- License as published by the Free Software Foundation; either >- version 2 of the License, or (at your option) any later version. >- >- This library is distributed in the hope that it will be useful, >- but WITHOUT ANY WARRANTY; without even the implied warranty of >- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- Library General Public License for more details. >- >- You should have received a copy of the GNU Library General Public License >- along with this library; see the file COPYING.LIB. If not, write to >- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "UpdateAtlas.h" >- >-#if USE(COORDINATED_GRAPHICS) >- >-#include "GraphicsContext.h" >-#include "IntRect.h" >-#include <wtf/MathExtras.h> >- >-using namespace WebCore; >- >-namespace WebKit { >- >-UpdateAtlas::UpdateAtlas(UpdateAtlasClient* client, int dimension, ShareableBitmap::Flags flags) >- : m_client(client) >- , m_flags(flags) >- , m_inactivityInSeconds(0) >- , m_isVaild(true) >-{ >- static int nextID = 0; >- m_ID = ++nextID; >- IntSize size = nextPowerOfTwo(IntSize(dimension, dimension)); >- m_surface = ShareableSurface::create(size, flags, ShareableSurface::SupportsGraphicsSurface); >- >- if (!m_surface->createHandle(m_handle)) { >- m_isVaild = false; >- return; >- } >- m_client->createUpdateAtlas(m_ID, m_handle); >-} >- >-UpdateAtlas::~UpdateAtlas() >-{ >- if (m_isVaild) >- m_client->removeUpdateAtlas(m_ID); >-} >- >-void UpdateAtlas::buildLayoutIfNeeded() >-{ >- if (!m_areaAllocator) { >- m_areaAllocator = adoptPtr(new GeneralAreaAllocator(size())); >- m_areaAllocator->setMinimumAllocation(IntSize(32, 32)); >- } >-} >- >-void UpdateAtlas::didSwapBuffers() >-{ >- m_areaAllocator.clear(); >-} >- >-PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize& size, IntPoint& offset) >-{ >- m_inactivityInSeconds = 0; >- buildLayoutIfNeeded(); >- IntRect rect = m_areaAllocator->allocate(size); >- >- // No available buffer was found, returning null. >- if (rect.isEmpty()) >- return PassOwnPtr<GraphicsContext>(); >- >- if (!m_isVaild) >- return PassOwnPtr<GraphicsContext>(); >- >- atlasID = m_ID; >- >- // FIXME: Use tri-state buffers, to allow faster updates. >- offset = rect.location(); >- OwnPtr<GraphicsContext> graphicsContext = m_surface->createGraphicsContext(rect); >- >- if (flags() & ShareableBitmap::SupportsAlpha) { >- graphicsContext->setCompositeOperation(CompositeCopy); >- graphicsContext->fillRect(IntRect(IntPoint::zero(), size), Color::transparent, ColorSpaceDeviceRGB); >- graphicsContext->setCompositeOperation(CompositeSourceOver); >- } >- >- return graphicsContext.release(); >-} >- >-} >-#endif >diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h >deleted file mode 100644 >index 7cefe9c979421586273f4e0cd309a20234c71ad1..0000000000000000000000000000000000000000 >--- a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h >+++ /dev/null >@@ -1,82 +0,0 @@ >-/* >- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) >- >- This library is free software; you can redistribute it and/or >- modify it under the terms of the GNU Library General Public >- License as published by the Free Software Foundation; either >- version 2 of the License, or (at your option) any later version. >- >- This library is distributed in the hope that it will be useful, >- but WITHOUT ANY WARRANTY; without even the implied warranty of >- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- Library General Public License for more details. >- >- You should have received a copy of the GNU Library General Public License >- along with this library; see the file COPYING.LIB. If not, write to >- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- Boston, MA 02110-1301, USA. >- */ >- >-#ifndef UpdateAtlas_h >-#define UpdateAtlas_h >- >-#include "AreaAllocator.h" >-#include "IntSize.h" >-#include "ShareableSurface.h" >- >-#if USE(COORDINATED_GRAPHICS) >-namespace WebCore { >-class GraphicsContext; >-class IntPoint; >-} >- >-namespace WebKit { >- >-class UpdateAtlasClient { >-public: >- virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&) = 0; >- virtual void removeUpdateAtlas(int atlasID) = 0; >-}; >- >-class UpdateAtlas { >- WTF_MAKE_NONCOPYABLE(UpdateAtlas); >-public: >- UpdateAtlas(UpdateAtlasClient*, int dimension, ShareableBitmap::Flags); >- ~UpdateAtlas(); >- >- inline WebCore::IntSize size() const { return m_surface->size(); } >- >- // Returns a null pointer of there is no available buffer. >- PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize&, WebCore::IntPoint& offset); >- void didSwapBuffers(); >- ShareableBitmap::Flags flags() const { return m_flags; } >- >- void addTimeInactive(double seconds) >- { >- ASSERT(!isInUse()); >- m_inactivityInSeconds += seconds; >- } >- bool isInactive() const >- { >- const double inactiveSecondsTolerance = 3; >- return m_inactivityInSeconds > inactiveSecondsTolerance; >- } >- bool isInUse() const { return m_areaAllocator; } >- >-private: >- void buildLayoutIfNeeded(); >- >-private: >- UpdateAtlasClient* m_client; >- OwnPtr<GeneralAreaAllocator> m_areaAllocator; >- ShareableBitmap::Flags m_flags; >- RefPtr<ShareableSurface> m_surface; >- ShareableSurface::Handle m_handle; >- double m_inactivityInSeconds; >- int m_ID; >- bool m_isVaild; >-}; >- >-} >-#endif >-#endif // UpdateAtlas_h
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 103864
:
177201
|
177420
|
177440