#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
#include "LayerTile.h"
#include "TextureCacheCompositingThread.h"
namespace WebCore {
LayerTile::LayerTile()
: m_contentsDirty(false)
{
}
LayerTile::~LayerTile()
{
setVisible(false);
}
void LayerTile::setContents(const SkBitmap& contents, const IntRect& tileRect, const TileIndex& index, bool isOpaque)
{
setTexture(textureCacheCompositingThread()->textureForTiledContents(contents, tileRect, index, isOpaque));
}
void LayerTile::setContentsToColor(const Color& color)
{
setTexture(textureCacheCompositingThread()->textureForColor(color));
}
void LayerTile::updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tileRect, bool isOpaque)
{
setTexture(textureCacheCompositingThread()->updateContents(m_texture, contents, dirtyRect, tileRect, isOpaque));
}
void LayerTile::discardContents()
{
setTexture(0);
}
void LayerTile::setVisible(bool visible)
{
if (visible == m_visible)
return;
m_visible = visible;
if (!m_texture)
return;
if (visible)
m_texture->protect();
else
m_texture->unprotect();
}
void LayerTile::setTexture(PassRefPtr<Texture> texture)
{
m_contentsDirty = false;
if (texture == m_texture)
return;
if (m_visible) {
if (m_texture)
m_texture->unprotect();
if (texture)
texture->protect();
}
m_texture = texture;
}
}
#endif // USE(ACCELERATED_COMPOSITING)