2 * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "BackingStoreCompositingSurface.h"
22 #include "GraphicsContext.h"
23 #include "SurfacePool.h"
25 #if USE(ACCELERATED_COMPOSITING)
27 #include <BlackBerryPlatformGraphics.h>
29 namespace BlackBerry {
32 CompositingSurfaceBuffer::CompositingSurfaceBuffer(const Platform::IntSize& size)
38 CompositingSurfaceBuffer::~CompositingSurfaceBuffer()
40 destroyBuffer(m_buffer);
43 Platform::IntSize CompositingSurfaceBuffer::surfaceSize() const
48 Platform::Graphics::Buffer* CompositingSurfaceBuffer::nativeBuffer() const
51 m_buffer = createBuffer(m_size,
52 Platform::Graphics::TileBuffer,
53 Platform::Graphics::GLES2);
58 BackingStoreCompositingSurface::BackingStoreCompositingSurface(const Platform::IntSize& size, bool doubleBuffered)
59 : m_isDoubleBuffered(doubleBuffered)
62 m_frontBuffer = new CompositingSurfaceBuffer(size);
63 m_backBuffer = !doubleBuffered ? 0 : new CompositingSurfaceBuffer(size);
66 BackingStoreCompositingSurface::~BackingStoreCompositingSurface()
75 CompositingSurfaceBuffer* BackingStoreCompositingSurface::frontBuffer() const
77 ASSERT(m_frontBuffer);
81 CompositingSurfaceBuffer* BackingStoreCompositingSurface::backBuffer() const
83 if (!m_isDoubleBuffered)
90 void BackingStoreCompositingSurface::swapBuffers()
92 if (!m_isDoubleBuffered)
96 unsigned front = reinterpret_cast<unsigned>(frontBuffer());
97 unsigned back = reinterpret_cast<unsigned>(backBuffer());
100 _smp_xchg(reinterpret_cast<unsigned*>(&m_frontBuffer), back);
101 _smp_xchg(reinterpret_cast<unsigned*>(&m_backBuffer), front);
104 } // namespace WebKit
105 } // namespace BlackBerry
106 #endif // USE(ACCELERATED_COMPOSITING)