00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef BTRGBA32BUFFER_H
00035 #define BTRGBA32BUFFER_H
00036
00037 #include "config.h"
00038 #include "IntRect.h"
00039 #include <wtf/Vector.h>
00040 #include "DeprecatedArray.h"
00041 #include "RGBA32Array.h"
00042
00043 namespace BAL {
00044
00045 typedef WebCore::DeprecatedArray<char> DeprecatedByteArray;
00046
00051 class RGBA32Buffer
00052 {
00053 public:
00054 enum FrameStatus { FrameEmpty, FramePartial, FrameComplete };
00055
00056 RGBA32Buffer() : m_height(0), m_status(FrameEmpty), m_duration(0),
00057 m_includeInNextFrame(false), m_hasAlpha(false)
00058 {}
00059
00063 const RGBA32Array& bytes() const { return m_bytes; }
00064 RGBA32Array& bytes() { return m_bytes; }
00068 const WebCore::IntRect& rect() const { return m_rect; }
00072 unsigned height() const { return m_height; }
00076 unsigned width() const { return m_rect.width(); }
00080 FrameStatus status() const { return m_status; }
00084 unsigned duration() const { return m_duration; }
00088 bool includeInNextFrame() const { return m_includeInNextFrame; }
00092 bool hasAlpha() const { return m_hasAlpha; }
00093
00097 void setRect(const WebCore::IntRect& r) { m_rect = r; }
00101 void ensureHeight(unsigned rowIndex) { if (rowIndex > m_height) m_height = rowIndex; }
00105 void setStatus(FrameStatus s) { m_status = s; }
00109 void setDuration(unsigned duration) { m_duration = duration; }
00113 void setIncludeInNextFrame(bool n) { m_includeInNextFrame = n; }
00117 void setHasAlpha(bool alpha) { m_hasAlpha = alpha; }
00118
00122 static void setRGBA(unsigned& pos, unsigned r, unsigned g, unsigned b, unsigned a)
00123 {
00124
00125 if (a == 0)
00126 pos = 0;
00127 else {
00128 if (a < 255) {
00129 float alphaPercent = a / 255.0f;
00130 r = (unsigned int)((float)r * alphaPercent);
00131 g = (unsigned int)((float)g * alphaPercent);
00132 b = (unsigned int)((float)b * alphaPercent);
00133 }
00134 pos = (a << 24 | r << 16 | g << 8 | b);
00135 }
00136 }
00137
00138 private:
00139 RGBA32Array m_bytes;
00140 WebCore::IntRect m_rect;
00141
00142
00143 unsigned m_height;
00144 FrameStatus m_status;
00145 unsigned m_duration;
00146 bool m_includeInNextFrame;
00147 bool m_hasAlpha;
00148 };
00149
00150 }
00151
00152 #endif