BackingStoreBackendCairoImpl.cpp [plain text]
#include "config.h"
#include "BackingStoreBackendCairoImpl.h"
#if USE(CAIRO)
#include "CairoUtilities.h"
namespace WebCore {
BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl(cairo_surface_t* surface, const IntSize& size)
: BackingStoreBackendCairo(size)
{
m_surface = surface;
double xScale, yScale;
cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
IntSize scaledSize = size;
scaledSize.scale(xScale, yScale);
m_scrollSurface = adoptRef(cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
}
BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl()
{
}
void BackingStoreBackendCairoImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
{
IntRect targetRect = scrollRect;
targetRect.move(scrollOffset);
targetRect.shiftMaxXEdgeTo(targetRect.maxX() - scrollOffset.width());
targetRect.shiftMaxYEdgeTo(targetRect.maxY() - scrollOffset.height());
if (targetRect.isEmpty())
return;
copyRectFromOneSurfaceToAnother(m_surface.get(), m_scrollSurface.get(), scrollOffset, targetRect);
copyRectFromOneSurfaceToAnother(m_scrollSurface.get(), m_surface.get(), IntSize(), targetRect);
}
}
#endif // USE(CAIRO)