CCTiledLayerTestCommon.cpp [plain text]
#include "config.h"
#include "CCTiledLayerTestCommon.h"
using namespace WebCore;
namespace WebKitTests {
FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, PassOwnPtr<ManagedTexture> texture)
: LayerTextureUpdater::Texture(texture)
, m_layer(layer)
{
}
FakeLayerTextureUpdater::Texture::~Texture()
{
}
void FakeLayerTextureUpdater::Texture::updateRect(GraphicsContext3D*, TextureAllocator* allocator, const IntRect&, const IntRect&)
{
if (allocator)
texture()->allocate(allocator);
m_layer->updateRect();
}
void FakeLayerTextureUpdater::Texture::prepareRect(const IntRect&)
{
m_layer->prepareRect();
}
FakeLayerTextureUpdater::FakeLayerTextureUpdater()
: m_prepareCount(0)
, m_updateCount(0)
, m_prepareRectCount(0)
{
}
FakeLayerTextureUpdater::~FakeLayerTextureUpdater()
{
}
void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect& resultingOpaqueRect)
{
m_prepareCount++;
m_lastUpdateRect = contentRect;
if (!m_rectToInvalidate.isEmpty()) {
m_layer->invalidateRect(m_rectToInvalidate);
m_rectToInvalidate = IntRect();
m_layer = 0;
}
resultingOpaqueRect = m_opaquePaintRect;
}
void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiledLayerChromium* layer)
{
m_rectToInvalidate = rect;
m_layer = layer;
}
PassOwnPtr<LayerTextureUpdater::Texture> FakeLayerTextureUpdater::createTexture(TextureManager* manager)
{
return adoptPtr(new Texture(this, ManagedTexture::create(manager)));
}
FakeCCTiledLayerImpl::FakeCCTiledLayerImpl(int id)
: CCTiledLayerImpl(id)
{
}
FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl()
{
}
FakeTiledLayerChromium::FakeTiledLayerChromium(TextureManager* textureManager)
: TiledLayerChromium()
, m_fakeTextureUpdater(adoptRef(new FakeLayerTextureUpdater))
, m_textureManager(textureManager)
{
setTileSize(tileSize());
setTextureFormat(GraphicsContext3D::RGBA);
setBorderTexelOption(CCLayerTilingData::NoBorderTexels);
setIsDrawable(true); }
FakeTiledLayerChromium::~FakeTiledLayerChromium()
{
}
void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect)
{
m_lastNeedsDisplayRect = rect;
TiledLayerChromium::setNeedsDisplayRect(rect);
}
void FakeTiledLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion)
{
updateLayerRect(updater, visibleLayerRect(), occlusion);
}
FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(TextureManager* textureManager)
: FakeTiledLayerChromium(textureManager)
{
}
}