#ifndef LayerTexture_h
#define LayerTexture_h
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsTypes3D.h"
#include "IntSize.h"
#include <BlackBerryPlatformGraphics.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class Color;
class IntRect;
class TextureCacheCompositingThread;
class LayerTexture : public RefCounted<LayerTexture> {
public:
static PassRefPtr<LayerTexture> create(bool isColor = false)
{
return adoptRef(new LayerTexture(isColor));
}
~LayerTexture();
bool isDirty() const { return !m_buffer; }
BlackBerry::Platform::Graphics::Buffer* buffer() const { return m_buffer; }
bool isColor() const { return m_isColor; }
bool isProtected() const { return m_protectionCount > 0; }
void protect() { ++m_protectionCount; }
void unprotect() { --m_protectionCount; }
bool protect(const IntSize&, BlackBerry::Platform::Graphics::BufferType = BlackBerry::Platform::Graphics::BackedWhenNecessary);
Platform3DObject platformTexture() const;
void updateContents(BlackBerry::Platform::Graphics::Buffer*);
void setContentsToColor(const Color&);
IntSize size() const { return m_size; }
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
static int bytesPerPixel() { return 4; }
size_t sizeInBytes() const { return m_bufferSizeInBytes; }
private:
friend class TextureCacheCompositingThread;
LayerTexture(bool isColor = false);
void setBuffer(BlackBerry::Platform::Graphics::Buffer* buffer)
{
m_buffer = buffer;
m_size = IntSize();
m_bufferSizeInBytes = 0;
}
void setSize(const IntSize& size) { m_size = size; }
int m_protectionCount;
BlackBerry::Platform::Graphics::Buffer* m_buffer;
IntSize m_size;
bool m_isColor;
size_t m_bufferSizeInBytes;
};
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif // LayerTexture_h