#ifndef Texture_h
#define Texture_h
#if USE(ACCELERATED_COMPOSITING)
#include "IntSize.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
class SkBitmap;
namespace WebCore {
class Color;
class IntRect;
class TextureCacheCompositingThread;
class Texture : public RefCounted<Texture> {
public:
static PassRefPtr<Texture> create(bool isColor = false)
{
return adoptRef(new Texture(isColor));
}
~Texture();
unsigned textureId() const { return m_textureId; }
bool isDirty() const { return !m_textureId; }
bool hasTexture() const { return m_textureId; }
bool isColor() const { return m_isColor; }
bool isOpaque() const { return m_isOpaque; }
bool isProtected() const { return m_protectionCount > 0; }
void protect() { ++m_protectionCount; }
void unprotect() { --m_protectionCount; }
bool protect(const IntSize&);
void updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tile, bool isOpaque);
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; }
private:
friend class TextureCacheCompositingThread;
Texture(bool isColor = false);
void setTextureId(unsigned id)
{
m_textureId = id;
m_size = IntSize();
}
int m_protectionCount;
unsigned m_textureId;
IntSize m_size;
bool m_isColor;
bool m_isOpaque;
};
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif // Texture_h