diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
commit | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch) | |
tree | b34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp | |
parent | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff) | |
download | qtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz |
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp')
-rw-r--r-- | Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp b/Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp new file mode 100644 index 000000000..a02f93a1c --- /dev/null +++ b/Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved. + * + * 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 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 "BackingStoreTile.h" + +#include "GraphicsContext.h" +#include "SurfacePool.h" + +#include <BlackBerryPlatformGraphics.h> + +namespace BlackBerry { +namespace WebKit { + +TileBuffer::TileBuffer(const Platform::IntSize& size) + : m_size(size) + , m_buffer(0) + , m_blitGeneration(0) +{ +} + +TileBuffer::~TileBuffer() +{ + destroyBuffer(m_buffer); +} + +Platform::IntSize TileBuffer::size() const +{ + return m_size; +} + +Platform::IntRect TileBuffer::rect() const +{ + return Platform::IntRect(Platform::IntPoint::zero(), m_size); +} + +bool TileBuffer::isRendered() const +{ + return isRendered(rect()); +} + +bool TileBuffer::isRendered(const Platform::IntRectRegion& contents) const +{ + return Platform::IntRectRegion::subtractRegions(contents, m_renderedRegion).isEmpty(); +} + +void TileBuffer::clearRenderedRegion(const Platform::IntRectRegion& region) +{ + m_renderedRegion = Platform::IntRectRegion::subtractRegions(m_renderedRegion, region); +} + +void TileBuffer::clearRenderedRegion() +{ + m_renderedRegion = Platform::IntRectRegion(); +} + +void TileBuffer::addRenderedRegion(const Platform::IntRectRegion& region) +{ + m_renderedRegion = Platform::IntRectRegion::unionRegions(region, m_renderedRegion); +} + +Platform::IntRectRegion TileBuffer::renderedRegion() const +{ + return m_renderedRegion; +} + +Platform::IntRectRegion TileBuffer::notRenderedRegion() const +{ + return Platform::IntRectRegion::subtractRegions(rect(), renderedRegion()); +} + +Platform::Graphics::Buffer* TileBuffer::nativeBuffer() const +{ + if (!m_buffer) + m_buffer = createBuffer(m_size, Platform::Graphics::TileBuffer, SurfacePool::globalSurfacePool()->sharedPixmapGroup()); + + return m_buffer; +} + + +BackingStoreTile::BackingStoreTile(const Platform::IntSize& size, BufferingMode mode) + : m_bufferingMode(mode) + , m_committed(false) + , m_backgroundPainted(false) + , m_horizontalShift(0) + , m_verticalShift(0) +{ + m_frontBuffer = new TileBuffer(size); +} + +BackingStoreTile::~BackingStoreTile() +{ + delete m_frontBuffer; + m_frontBuffer = 0; +} + +Platform::IntSize BackingStoreTile::size() const +{ + return frontBuffer()->size(); +} + +Platform::IntRect BackingStoreTile::rect() const +{ + return frontBuffer()->rect(); +} + +TileBuffer* BackingStoreTile::frontBuffer() const +{ + ASSERT(m_frontBuffer); + return m_frontBuffer; +} + +TileBuffer* BackingStoreTile::backBuffer() const +{ + if (m_bufferingMode == SingleBuffered) + return frontBuffer(); + + return SurfacePool::globalSurfacePool()->backBuffer(); +} + +void BackingStoreTile::swapBuffers() +{ + if (m_bufferingMode == SingleBuffered) + return; + + // Store temps. + unsigned front = reinterpret_cast<unsigned>(frontBuffer()); + unsigned back = reinterpret_cast<unsigned>(backBuffer()); + + // Atomic change. + _smp_xchg(reinterpret_cast<unsigned*>(&m_frontBuffer), back); + _smp_xchg(reinterpret_cast<unsigned*>(&SurfacePool::globalSurfacePool()->m_backBuffer), front); +} + +void BackingStoreTile::reset() +{ + setCommitted(false); + frontBuffer()->clearRenderedRegion(); + backBuffer()->clearRenderedRegion(); + clearShift(); +} + +void BackingStoreTile::paintBackground() +{ + m_backgroundPainted = true; + + clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0); +} + +} +} |